Hello,
I would like to validate a test when I have a valid user. Unfortunately, this one is blocking because of the password when debugging.
Here’s the fixture
<?php namespace App\Test\Fixture;
use Cake\TestSuite\Fixture\TestFixture;
class UsersFixture extends TestFixture
{
public $import = [‘table’ => ‘users’];
public $fields = [
‘id’ => [
‘type’ => ‘integer’,
‘length’ => 11,
‘unsigned’ => false,
‘null’ => false,
‘default’ => null,
‘comment’ => ‘’,
‘autoIncrement’ => true,
‘precision’ => null,
],
‘id_user’ => [
‘type’ => ‘integer’,
‘length’ => 11,
‘null’ => false,
‘default’ => null,
‘comment’ => ‘’,
‘precision’ => null,
],
‘password’ => [
‘type’ => ‘text’,
‘length’ => 255,
‘null’ => false,
‘default’ => null,
‘collate’ => ‘utf8_general_ci’,
‘comment’ => ‘’,
‘precision’ => null,
‘fixed’ => null,
],
‘role’ => [
‘type’ => ‘text’,
‘length’ => 20,
‘null’ => false,
‘default’ => null,
‘collate’ => ‘utf8_general_ci’,
‘comment’ => ‘’,
‘precision’ => null,
‘fixed’ => null,
],
public $records = [
[
‘id’ => 1,
‘username’ => ‘admin’,
‘password’ => ‘12345678’,
‘role’ => ‘ADMIN’,
‘email’ => ‘admin@gmail.com’,
‘notification_email’ => 1,
‘active’ => 1,
‘blocked’ => 0,
‘created’ => ‘2016-08-02 09:00:00’,
‘modified’ => ‘2016-09-02 09:00:00’,
‘token_password’ => ‘token_vraiment’
],
[
‘id’ => 2,
‘username’ => ‘user0’,
‘password’ => ‘123456789’,
‘role’ => ‘USER’,
‘email’ => ‘user0@gmail.com’,
‘notification_email’ => 1,
‘active’ => 1,
‘blocked’ => 0,
‘created’ => ‘2016-08-02 09:00:00’,
‘modified’ => ‘2016-09-02 09:00:00’,
],
];
And the controllerTest
<?php namespace SupportPlugin\Test\TestCase\Controller; use Cake\TestSuite\IntegrationTestCase; use Cake\ORM\TableRegistry;
/**
- Class TwoFactorsControllerTest
/
class UsersControllerTest extends IntegrationTestCase
{
public $fixtures = [
‘app.users’,
‘app.adress_ips’
];
/*
* Test identify success login action
*
* @return void
*/
public function testIdentifySuccessLoginAction()
{
$this->post([‘_name’ => ‘support:users:login’], [
‘username’ => ‘user0’,
‘password’ => ‘123456789’
]);
$this->assertSession([
'id' => 2,
'username' => 'user0',
'role' => 'USER',
'email' => 'user0@gmail.com',
'notification_email' => 1,
'version_wordpress_default' => null,
'version_php_default' => null,
'version_mysql_default' => null,
'secret' => null
], 'Auth.User');
$this->assertRedirect(['_name' => 'support:home']);
}
And this response phpunit:
There was 1 failure:
- SupportPlugin\Test\TestCase\Controller\UsersControllerTest::testIdentifySuccessLoginAction
Session content for “Auth.User” differs.
null does not match expected type “array”.
I need you help.