Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/private/User/AccountMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,11 @@ public function getByEmail($email) {
throw new \InvalidArgumentException('$email must be defined');
}
$qb = $this->db->getQueryBuilder();
// RFC 5321 says that only domain name is case insensitive, but in practice
// it's the whole email
$qb->select('*')
->from($this->getTableName())
->where($qb->expr()->eq('email', $qb->createNamedParameter($email)));
->where($qb->expr()->eq($qb->createFunction('LOWER(`email`)'), $qb->createFunction('LOWER(' . $qb->createNamedParameter($email) . ')')));

return $this->findEntities($qb->getSQL(), $qb->getParameters());
}
Expand Down
27 changes: 24 additions & 3 deletions tests/lib/User/AccountMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,32 @@ public function testFindByDisplayName() {
$this->assertEquals("TestFind2", array_shift($result)->getUserId());
}

public function findByEmailDataProvider() {
return [
['test3@find.tld'],
['Test3@find.tld'],
['test3@Find.tld'],
];
}

/**
* find by email
*
* @dataProvider findByEmailDataProvider
*/
public function testFindByEmail($email) {
$result = $this->mapper->find($email);
$this->assertEquals(1, count($result));
$this->assertEquals("TestFind3", array_shift($result)->getUserId());
}

/**
* get by email
*
* @dataProvider findByEmailDataProvider
*/
public function testFindByEmail() {
$result= $this->mapper->find('test3@find.tld');
public function testGetByEmail($email) {
$result = $this->mapper->getByEmail($email);
$this->assertEquals(1, count($result));
$this->assertEquals("TestFind3", array_shift($result)->getUserId());
}
Expand All @@ -148,4 +169,4 @@ public function testFindLimitAndOffset() {
$this->assertEquals("TestFind3", array_shift($result)->getUserId());
$this->assertEquals("TestFind4", array_shift($result)->getUserId());
}
}
}