Commit 54e2dad3 authored by okhin's avatar okhin 🚴

get users by email

parent cf41e30a
...@@ -25,6 +25,18 @@ class UserFinder ...@@ -25,6 +25,18 @@ class UserFinder
return $this->connection->fetchAssoc("SELECT * FROM users WHERE id = :id", ['id' => (int) $id]); return $this->connection->fetchAssoc("SELECT * FROM users WHERE id = :id", ['id' => (int) $id]);
} }
/**
* findByEmail
*
* @param mixed $email
*
* @return []
*/
public function findByEmail($email)
{
return $this->connection->fetchAssoc("SELECT * FROM users WHERE email = :email", ['email' => $email]);
}
/** /**
* The search from the admin. * The search from the admin.
* *
......
...@@ -24,6 +24,24 @@ class UserFinderTest extends FunctionalTest ...@@ -24,6 +24,24 @@ class UserFinderTest extends FunctionalTest
$this->assertEquals($expectedUser, $user); $this->assertEquals($expectedUser, $user);
} }
public function testFindByEmail()
{
$user = $this->container['user_finder']->findByEmail('alice@example.org');
$expectedUser = [
'id' => '1',
'status' => '1',
'hash' => '5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8',
'cumul' => '2000',
'email' => 'alice@example.org',
'total' => '5000',
'pseudo' => 'Alice',
'expiration' => null,
'commentaire' => 'RAS',
];
$this->assertEquals($expectedUser, $user);
}
public function testAdminSearch() public function testAdminSearch()
{ {
$this->assertCount(1, $this->container['user_finder']->adminSearch($text='alice@example.org', $status='')); $this->assertCount(1, $this->container['user_finder']->adminSearch($text='alice@example.org', $status=''));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment