Skip to content

Commit

Permalink
Adapted unit tests for onthefly repo
Browse files Browse the repository at this point in the history
  • Loading branch information
abienvenu committed Jan 31, 2018
1 parent c678667 commit 4b2db2d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
15 changes: 7 additions & 8 deletions Tests/Entity/ClientManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
}

Expand All @@ -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')
Expand Down
22 changes: 14 additions & 8 deletions Tests/Entity/TokenManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 4b2db2d

Please sign in to comment.