1111use Doctrine \ORM \EntityManagerInterface ;
1212use Symfony \Bundle \FrameworkBundle \Test \KernelTestCase ;
1313
14+ /**
15+ * @internal
16+ */
1417class ClaimInvitationServiceTest extends KernelTestCase {
15-
1618 private CampCollaborationRepository $ campCollaborationRepository ;
1719 private EntityManagerInterface $ em ;
1820 private ClaimInvitationService $ claimInvitationService ;
1921
2022 private User $ user ;
2123 private string $ email = 'test@example.com ' ;
2224
23-
2425 protected function setUp (): void {
2526 static ::bootKernel ();
2627
@@ -38,7 +39,8 @@ public function testDoesNothingWhenNoInvitationPresent() {
3839 ->expects ($ this ->once ())
3940 ->method ('findAllByInviteEmailAndInvited ' )
4041 ->with ($ this ->email )
41- ->willReturn ([]);
42+ ->willReturn ([])
43+ ;
4244
4345 // then
4446 $ this ->em ->expects ($ this ->never ())->method ('persist ' );
@@ -61,7 +63,8 @@ public function testClaimsInvitation() {
6163 ->expects ($ this ->once ())
6264 ->method ('findAllByInviteEmailAndInvited ' )
6365 ->with ($ this ->email )
64- ->willReturn ([ $ invitation ]);
66+ ->willReturn ([$ invitation ])
67+ ;
6568
6669 // then
6770 $ this ->em ->expects ($ this ->once ())->method ('persist ' )->with ($ invitation );
@@ -97,13 +100,15 @@ public function testIgnoresInvitationWhenUserAlreadyPartOfCamp() {
97100 ->expects ($ this ->once ())
98101 ->method ('findAllByInviteEmailAndInvited ' )
99102 ->with ($ this ->email )
100- ->willReturn ([ $ invitation ]);
103+ ->willReturn ([$ invitation ])
104+ ;
101105
102106 $ this ->campCollaborationRepository
103107 ->expects ($ this ->once ())
104108 ->method ('findOneBy ' )
105109 ->with (['user ' => $ this ->user , 'camp ' => $ camp ])
106- ->willReturn ($ existingCollaboration );
110+ ->willReturn ($ existingCollaboration )
111+ ;
107112
108113 // then
109114 $ this ->em ->expects ($ this ->never ())->method ('persist ' );
@@ -139,13 +144,15 @@ public function testIgnoresInvitationWhenUserWasPreviouslyPartOfCamp() {
139144 ->expects ($ this ->once ())
140145 ->method ('findAllByInviteEmailAndInvited ' )
141146 ->with ($ this ->email )
142- ->willReturn ([ $ invitation ]);
147+ ->willReturn ([$ invitation ])
148+ ;
143149
144150 $ this ->campCollaborationRepository
145151 ->expects ($ this ->once ())
146152 ->method ('findOneBy ' )
147153 ->with (['user ' => $ this ->user , 'camp ' => $ camp ])
148- ->willReturn ($ existingCollaboration );
154+ ->willReturn ($ existingCollaboration )
155+ ;
149156
150157 // then
151158 $ this ->em ->expects ($ this ->never ())->method ('persist ' );
@@ -181,24 +188,30 @@ public function testHandlesUniqueConstraintViolationWhenUserAlreadyPartOfCamp()
181188 ->expects ($ this ->once ())
182189 ->method ('findAllByInviteEmailAndInvited ' )
183190 ->with ($ this ->email )
184- ->willReturn ([ $ invitation , $ invitation2 ]);
191+ ->willReturn ([$ invitation , $ invitation2 ])
192+ ;
185193
186194 // then
187195 $ matcher1 = $ this ->exactly (2 );
188196 $ this ->em ->expects ($ matcher1 )
189197 ->method ('persist ' )
190198 ->willReturnCallback (function (CampCollaboration $ value ) use ($ matcher1 , $ invitation , $ invitation2 ) {
191- if ($ matcher1 ->numberOfInvocations () === 1 ) $ this ->assertEquals ($ invitation , $ value );
192- else $ this ->assertEquals ($ invitation2 , $ value );
193- });
199+ if (1 === $ matcher1 ->numberOfInvocations ()) {
200+ $ this ->assertEquals ($ invitation , $ value );
201+ } else {
202+ $ this ->assertEquals ($ invitation2 , $ value );
203+ }
204+ })
205+ ;
194206 $ matcher2 = $ this ->exactly (2 );
195207 $ this ->em ->expects ($ matcher2 )
196208 ->method ('flush ' )
197209 ->willReturnCallback (function () use ($ matcher2 ) {
198- if ($ matcher2 ->numberOfInvocations () === 1 ) {
210+ if (1 === $ matcher2 ->numberOfInvocations ()) {
199211 throw $ this ->createMock (UniqueConstraintViolationException::class);
200212 }
201- });
213+ })
214+ ;
202215 $ this ->em ->expects ($ this ->once ())->method ('clear ' );
203216
204217 // when
0 commit comments