2222
2323class HttpPluginClientBuilderTest extends TestCase
2424{
25- /** @dataProvider provideRequestFactories */
26- public function testRequestFactory (?object $ factory , ?string $ expectedException ): void
25+ public function testInvalidRequestFactory (): void
2726 {
28- if ($ expectedException !== null ) {
29- $ this ->expectException ($ expectedException );
30- }
27+ $ this ->expectException (\TypeError::class);
28+ $ definitelyNotARequestFactory = new \stdClass ;
29+ new HttpPluginClientBuilder (new MockClient , $ definitelyNotARequestFactory );
30+ }
3131
32+ /** @dataProvider provideRequestFactories */
33+ public function testRequestFactory (?object $ factory ): void
34+ {
3235 $ mockHttp = new MockClient ;
3336 $ mockHttp ->setDefaultException (new \Exception ('Mock HTTP client did not match request. ' ));
3437 $ mockHttp ->on ($ this ->matchRequestIncludingHeaders (), new Response (307 , ['Location ' => '/kittens.jpg ' ]));
@@ -52,7 +55,7 @@ public function testRequestFactory(?object $factory, ?string $expectedException)
5255 * The concrete implementation of the RequestMatcher interface does not allow matching on
5356 * headers, which we need to test to ensure both legacy and PSR17 implementations work.
5457 */
55- protected function matchRequestIncludingHeaders (): RequestMatcherInterface
58+ private function matchRequestIncludingHeaders (): RequestMatcherInterface
5659 {
5760 return new class implements RequestMatcherInterface {
5861 public function matches (RequestInterface $ request ): bool
@@ -65,16 +68,11 @@ public function matches(RequestInterface $request): bool
6568 };
6669 }
6770
68- /** @return iterable{object|null, class-string|null } */
71+ /** @return iterable{object|null} */
6972 public static function provideRequestFactories (): iterable
7073 {
71- // Fallback
72- yield [null , null ];
73- // Legacy
74- yield [new GuzzleMessageFactory , null ];
75- // PSR17
76- yield [new HttpFactory , null ];
77- // Invalid
78- yield [new \stdClass , \TypeError::class];
74+ yield [null ];
75+ yield [new GuzzleMessageFactory ];
76+ yield [new HttpFactory ];
7977 }
8078}
0 commit comments