diff --git a/Tests/Entity/ClientManagerTest.php b/Tests/Entity/ClientManagerTest.php index d575d320..cfcd9e68 100644 --- a/Tests/Entity/ClientManagerTest.php +++ b/Tests/Entity/ClientManagerTest.php @@ -57,13 +57,6 @@ public function setUp() ; $this->className = 'RandomClassName'.\random_bytes(5); - $this->entityManager - ->expects($this->once()) - ->method('getRepository') - ->with($this->className) - ->willReturn($this->repository) - ; - $this->instance = new ClientManager($this->entityManager, $this->className); parent::setUp(); @@ -72,7 +65,6 @@ public function setUp() public function testConstructWillSetParameters() { $this->assertAttributeSame($this->entityManager, 'em', $this->instance); - $this->assertAttributeSame($this->repository, 'repository', $this->instance); $this->assertAttributeSame($this->className, 'class', $this->instance); } @@ -88,6 +80,13 @@ public function testFindClientBy() ]; $randomResult = \random_bytes(5); + $this->entityManager + ->expects($this->once()) + ->method('getRepository') + ->with($this->className) + ->willReturn($this->repository) + ; + $this->repository ->expects($this->once()) ->method('findOneBy') diff --git a/Tests/Entity/TokenManagerTest.php b/Tests/Entity/TokenManagerTest.php index acdeca16..7bce37e0 100644 --- a/Tests/Entity/TokenManagerTest.php +++ b/Tests/Entity/TokenManagerTest.php @@ -63,20 +63,12 @@ public function setUp() ->getMock() ; - $this->entityManager - ->expects($this->once()) - ->method('getRepository') - ->with($this->className) - ->willReturn($this->repository) - ; - $this->instance = new TokenManager($this->entityManager, $this->className); } public function testConstructWillSetParameters() { $this->assertAttributeSame($this->entityManager, 'em', $this->instance); - $this->assertAttributeSame($this->repository, 'repository', $this->instance); $this->assertAttributeSame($this->className, 'class', $this->instance); } @@ -112,6 +104,13 @@ public function testFindTokenBy() \random_bytes(5), ]; + $this->entityManager + ->expects($this->once()) + ->method('getRepository') + ->with($this->className) + ->willReturn($this->repository) + ; + $this->repository ->expects($this->once()) ->method('findOneBy') @@ -174,6 +173,13 @@ public function testDeleteExpired() { $randomResult = \random_bytes(10); + $this->entityManager + ->expects($this->once()) + ->method('getRepository') + ->with($this->className) + ->willReturn($this->repository) + ; + $queryBuilder = $this->getMockBuilder(QueryBuilder::class) ->disableOriginalConstructor() ->getMock()