Skip to content

Instantly share code, notes, and snippets.

@loro102
Last active March 13, 2018 12:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loro102/acf96e8ddd11498acb64698a5d744ef6 to your computer and use it in GitHub Desktop.
Save loro102/acf96e8ddd11498acb64698a5d744ef6 to your computer and use it in GitHub Desktop.
Test error
Testing started at 13:17 ...
sftp://root@127.0.0.1:2222/usr/bin/php /var/www/vendor/phpunit/phpunit/phpunit --configuration /var/www/phpunit.xml --filter "/::Usuario_puede_crear_clientes( .*)?$/" Tests\\Feature\\ClientTest /var/www/tests/Feature/ClientTest.php --teamcity
PHPUnit 7.0.2 by Sebastian Bergmann and contributors.
null does not match expected type "array".
/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestResponse.php:709
/var/www/tests/Feature/ClientTest.php:114
Time: 31.5 seconds, Memory: 24.00MB
FAILURES!
Tests: 1, Assertions: 18, Failures: 1.
Process finished with exit code 1
public function Usuario_puede_crear_clientes()
{
//Verifica que salta mensaje de error en caso de que los campos estén vacios
$this->users=factory(User::class)->create();
$this->withExceptionHandling();
$this->signIn();
$this->get('/clientes');
$this->clients->nombre=null;
$this->clients->apellidos=null;
$this->clients->nif=null;
$response=$this->post('/clientes/',$this->clients->toArray());
$response
->assertStatus(302)
->assertSessionHasErrors(['nombre','apellidos','nif']);
$this->clients->nombre='Ratoncito';
$response=$this->post('/clientes',$this->clients->toArray());
$response
->assertStatus(302)
->assertSessionHasErrors(['apellidos','nif']);
$this->clients->apellidos='Perez';
$response=$this->post('/clientes',$this->clients->toArray());
$response
->assertStatus(302)
->assertSessionHasErrors(['nif']);
//verifica que el nif no es válido
$this->clients->nif='10002112P';
$response=$this->post('/clientes',$this->clients->toArray());
$response
->assertStatus(302)
->assertSessionHasErrors(['nif']);
//Verifica que los campos obligatorios son correctos y válidos, y además devuelva el mensaje de cliente creado.
$this->client = factory(Client::class)->create([
'nombre' => 'Abigail',
'apellidos'=> 'Pestaña Rota',
'nif'=>'10002112X',
'user'=>$this->users->id
]);
$response=$this->post('/clientes/',$this->clients->toArray());
$response
->assertStatus(302)
->assertSee('clientes')
->assertSessionHas('message',['success',__('Cliente creado correctamente')]); //esta es la linea que falla
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment