@@ -29,9 +29,9 @@ class CampIsPublicVoterTest extends TestCase {
2929
3030 public function setUp (): void {
3131 parent ::setUp ();
32- $ this ->token = $ this ->createMock (TokenInterface::class);
33- $ this ->em = $ this ->createMock (EntityManagerInterface::class);
34- $ this ->responseTagger = $ this ->createMock (ResponseTagger::class);
32+ $ this ->token = $ this ->createStub (TokenInterface::class);
33+ $ this ->em = $ this ->createStub (EntityManagerInterface::class);
34+ $ this ->responseTagger = $ this ->createStub (ResponseTagger::class);
3535 $ this ->voter = new CampIsPublicVoter ($ this ->em , $ this ->responseTagger );
3636 }
3737
@@ -68,7 +68,7 @@ public function testDoesntVoteWhenSubjectIsNull() {
6868 public function testDeniesAccessWhenGetCampYieldsNull () {
6969 // given
7070 $ this ->token ->method ('getUser ' )->willReturn (new User ());
71- $ subject = $ this ->createMock (Period::class);
71+ $ subject = $ this ->createStub (Period::class);
7272 $ subject ->method ('getCamp ' )->willReturn (null );
7373
7474 // when
@@ -80,12 +80,12 @@ public function testDeniesAccessWhenGetCampYieldsNull() {
8080
8181 public function testDeniesAccessWhenCampIsntPublic () {
8282 // given
83- $ user = $ this ->createMock (User::class);
83+ $ user = $ this ->createStub (User::class);
8484 $ user ->method ('getId ' )->willReturn ('idFromTest ' );
8585 $ this ->token ->method ('getUser ' )->willReturn ($ user );
8686 $ camp = new Camp ();
8787 $ camp ->isPublic = false ;
88- $ subject = $ this ->createMock (Period::class);
88+ $ subject = $ this ->createStub (Period::class);
8989 $ subject ->method ('getCamp ' )->willReturn ($ camp );
9090
9191 // when
@@ -97,15 +97,17 @@ public function testDeniesAccessWhenCampIsntPublic() {
9797
9898 public function testGrantsAccessViaBelongsToCampInterface () {
9999 // given
100- $ user = $ this ->createMock (User::class);
100+ $ user = $ this ->createStub (User::class);
101101 $ user ->method ('getId ' )->willReturn ('idFromTest ' );
102102 $ this ->token ->method ('getUser ' )->willReturn ($ user );
103103 $ camp = new Camp ();
104104 $ camp ->isPublic = true ;
105- $ subject = $ this ->createMock (Period::class);
105+ $ subject = $ this ->createStub (Period::class);
106106 $ subject ->method ('getCamp ' )->willReturn ($ camp );
107107
108+ $ this ->responseTagger = $ this ->createMock (ResponseTagger::class);
108109 $ this ->responseTagger ->expects ($ this ->once ())->method ('addTags ' )->with ([$ camp ->getId ()]);
110+ $ this ->voter = new CampIsPublicVoter ($ this ->em , $ this ->responseTagger );
109111
110112 // when
111113 $ result = $ this ->voter ->vote ($ this ->token , $ subject , ['CAMP_IS_PUBLIC ' ]);
@@ -116,17 +118,17 @@ public function testGrantsAccessViaBelongsToCampInterface() {
116118
117119 public function testGrantsAccessViaBelongsToContentNodeTreeInterface () {
118120 // given
119- $ user = $ this ->createMock (User::class);
121+ $ user = $ this ->createStub (User::class);
120122 $ user ->method ('getId ' )->willReturn ('idFromTest ' );
121123 $ this ->token ->method ('getUser ' )->willReturn ($ user );
122124 $ camp = new Camp ();
123125 $ camp ->isPublic = true ;
124- $ activity = $ this ->createMock (Activity::class);
126+ $ activity = $ this ->createStub (Activity::class);
125127 $ activity ->method ('getCamp ' )->willReturn ($ camp );
126- $ root = $ this ->createMock (ColumnLayout::class);
127- $ subject = $ this ->createMock (ContentNodeTreeDummy3::class);
128+ $ root = $ this ->createStub (ColumnLayout::class);
129+ $ subject = $ this ->createStub (ContentNodeTreeDummy3::class);
128130 $ subject ->method ('getRoot ' )->willReturn ($ root );
129- $ repository = $ this ->createMock (EntityRepository::class);
131+ $ repository = $ this ->createStub (EntityRepository::class);
130132 $ this ->em ->method ('getRepository ' )->willReturn ($ repository );
131133 $ repository ->method ('findOneBy ' )->willReturn ($ activity );
132134
0 commit comments