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

HttpSlackClientTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 19
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A mockHttpClient() 0 8 1
A testPostToChannel() 0 7 1
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