Skip to content

Commit 3e431a2

Browse files
committed
Add dummy classes to TestAsset
1 parent 9574d06 commit 3e431a2

File tree

2 files changed

+87
-0
lines changed

2 files changed

+87
-0
lines changed

tests/TestAsset/DummyEmitter.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
}

tests/TestAsset/DummyHandler.php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
}

0 commit comments

Comments
 (0)