Commit bdb1af3b authored by okhin's avatar okhin 🚴

Add a findByPseudo user finder

parent a39e9915
...@@ -61,7 +61,7 @@ SELECT d.id as id, ...@@ -61,7 +61,7 @@ SELECT d.id as id,
a.ville AS ville, a.ville AS ville,
a.pays AS pays a.pays AS pays
FROM dons d FROM dons d
JOIN users u ON u.id = d.user_id LEFT JOIN users u ON u.id = d.user_id
LEFT JOIN adresses a ON d.adresse_id = a.id LEFT JOIN adresses a ON d.adresse_id = a.id
WHERE 1=1 WHERE 1=1
EOQ; EOQ;
...@@ -92,6 +92,7 @@ EOQ; ...@@ -92,6 +92,7 @@ EOQ;
$params['date1'] = $date1; $params['date1'] = $date1;
$params['date2'] = $date2; $params['date2'] = $date2;
} }
$first = ($page - 1) * $limit; $first = ($page - 1) * $limit;
$last = ($page) * $limit; $last = ($page) * $limit;
$query .= " ORDER BY datec DESC LIMIT $first, $last"; $query .= " ORDER BY datec DESC LIMIT $first, $last";
......
...@@ -37,6 +37,18 @@ class UserFinder ...@@ -37,6 +37,18 @@ class UserFinder
return $this->connection->fetchAssoc("SELECT * FROM users WHERE email = :email", ['email' => $email]); return $this->connection->fetchAssoc("SELECT * FROM users WHERE email = :email", ['email' => $email]);
} }
/**
* findByPseudo
*
* @param mixed pseudo
*
* @return []
*/
public function findByPseudo($pseudo)
{
return $this->connection->fetchAssoc("SELECT * FROM users WHERE pseudo = :pseudo", ['pseudo' => $pseudo]);
}
/** /**
* The search from the admin. * The search from the admin.
* *
......
...@@ -42,6 +42,25 @@ class UserFinderTest extends FunctionalTest ...@@ -42,6 +42,25 @@ class UserFinderTest extends FunctionalTest
$this->assertEquals($expectedUser, $user); $this->assertEquals($expectedUser, $user);
} }
public function testFindByPseudo()
{
$user = $this->container['user_finder']->findByPseudo('Alice');
$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