@@ -41,6 +41,8 @@ private function createParser(): Parser
4141 #[PHPUnit \Test]
4242 public function parseMustRaiseExceptionWhenTokenDoesNotHaveThreeParts (): void
4343 {
44+ $ this ->decoder ->expects ($ this ->never ())->method (self ::anything ());
45+
4446 $ parser = $ this ->createParser ();
4547
4648 $ this ->expectException (InvalidTokenStructure::class);
@@ -52,6 +54,8 @@ public function parseMustRaiseExceptionWhenTokenDoesNotHaveThreeParts(): void
5254 #[PHPUnit \Test]
5355 public function parseMustRaiseExceptionWhenTokenDoesNotHaveHeaders (): void
5456 {
57+ $ this ->decoder ->expects ($ this ->never ())->method (self ::anything ());
58+
5559 $ parser = $ this ->createParser ();
5660
5761 $ this ->expectException (InvalidTokenStructure::class);
@@ -63,6 +67,8 @@ public function parseMustRaiseExceptionWhenTokenDoesNotHaveHeaders(): void
6367 #[PHPUnit \Test]
6468 public function parseMustRaiseExceptionWhenTokenDoesNotHaveClaims (): void
6569 {
70+ $ this ->decoder ->expects ($ this ->never ())->method (self ::anything ());
71+
6672 $ parser = $ this ->createParser ();
6773
6874 $ this ->expectException (InvalidTokenStructure::class);
@@ -74,6 +80,8 @@ public function parseMustRaiseExceptionWhenTokenDoesNotHaveClaims(): void
7480 #[PHPUnit \Test]
7581 public function parseMustRaiseExceptionWhenTokenDoesNotHaveSignature (): void
7682 {
83+ $ this ->decoder ->expects ($ this ->never ())->method (self ::anything ());
84+
7785 $ parser = $ this ->createParser ();
7886
7987 $ this ->expectException (InvalidTokenStructure::class);
@@ -108,7 +116,8 @@ public function parseMustRaiseExceptionWhenHeaderCannotBeDecoded(): void
108116 #[PHPUnit \Test]
109117 public function parseMustRaiseExceptionWhenDealingWithNonArrayHeaders (): void
110118 {
111- $ this ->decoder ->method ('jsonDecode ' )
119+ $ this ->decoder ->expects ($ this ->once ())
120+ ->method ('jsonDecode ' )
112121 ->willReturn ('A very invalid header ' );
113122
114123 $ parser = $ this ->createParser ();
@@ -122,8 +131,9 @@ public function parseMustRaiseExceptionWhenDealingWithNonArrayHeaders(): void
122131 #[PHPUnit \Test]
123132 public function parseMustRaiseExceptionWhenDealingWithHeadersThatHaveEmptyStringKeys (): void
124133 {
125- $ this ->decoder ->method ('jsonDecode ' )
126- ->willReturn (['' => 'foo ' ]);
134+ $ this ->decoder ->expects ($ this ->once ())
135+ ->method ('jsonDecode ' )
136+ ->willReturn (['' => 'foo ' ]);
127137
128138 $ parser = $ this ->createParser ();
129139
@@ -136,8 +146,9 @@ public function parseMustRaiseExceptionWhenDealingWithHeadersThatHaveEmptyString
136146 #[PHPUnit \Test]
137147 public function parseMustRaiseExceptionWhenHeaderIsFromAnEncryptedToken (): void
138148 {
139- $ this ->decoder ->method ('jsonDecode ' )
140- ->willReturn (['enc ' => 'AAA ' ]);
149+ $ this ->decoder ->expects ($ this ->once ())
150+ ->method ('jsonDecode ' )
151+ ->willReturn (['enc ' => 'AAA ' ]);
141152
142153 $ parser = $ this ->createParser ();
143154
@@ -150,8 +161,9 @@ public function parseMustRaiseExceptionWhenHeaderIsFromAnEncryptedToken(): void
150161 #[PHPUnit \Test]
151162 public function parseMustRaiseExceptionWhenDealingWithNonArrayClaims (): void
152163 {
153- $ this ->decoder ->method ('jsonDecode ' )
154- ->willReturnOnConsecutiveCalls (['typ ' => 'JWT ' ], 'A very invalid claim set ' );
164+ $ this ->decoder ->expects ($ this ->exactly (2 ))
165+ ->method ('jsonDecode ' )
166+ ->willReturnOnConsecutiveCalls (['typ ' => 'JWT ' ], 'A very invalid claim set ' );
155167
156168 $ parser = $ this ->createParser ();
157169
@@ -164,8 +176,9 @@ public function parseMustRaiseExceptionWhenDealingWithNonArrayClaims(): void
164176 #[PHPUnit \Test]
165177 public function parseMustRaiseExceptionWhenDealingWithClaimsThatHaveEmptyStringKeys (): void
166178 {
167- $ this ->decoder ->method ('jsonDecode ' )
168- ->willReturnOnConsecutiveCalls (['typ ' => 'JWT ' ], ['' => 'foo ' ]);
179+ $ this ->decoder ->expects ($ this ->exactly (2 ))
180+ ->method ('jsonDecode ' )
181+ ->willReturnOnConsecutiveCalls (['typ ' => 'JWT ' ], ['' => 'foo ' ]);
169182
170183 $ parser = $ this ->createParser ();
171184
0 commit comments