|
@@ -18,7 +18,7 @@ class CMTSRESTControllerTest extends WebTestCaseBase
|
|
|
{
|
|
|
return '/api/cmtss.json';
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* @return string Retorna la uri a consultar.
|
|
|
*/
|
|
@@ -41,18 +41,27 @@ class CMTSRESTControllerTest extends WebTestCaseBase
|
|
|
*/
|
|
|
protected function obtainDataWebService()
|
|
|
{
|
|
|
- $datos = [];
|
|
|
+ $datos = array();
|
|
|
+ $datos['api/clients'] =
|
|
|
+ json_encode(array(array("name" => "Stock", "id" => 1)));
|
|
|
+ $datos['api/devices/check'] =
|
|
|
+ json_encode(array(array('result' => true, 'errors' => null)));
|
|
|
+ $datos['api/devices'] =
|
|
|
+ json_encode(array('id' => 1));
|
|
|
+
|
|
|
+ $datos["client"] = array(array("id" => 1));
|
|
|
+
|
|
|
|
|
|
return $datos;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Genera los datos a manipular.
|
|
|
- *
|
|
|
+ *
|
|
|
* @param string $key Contiene la key a buscar en los datos.
|
|
|
- *
|
|
|
+ *
|
|
|
* @return array|string Retorna el array con los datos o el valor de la key pasada como parametro.
|
|
|
- *
|
|
|
+ *
|
|
|
* @throws \Exception Lanza un excepcion en caso de no encontrar la key.
|
|
|
*/
|
|
|
protected function obtainData($key = null)
|
|
@@ -67,7 +76,8 @@ class CMTSRESTControllerTest extends WebTestCaseBase
|
|
|
'timeCmtsOctets' => 5,
|
|
|
'executeSnmp' => true,
|
|
|
'extraData' => '',
|
|
|
- 'tenancyId' => 1
|
|
|
+ 'tenancyId' => 1,
|
|
|
+ 'deviceId' => 1,
|
|
|
];
|
|
|
|
|
|
if ($key == null) {
|
|
@@ -86,10 +96,10 @@ class CMTSRESTControllerTest extends WebTestCaseBase
|
|
|
* get_cmtss -> /api/cmtss.{_format}
|
|
|
* controller: CablemodemBundle:CMTSREST:cget
|
|
|
* Method: GET
|
|
|
- *
|
|
|
+ *
|
|
|
* @param string $uri Contiene la direccion.
|
|
|
* @param array $data Contiene los filtros a utilizar en la busqueda.
|
|
|
- *
|
|
|
+ *
|
|
|
* @return null|Response Retorna el response.
|
|
|
*/
|
|
|
private function generateGET($uri = null, $data = null)
|
|
@@ -105,7 +115,7 @@ class CMTSRESTControllerTest extends WebTestCaseBase
|
|
|
];
|
|
|
}
|
|
|
$this->getClient()->request('GET', $uri . $this->generateFilters($data));
|
|
|
-
|
|
|
+
|
|
|
return $this->getClient()->getResponse();
|
|
|
}
|
|
|
|
|
@@ -117,7 +127,7 @@ class CMTSRESTControllerTest extends WebTestCaseBase
|
|
|
$webservicemock = $this->getContainerObject('webservice');
|
|
|
$listener = $this->getContainerObject('device.device_listener');
|
|
|
$listener->setWebservice($webservicemock);
|
|
|
-
|
|
|
+
|
|
|
$validator = $this->getContainerObject('device.device_validator');
|
|
|
$validator->setWebservice($webservicemock);
|
|
|
}
|
|
@@ -138,7 +148,7 @@ class CMTSRESTControllerTest extends WebTestCaseBase
|
|
|
$this->getClient()->request('POST', $this->getPOSTUri(), $this->obtainData());
|
|
|
// obtengo la respuesta
|
|
|
$response = $this->getClient()->getResponse();
|
|
|
-
|
|
|
+
|
|
|
$this->assertEquals(201, $response->getStatusCode(), "Error en la respuesta http.");
|
|
|
}
|
|
|
|
|
@@ -176,7 +186,7 @@ class CMTSRESTControllerTest extends WebTestCaseBase
|
|
|
$this->setListener();
|
|
|
// creo el nuevo set de datos a enviar.
|
|
|
$data = $this->obtainDataChange($this->obtainData(), [
|
|
|
- 'name' => 'Test test',
|
|
|
+ 'name' => 'Test test',
|
|
|
'id' => $id,
|
|
|
]);
|
|
|
// hago la modificacion llamando al servicio por put
|
|
@@ -200,7 +210,7 @@ class CMTSRESTControllerTest extends WebTestCaseBase
|
|
|
$this->assertJson($response->getContent(), "No se obtuvo un objeto json.");
|
|
|
$this->assertContains('Test test', $response->getContent(), "Error al buscar CMTS modificado.");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Realiza una baja.
|
|
|
* delete_cmtss -> /api/cmtss.{_format}
|
|
@@ -236,6 +246,6 @@ class CMTSRESTControllerTest extends WebTestCaseBase
|
|
|
// verifco el resultado
|
|
|
$this->assertEquals(200, $response->getStatusCode(), "Error en la respuesta http.");
|
|
|
$this->assertJson($response->getContent(), "No se obtuvo un objeto json.");
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
}
|