testGetClientWithNonExistingClient()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the xAPI package.
5
 *
6
 * (c) Christian Flothmann <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Xabbuh\XApi\Bundle\ClientBundle\Tests\Manager;
13
14
use Xabbuh\XApi\Bundle\ClientBundle\Manager\ClientManager;
15
16
/**
17
 * @author Christian Flothmann <[email protected]>
18
 */
19
class ClientManagerTest extends \PHPUnit_Framework_TestCase
20
{
21
    public function testGetClient()
22
    {
23
        $client = $this->createClientMock();
24
        $manager = $this->createManager(array('foo' => $client));
25
26
        $this->assertSame($client, $manager->getClient('foo'));
27
    }
28
29
    /**
30
     * @expectedException \InvalidArgumentException
31
     */
32
    public function testGetClientWithoutRegisteredClients()
33
    {
34
        $client = $this->createClientMock();
35
        $manager = $this->createManager(array('foo' => $client));
36
        $manager->getClient('bar');
37
    }
38
39
    /**
40
     * @expectedException \InvalidArgumentException
41
     */
42
    public function testGetClientWithNonExistingClient()
43
    {
44
        $manager = $this->createManager(array());
45
        $manager->getClient('bar');
46
    }
47
48
    private function createManager(array $clients)
49
    {
50
        return new ClientManager($clients);
51
    }
52
53
    private function createClientMock()
54
    {
55
        return $this->getMockBuilder('\Xabbuh\XApi\Client\XApiClient')
56
            ->disableOriginalConstructor()
57
            ->getMock();
58
    }
59
}
60