Added method to ApiKeyService to list api keys

This commit is contained in:
Alejandro Celaya
2016-08-06 18:08:09 +02:00
parent 74777c2234
commit dd1bc49b79
3 changed files with 46 additions and 0 deletions

View File

@@ -139,4 +139,30 @@ class ApiKeyServiceTest extends TestCase
$this->assertFalse($key->isEnabled());
$this->assertSame($key, $returnedKey);
}
/**
* @test
*/
public function listFindsAllApiKeys()
{
$repo = $this->prophesize(EntityRepository::class);
$repo->findBy([])->willReturn([])
->shouldBeCalledTimes(1);
$this->em->getRepository(ApiKey::class)->willReturn($repo->reveal());
$this->service->listKeys();
}
/**
* @test
*/
public function listEnabledFindsOnlyEnabledApiKeys()
{
$repo = $this->prophesize(EntityRepository::class);
$repo->findBy(['enabled' => true])->willReturn([])
->shouldBeCalledTimes(1);
$this->em->getRepository(ApiKey::class)->willReturn($repo->reveal());
$this->service->listKeys(true);
}
}