Skip to content

Commit 4b2db2d

Browse files
committed
Adapted unit tests for onthefly repo
1 parent c678667 commit 4b2db2d

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

Tests/Entity/ClientManagerTest.php

+7-8
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,6 @@ public function setUp()
5757
;
5858
$this->className = 'RandomClassName'.\random_bytes(5);
5959

60-
$this->entityManager
61-
->expects($this->once())
62-
->method('getRepository')
63-
->with($this->className)
64-
->willReturn($this->repository)
65-
;
66-
6760
$this->instance = new ClientManager($this->entityManager, $this->className);
6861

6962
parent::setUp();
@@ -72,7 +65,6 @@ public function setUp()
7265
public function testConstructWillSetParameters()
7366
{
7467
$this->assertAttributeSame($this->entityManager, 'em', $this->instance);
75-
$this->assertAttributeSame($this->repository, 'repository', $this->instance);
7668
$this->assertAttributeSame($this->className, 'class', $this->instance);
7769
}
7870

@@ -88,6 +80,13 @@ public function testFindClientBy()
8880
];
8981
$randomResult = \random_bytes(5);
9082

83+
$this->entityManager
84+
->expects($this->once())
85+
->method('getRepository')
86+
->with($this->className)
87+
->willReturn($this->repository)
88+
;
89+
9190
$this->repository
9291
->expects($this->once())
9392
->method('findOneBy')

Tests/Entity/TokenManagerTest.php

+14-8
Original file line numberDiff line numberDiff line change
@@ -63,20 +63,12 @@ public function setUp()
6363
->getMock()
6464
;
6565

66-
$this->entityManager
67-
->expects($this->once())
68-
->method('getRepository')
69-
->with($this->className)
70-
->willReturn($this->repository)
71-
;
72-
7366
$this->instance = new TokenManager($this->entityManager, $this->className);
7467
}
7568

7669
public function testConstructWillSetParameters()
7770
{
7871
$this->assertAttributeSame($this->entityManager, 'em', $this->instance);
79-
$this->assertAttributeSame($this->repository, 'repository', $this->instance);
8072
$this->assertAttributeSame($this->className, 'class', $this->instance);
8173
}
8274

@@ -112,6 +104,13 @@ public function testFindTokenBy()
112104
\random_bytes(5),
113105
];
114106

107+
$this->entityManager
108+
->expects($this->once())
109+
->method('getRepository')
110+
->with($this->className)
111+
->willReturn($this->repository)
112+
;
113+
115114
$this->repository
116115
->expects($this->once())
117116
->method('findOneBy')
@@ -174,6 +173,13 @@ public function testDeleteExpired()
174173
{
175174
$randomResult = \random_bytes(10);
176175

176+
$this->entityManager
177+
->expects($this->once())
178+
->method('getRepository')
179+
->with($this->className)
180+
->willReturn($this->repository)
181+
;
182+
177183
$queryBuilder = $this->getMockBuilder(QueryBuilder::class)
178184
->disableOriginalConstructor()
179185
->getMock()

0 commit comments

Comments
 (0)