|
@@ -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);
|
|
|
-
|
|
|
}
|
|
|
}
|