Skip to content

Commit 02d036f

Browse files
committed
Improve Notification Test
1 parent 69bcc38 commit 02d036f

File tree

3 files changed

+61
-36
lines changed

3 files changed

+61
-36
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
4+
namespace App\Test\Notification\Slack;
5+
6+
7+
use App\Notification\Client\Guzzle\HTTPResponse;
8+
use App\Notification\Client\HTTPResponseInterface;
9+
use Psr\Http\Message\ResponseInterface;
10+
11+
class FakeSlackNotificationResponse implements HTTPResponseInterface
12+
{
13+
private ResponseInterface $response;
14+
15+
public function __construct(ResponseInterface $response)
16+
{
17+
$this->response = $response;
18+
}
19+
20+
public function getResponse(): array
21+
{
22+
return (new HTTPResponse($this->response))->getResponse();
23+
}
24+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
namespace App\Test\Notification\Slack;
4+
5+
use App\Notification\Client\HTTPResponseInterface;
6+
use GuzzleHttp\Psr7\Response;
7+
use PHPUnit\Framework\Assert;
8+
use PHPUnit\Framework\TestCase;
9+
10+
require_once 'app/DotEnvLoader/index.php';
11+
12+
/**
13+
* @group notification
14+
*/
15+
class FakeSlackNotificationResponseTest extends TestCase
16+
{
17+
public static function test_FakeSlackNotificationResponse_ShouldAssertHTTPResponse(): void
18+
{
19+
$notificationResponse = new Response(
20+
$statusCode = 200,
21+
$responseHeader = [],
22+
$responseBody = null,
23+
$protocolVersion = '1.1',
24+
$responseReason = 'OK'
25+
);
26+
27+
$fakerResponse = new FakeSlackNotificationResponse($notificationResponse);
28+
29+
$expectedResponse = [
30+
'status_code' => 200,
31+
'message' => 'OK',
32+
];
33+
34+
Assert::assertInstanceOf(HTTPResponseInterface::class, $fakerResponse);
35+
Assert::assertEquals($expectedResponse, $fakerResponse->getResponse());
36+
}
37+
}

tests/Notification/Slack/SlackNotificationTest.php

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)