AuthTest
extends ApiTestCase
in package
Test unitarios de todas las funciones relacionadas con auth
Tags
Table of Contents
Properties
- $_DEBUG : bool
- $cookieJar : CookieJar
- $http : Client
Methods
- accionesProtegidasProvider() : array<string|int, mixed>
- testAccionesProtegidasSinSesionDevuelven403() : void
- Las acciones protegidas deben devolver 403
- testCheckSessionConLoginDevuelveDatosCorrectos() : void
- Si hay login previo, checkSession debe devolver 200
- testCheckSessionSinCredencialesDevuelve401() : void
- Si no hay login previo, checkSession debe devolver 401
- testLoginCredencialesCorrectasDevuelve200() : void
- Un login correcto debe devolver status 200
- testLoginCredencialesIncorrectasDevuelve401() : void
- Un login incorrecto debe devolver 401
- testLoginSinCredencialesDevuelve400() : void
- Un login sin credenciales debe ser 400
- testLogoutInvalidaSesion() : void
- Se comprueba el ciclo de: iniciar sesion -> checkSession 200 -> cerrar sesion -> checkSession 401
- iniciarSesion() : void
- Inicia sesión con las credenciales del .env.
- post() : array{0: int, 1: array}
- Ejecuta un POST contra la API y devuelve [statusCode, bodyArray].
- setUp() : void
- setUp de los tests. Carga el .env de no estarlo, el cookieJar y http
- trace() : void
- Imprime una traza de ejecución con contexto, dirección y payload.
Properties
$_DEBUG
protected
bool
$_DEBUG
= \true
$cookieJar
protected
CookieJar
$cookieJar
$http
protected
Client
$http
Methods
accionesProtegidasProvider()
public
static accionesProtegidasProvider() : array<string|int, mixed>
Return values
array<string|int, mixed>testAccionesProtegidasSinSesionDevuelven403()
Las acciones protegidas deben devolver 403
public
testAccionesProtegidasSinSesionDevuelven403(string $accion, array<string|int, mixed> $params) : void
Parameters
- $accion : string
- $params : array<string|int, mixed>
Tags
Attributes
- #[DataProvider]
- 'accionesProtegidasProvider'
testCheckSessionConLoginDevuelveDatosCorrectos()
Si hay login previo, checkSession debe devolver 200
public
testCheckSessionConLoginDevuelveDatosCorrectos() : void
Tags
testCheckSessionSinCredencialesDevuelve401()
Si no hay login previo, checkSession debe devolver 401
public
testCheckSessionSinCredencialesDevuelve401() : void
Tags
testLoginCredencialesCorrectasDevuelve200()
Un login correcto debe devolver status 200
public
testLoginCredencialesCorrectasDevuelve200() : void
Tags
testLoginCredencialesIncorrectasDevuelve401()
Un login incorrecto debe devolver 401
public
testLoginCredencialesIncorrectasDevuelve401() : void
Tags
testLoginSinCredencialesDevuelve400()
Un login sin credenciales debe ser 400
public
testLoginSinCredencialesDevuelve400() : void
Tags
testLogoutInvalidaSesion()
Se comprueba el ciclo de: iniciar sesion -> checkSession 200 -> cerrar sesion -> checkSession 401
public
testLogoutInvalidaSesion() : void
Tags
iniciarSesion()
Inicia sesión con las credenciales del .env.
protected
iniciarSesion([bool $admin = false ]) : void
Marca el test como skipped si no están configuradas.
Parameters
- $admin : bool = false
Tags
post()
Ejecuta un POST contra la API y devuelve [statusCode, bodyArray].
protected
post(string $endpoint, array<string|int, mixed> $params) : array{0: int, 1: array}
Imprime automáticamente request y response por consola.
Parameters
- $endpoint : string
-
: Punto de entrada
- $params : array<string|int, mixed>
-
: Parametros de la peticion
Tags
Return values
array{0: int, 1: array}setUp()
setUp de los tests. Carga el .env de no estarlo, el cookieJar y http
protected
setUp() : void
trace()
Imprime una traza de ejecución con contexto, dirección y payload.
protected
trace(string $contexto, string $mensaje[, mixed|null $payload = null ]) : void
Parameters
- $contexto : string
-
: Contexto del mensaje
- $mensaje : string
-
: Mensaje
- $payload : mixed|null = null
-
: Carga del mensaje