Completed
Push — master ( b587fb...d05392 )
by David
20:34
created

ProfileClientFactoryTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Http\HttplugBundle\Tests\Unit\Collector;
4
5
use Http\Client\HttpClient;
6
use Http\HttplugBundle\ClientFactory\ClientFactory;
7
use Http\HttplugBundle\Collector\Collector;
8
use Http\HttplugBundle\Collector\Formatter;
9
use Http\HttplugBundle\Collector\ProfileClient;
10
use Http\HttplugBundle\Collector\ProfileClientFactory;
11
use PHPUnit\Framework\TestCase;
12
use Symfony\Component\Stopwatch\Stopwatch;
13
14
class ProfileClientFactoryTest extends TestCase
15
{
16
    /**
17
     * @var Collector
18
     */
19
    private $collector;
20
21
    /**
22
     * @var Formatter
23
     */
24
    private $formatter;
25
26
    /**
27
     * @var Stopwatch
28
     */
29
    private $stopwatch;
30
31
    /**
32
     * @var HttpClient
33
     */
34
    private $client;
35
36
    public function setUp()
37
    {
38
        $this->collector = $this->getMockBuilder(Collector::class)->disableOriginalConstructor()->getMock();
39
        $this->formatter = $this->getMockBuilder(Formatter::class)->disableOriginalConstructor()->getMock();
40
        $this->stopwatch = $this->getMockBuilder(Stopwatch::class)->getMock();
41
        $this->client = $this->getMockBuilder(HttpClient::class)->getMock();
42
    }
43
44
    public function testCreateClientFromClientFactory()
45
    {
46
        $factory = $this->getMockBuilder(ClientFactory::class)->getMock();
47
        $factory->method('createClient')->willReturn($this->client);
48
49
        $subject = new ProfileClientFactory($factory, $this->collector, $this->formatter, $this->stopwatch);
50
51
        $this->assertInstanceOf(ProfileClient::class, $subject->createClient());
52
    }
53
54
    public function testCreateClientFromCallable()
55
    {
56
        $factory = function ($config) {
0 ignored issues
show
Unused Code introduced by
The parameter $config is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
57
            return $this->client;
58
        };
59
60
        $subject = new ProfileClientFactory($factory, $this->collector, $this->formatter, $this->stopwatch);
61
62
        $this->assertInstanceOf(ProfileClient::class, $subject->createClient());
63
    }
64
}
65