Просмотр исходного кода

Agregado del setContainer para el phpunit

Your Name 7 лет назад
Родитель
Сommit
61a172c14a
2 измененных файлов с 24 добавлено и 14 удалено
  1. 9 10
      EventListener/DeviceListener.php
  2. 15 4
      Validator/Constraints/DeviceValidator.php

+ 9 - 10
EventListener/DeviceListener.php

@@ -45,16 +45,6 @@ class DeviceListener
         $this->enabled = true;
     }
 
-    /**
-     * Se utiliza para las pruebas de phpunit
-     * @param Webservice $webservice
-     */
-    public function setWebservice($webservice)
-    {
-        $this->webservice = $webservice;
-    }
-
-
     /**
      * @param LifecycleEventArgs $args
      */
@@ -170,4 +160,13 @@ class DeviceListener
         $this->enabled = $enabled;
     }
 
+    /**
+     * Se utiliza para las pruebas de phpunit
+     * @param Webservice $webservice
+     */
+    public function setWebservice($webservice)
+    {
+        $this->webservice = $webservice;
+    }
+
 }

+ 15 - 4
Validator/Constraints/DeviceValidator.php

@@ -28,7 +28,7 @@ class DeviceValidator extends ConstraintValidator
     {
         $this->webservice = $webservice;
         $this->deviceCheckUrl = $deviceCheckUrl;
-	$this->enabled = true;
+        $this->enabled = true;
     }
 
     /**
@@ -37,18 +37,29 @@ class DeviceValidator extends ConstraintValidator
      */
     public function validate($entity, Constraint $constraint)
     {
-	if(!$this->enabled) return;
+        if (!$this->enabled) return;
 
         $result = $this->webservice->makeGetRequest($this->deviceCheckUrl);
         $data = json_decode($result, true);
         if (is_null($entity->getId()) && isset($data['result']) && $data['result'] == false) {
             $this->context->buildViolation($constraint->message)
-                    ->addViolation();
+                ->addViolation();
         }
     }
 
-    function remoteCheck($enable){
+    function remoteCheck($enable)
+    {
         $this->enabled = $enable;
     }
 
+    /**
+     * Se utiliza para las pruebas de phpunit
+     * @param Webservice $webservice
+     */
+    public function setWebservice($webservice)
+    {
+        $this->webservice = $webservice;
+    }
+
+
 }