File tree Expand file tree Collapse file tree 2 files changed +87
-0
lines changed
Expand file tree Collapse file tree 2 files changed +87
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace HttpSoft \Tests \Basis \TestAsset ;
6+
7+ use HttpSoft \Emitter \EmitterInterface ;
8+ use Psr \Http \Message \ResponseInterface ;
9+
10+ class DummyEmitter implements EmitterInterface
11+ {
12+ /**
13+ * @var string
14+ */
15+ private string $ body = '' ;
16+
17+ /**
18+ * {@inheritDoc}
19+ */
20+ public function emit (ResponseInterface $ response , bool $ withoutBody = false ): void
21+ {
22+ $ this ->body = (string ) $ response ->getBody ();
23+ }
24+
25+ /**
26+ * @return string
27+ */
28+ public function getBody (): string
29+ {
30+ return $ this ->body ;
31+ }
32+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace HttpSoft \Tests \Basis \TestAsset ;
6+
7+ use HttpSoft \Response \TextResponse ;
8+ use Psr \Http \Message \ResponseInterface ;
9+ use Psr \Http \Message \ServerRequestInterface ;
10+ use Psr \Http \Server \RequestHandlerInterface ;
11+ use StdClass ;
12+
13+ class DummyHandler implements RequestHandlerInterface
14+ {
15+ /**
16+ * @param ServerRequestInterface $request
17+ * @return ResponseInterface
18+ */
19+ public function handle (ServerRequestInterface $ request ): ResponseInterface
20+ {
21+ return self ::staticHandle ();
22+ }
23+
24+ /**
25+ * @return ResponseInterface
26+ */
27+ public static function staticHandle ()
28+ {
29+ return new TextResponse (self ::body ());
30+ }
31+
32+ /**
33+ * @return string
34+ */
35+ public static function body ()
36+ {
37+ return 'Dummy Handler ' ;
38+ }
39+
40+ /**
41+ * @return null
42+ */
43+ public static function invalidStaticHandle ()
44+ {
45+ return new StdClass ();
46+ }
47+
48+ /**
49+ * @return null
50+ */
51+ public function invalidHandle ()
52+ {
53+ return null ;
54+ }
55+ }
You can’t perform that action at this time.
0 commit comments