Passed
Push — master ( 3ec735...0b5e67 )
by Chema
01:36 queued 14s
created

HttpSlackClientTest::mockHttpClient()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 8
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chemaclass\StockTickerTests\Unit\Domain\Notifier\Channel\Slack;
6
7
use Chemaclass\StockTicker\Domain\Notifier\Channel\Slack\HttpSlackClient;
8
use PHPUnit\Framework\MockObject\Rule\InvokedCount;
9
use PHPUnit\Framework\TestCase;
10
use Symfony\Contracts\HttpClient\HttpClientInterface;
11
12
final class HttpSlackClientTest extends TestCase
13
{
14
    public function testPostToChannel(): void
15
    {
16
        $client = new HttpSlackClient(
17
            $this->mockHttpClient(self::once())
18
        );
19
20
        $client->postToChannel('channel_id', 'text');
21
    }
22
23
    private function mockHttpClient(InvokedCount $invokedCount): HttpClientInterface
24
    {
25
        $httpClient = $this->createMock(HttpClientInterface::class);
26
        $httpClient
27
            ->expects($invokedCount)
28
            ->method('request');
29
30
        return $httpClient;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $httpClient returns the type PHPUnit\Framework\MockObject\MockObject which is incompatible with the type-hinted return Symfony\Contracts\HttpClient\HttpClientInterface.
Loading history...
31
    }
32
}
33