Skip to content

Commit 680c62a

Browse files
committed
Improve Notification Test
1 parent 69bcc38 commit 680c62a

File tree

3 files changed

+58
-36
lines changed

3 files changed

+58
-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: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
class FakeSlackNotificationResponseTest extends TestCase
13+
{
14+
public static function test_FakeSlackNotificationResponse_ShouldAssertHTTPResponse(): void
15+
{
16+
$notificationResponse = new Response(
17+
$statusCode = 200,
18+
$responseHeader = [],
19+
$responseBody = null,
20+
$protocolVersion = '1.1',
21+
$responseReason = 'OK'
22+
);
23+
24+
$fakerResponse = new FakeSlackNotificationResponse($notificationResponse);
25+
26+
$expectedResponse = [
27+
'status_code' => 200,
28+
'message' => 'OK',
29+
];
30+
31+
Assert::assertInstanceOf(HTTPResponseInterface::class, $fakerResponse);
32+
Assert::assertEquals($expectedResponse, $fakerResponse->getResponse());
33+
}
34+
}

tests/Notification/Slack/SlackNotificationTest.php

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

0 commit comments

Comments
 (0)