Browse Source

Agregado de todos los test de ONU

gabriel 7 years ago
parent
commit
749381d9d4
2 changed files with 63 additions and 65 deletions
  1. 4 4
      composer.lock
  2. 59 61
      src/FTTHBundle/tests/ONURESTControllerTest.php

+ 4 - 4
composer.lock

@@ -1443,7 +1443,7 @@
             "source": {
                 "type": "git",
                 "url": "ssh://git@gogs.infra.flowdat.com:222/VendorSoftwareFlowdat3/DeviceBundle.git",
-                "reference": "61a172c14ad8f5b82aa2facdfd56ef3293b65638"
+                "reference": "d6e4b53c759bdce8f03580e8783b1f40581f0d3f"
             },
             "type": "library",
             "autoload": {
@@ -1458,7 +1458,7 @@
                 "bundle",
                 "validators"
             ],
-            "time": "2017-09-15 12:51:43"
+            "time": "2017-09-15 14:14:26"
         },
         {
             "name": "ik/extra-data-bundle",
@@ -1632,7 +1632,7 @@
             "source": {
                 "type": "git",
                 "url": "ssh://git@200.50.168.30:222/VendorSoftwareFlowdat3/Webservice.git",
-                "reference": "784f6b89bfc0e127c8c69e3b68fba334d54ffa37"
+                "reference": "9ca153996372b0e67788c32628b2fa49a43e3e13"
             },
             "require": {
                 "ext-curl": "*",
@@ -1645,7 +1645,7 @@
                 }
             },
             "description": "The Flowdat3 Webservice Rest",
-            "time": "2017-09-15 12:12:42"
+            "time": "2017-09-15 13:40:56"
         },
         {
             "name": "ik/workflow-bundle",

+ 59 - 61
src/FTTHBundle/tests/ONURESTControllerTest.php

@@ -37,9 +37,6 @@ class ONURESTControllerTest extends WebTestCaseBase
     protected function obtainDataWebService()
     {
         $datos = array();
-//        original
-//        $datos['client'] =
-//            json_encode(array(array("name" => "Stock", "id" => 1)));
         $datos['api/clients'] =
             json_encode(array(array("name" => "Stock", "id" => 1)));
         $datos['api/devices/check'] =
@@ -63,7 +60,6 @@ class ONURESTControllerTest extends WebTestCaseBase
         $datos['mac'] = '00:11:22:33';
         $datos['ponSerialNumber'] = 'pon';
         $datos['clientId'] = array('name' => 'Stock GZ [pruebass]');
-//        $datos['clientId'] = '1';
         $datos['transitionState'] = 'ts';
         $datos['tenancyId'] = 1;
         $datos['deviceId'] = 1;
@@ -111,8 +107,11 @@ class ONURESTControllerTest extends WebTestCaseBase
      */
     public function testPOST()
     {
+        // inicializo con los datos del webservicemock
         $this->initDefault($this->obtainDataWebService());
+        // seteo los datos del listener
         $this->setListener();
+        // hago la inserccion llamando al servicio por post
         $this->getClient()->request('POST', $this->getUri(), $this->obtainData());
         // obtengo la respuesta
         $response = $this->getClient()->getResponse();
@@ -143,73 +142,73 @@ class ONURESTControllerTest extends WebTestCaseBase
      */
     public function testPUT()
     {
-        $this->initDefault($this->obtainDataWebService());
-        $this->setListener();
+        // realizo la consulta
         $response = $this->generateGET();
+        // busco el id
         $id = $this->getProperty($response, 'id');
-        // realizo la consulta
+        // inicializo con los datos del webservicemock
         $this->initDefault($this->obtainDataWebService());
+        // seteo los datos del listener
         $this->setListener();
+        // creo el nuevo set de datos a enviar.
         $data = $this->obtainDataChange($this->obtainData(), array('ponSerialNumber' => 'pon_modifi', 'id' => $id));
+        // hago la modificacion llamando al servicio por put
         $this->getClient()->request('PUT', $this->getUriPutDelete() . $id, $data);
         // obtengo la respuesta
         $response = $this->getClient()->getResponse();
-        $logger = $this->getContainerObject('logger');
-        $logger->err($response->getContent());
         $this->assertEquals(200, $response->getStatusCode(), "Error en la respuesta http.");
     }
 
-//    /**
-//     * Realiza una busqueda.
-//     * get_onus -> /api/onus.{_format}
-//     * controller: ClientBundle:ClientREST:cget
-//     * Method: GET
-//     */
-//    public function testGET_PUT()
-//    {
-//        $response = $this->generateGET();
-//        // verifco el resultado
-//        $this->assertEquals(200, $response->getStatusCode(), "Error en la respuesta http.");
-//        $this->assertJson($response->getContent(), "No se obtuvo un objeto json.");
-//        $this->assertContains('pon_modifi', strtolower($response->getContent()), "Error al buscar al onu modificado.");
-//    }
-//
-//
-//    /**
-//     * Realiza una baja.
-//     * delete_onu -> /api/onus.{_format}
-//     * controller: ClientBundle:ClientREST:delete
-//     * Method: DELETE
-//     */
-//    public function testDELETE()
-//    {
-//        // busco el id de
-//        $response = $this->generateGET();
-//        // obtengo el id de la respuesta de la busqueda
-//        $id = $this->getProperty($response, 'id');
-//        $this->initDefault();
-//        // realizo la consulta
-//        $data = array('tenancy' => 1);
-//        $this->getClient()->request('DELETE', $this->getUriPutDelete() . $id, $data);
-//        // obtengo la respuesta
-//        $response = $this->getClient()->getResponse();
-//        $this->assertEquals(204, $response->getStatusCode(), "Error en la respuesta http.");
-//    }
-//
-//    /**
-//     * Realiza una busqueda.
-//     * get_onus -> /api/onus.{_format}
-//     * controller: ClientBundle:ClientREST:cget
-//     * Method: GET
-//     */
-//    public function testGET_DELETE()
-//    {
-//        $response = $this->generateGET();
-//        // verifco el resultado
-//        $this->assertEquals(200, $response->getStatusCode(), "Error en la respuesta http.");
-//        $json = json_decode($response->getContent());
-//        $this->assertTrue(empty($json), "No se obtuvo un objeto json.");
-//    }
+    /**
+     * Realiza una busqueda.
+     * get_onus -> /api/onus.{_format}
+     * controller: ClientBundle:ClientREST:cget
+     * Method: GET
+     */
+    public function testGET_PUT()
+    {
+        $response = $this->generateGET();
+        // verifco el resultado
+        $this->assertEquals(200, $response->getStatusCode(), "Error en la respuesta http.");
+        $this->assertJson($response->getContent(), "No se obtuvo un objeto json.");
+        $this->assertContains('pon_modifi', strtolower($response->getContent()), "Error al buscar al onu modificado.");
+    }
+
+
+    /**
+     * Realiza una baja.
+     * delete_onu -> /api/onus.{_format}
+     * controller: ClientBundle:ClientREST:delete
+     * Method: DELETE
+     */
+    public function testDELETE()
+    {
+        // realizo la consulta
+        $response = $this->generateGET();
+        // obtengo el id de la respuesta de la busqueda
+        $id = $this->getProperty($response, 'id');
+        $this->initDefault();
+        // realizo la consulta
+        $data = array('tenancy' => 1);
+        $this->getClient()->request('DELETE', $this->getUriPutDelete() . $id, $data);
+        // obtengo la respuesta
+        $response = $this->getClient()->getResponse();
+        $this->assertEquals(204, $response->getStatusCode(), "Error en la respuesta http.");
+    }
+
+    /**
+     * Realiza una busqueda.
+     * get_onus -> /api/onus.{_format}
+     * controller: ClientBundle:ClientREST:cget
+     * Method: GET
+     */
+    public function testGET_DELETE()
+    {
+        $response = $this->generateGET();
+        // verifco el resultado
+        $this->assertEquals(200, $response->getStatusCode(), "Error en la respuesta http.");
+        $this->assertJson($response->getContent(), "No se obtuvo un objeto json.");
+    }
 
     /**
      * Sobreescribe el device.device_listener
@@ -223,6 +222,5 @@ class ONURESTControllerTest extends WebTestCaseBase
         $validator = $this->getContainerObject('device.device_validator');
         $validator->setWebservice($webservicemock);
         $this->setContainerObject('device.device_validator', $validator);
-
     }
 }