1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- <?php
- namespace IPv4Bundle\tests\Controller\REST;
- use WebserviceBundle\tests\WebTestCaseBase;
- use IPv4Bundle\Entity\Host;
- /**
- * Class HostRESTControllerTest
- * @package IPv4Bundle\tests\Controller\REST
- * En caso de modificar las tablas solo se deberia modificar la funcion "obtainData" agregando los campos necesarios.
- */
- class HostRESTControllerTest extends BaseRESTControllerTest
- {
- /**
- * @var string $entity
- */
- protected $entity = 'Host';
- /**
- * @var string $field
- */
- protected $field = 'mac';
- /**
- * @var string $field_value_edited
- */
- protected $field_value_edited = 'cafecafecaff';
- /**
- * @return string Retorna la uri a consultar.
- */
- protected function getUri()
- {
- return '/api/hosts.json';
- }
- /**
- * @return string Retorna la uri a consultar.
- */
- protected function getPOSTUri()
- {
- return '/api/hosts.json';
- }
- /**
- * @return string Retorna la uri a consultar.
- */
- protected function getUriPutDelete()
- {
- return '/api/hosts/';
- }
- /**
- * Contiene los datos que debe retornar el webservice. La key es nombre del webservice y el
- * value son los datos a retornar.
- */
- protected function obtainDataWebService()
- {
- $datos = [];
- 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)
- {
- $datos = [
- 'mac' => 'cafecafecafe',
- 'options' => 'cafecafecafe',
- 'hostType' => null,
- 'state' => Host::STATE_ACTIVE,
- ];
- if ($key == null) {
- return $datos;
- } else {
- if (isset($datos[$key])) {
- return $datos[$key];
- } else {
- throw new \Exception("No se seteo la key del dato a obtener. key=" . $key);
- }
- }
- }
- }
|