diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 284a3229..8b3b2fcc 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -2,7 +2,7 @@ - + diff --git a/src/Auth/MultiColumnAuthenticate.php b/src/Auth/MultiColumnAuthenticate.php index 0a38e542..13fa458a 100644 --- a/src/Auth/MultiColumnAuthenticate.php +++ b/src/Auth/MultiColumnAuthenticate.php @@ -83,7 +83,7 @@ protected function _query(string $username): SelectQuery { $options['username'] = $username; } - return $table->find($finder, $options); + return $table->find($finder, ...$options); } } diff --git a/tests/Fixture/UsersFixture.php b/tests/Fixture/UsersFixture.php index acc87f4f..85dbfaf5 100644 --- a/tests/Fixture/UsersFixture.php +++ b/tests/Fixture/UsersFixture.php @@ -17,6 +17,7 @@ class UsersFixture extends TestFixture { public array $fields = [ 'id' => ['type' => 'integer'], 'username' => ['type' => 'string', 'null' => false, 'length' => 64, 'comment' => '', 'charset' => 'utf8'], + 'email' => ['type' => 'string', 'null' => false, 'length' => 64, 'comment' => '', 'charset' => 'utf8'], 'role_id' => ['type' => 'integer', 'null' => false, 'default' => '0', 'length' => 11, 'collate' => null, 'comment' => ''], '_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]], ]; @@ -30,16 +31,19 @@ class UsersFixture extends TestFixture { [ 'id' => '1', 'username' => 'dereuromark', + 'email' => 'dereuromark@test.de', 'role_id' => ROLE_USER, ], [ 'id' => '2', 'username' => 'bravo-kernel', + 'email' => 'bravo-kernel@test.de', 'role_id' => ROLE_ADMIN, ], [ 'id' => '3', 'username' => 'adriana', + 'email' => 'adriana@test.de', 'role_id' => ROLE_MODERATOR, ], ]; diff --git a/tests/TestCase/Auth/MultiColumnAuthenticateTest.php b/tests/TestCase/Auth/MultiColumnAuthenticateTest.php new file mode 100644 index 00000000..9480dad5 --- /dev/null +++ b/tests/TestCase/Auth/MultiColumnAuthenticateTest.php @@ -0,0 +1,45 @@ + + */ + protected array $fixtures = [ + 'plugin.TinyAuth.Users', + ]; + + /** + * Test applying config in the constructor + * + * @return void + */ + public function testGetUser() { + $request = new ServerRequest(); + $request = $request->withData('login', 'dereuromark'); + $request = $request->withData('password', '123'); + + $object = new MultiColumnAuthenticate(new ComponentRegistry(new Controller($request)), [ + 'fields' => [ + 'username' => 'login', + 'password' => 'password', + ], + 'columns' => ['username', 'email'], + ]); + $result = $object->authenticate($request, new Response()); + $this->assertFalse($result); + } + +} diff --git a/tests/TestCase/Auth/TinyAuthorizeTest.php b/tests/TestCase/Auth/TinyAuthorizeTest.php index 0da4d08a..485c66ab 100644 --- a/tests/TestCase/Auth/TinyAuthorizeTest.php +++ b/tests/TestCase/Auth/TinyAuthorizeTest.php @@ -21,7 +21,7 @@ class TinyAuthorizeTest extends TestCase { /** - * @var array + * @var array */ protected array $fixtures = [ 'plugin.TinyAuth.Users', diff --git a/tests/TestCase/Controller/Component/AuthUserComponentTest.php b/tests/TestCase/Controller/Component/AuthUserComponentTest.php index 8575ee28..a0550297 100644 --- a/tests/TestCase/Controller/Component/AuthUserComponentTest.php +++ b/tests/TestCase/Controller/Component/AuthUserComponentTest.php @@ -15,7 +15,7 @@ class AuthUserComponentTest extends TestCase { /** - * @var array + * @var array */ protected array $fixtures = [ 'core.Sessions', diff --git a/tests/TestCase/Utility/TinyAuthTest.php b/tests/TestCase/Utility/TinyAuthTest.php index e633b583..30dbd523 100644 --- a/tests/TestCase/Utility/TinyAuthTest.php +++ b/tests/TestCase/Utility/TinyAuthTest.php @@ -8,7 +8,7 @@ class TinyAuthTest extends TestCase { /** - * @var array + * @var array */ protected array $fixtures = [ 'plugin.TinyAuth.DatabaseRoles',