ConnectionWrapperTest::getSUT()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 9
rs 9.6667
cc 1
eloc 6
nc 1
nop 1
1
<?php
2
/*
3
 * This file is part of the NatsBundle package.
4
 *
5
 * (c) Issel Guberna <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Octante\NatsBundle\Tests\Unit\Connection;
12
13
use Octante\NatsBundle\Connection\ConnectionWrapper;
14
15
class ConnectionWrapperTest extends \PHPUnit_Framework_TestCase
16
{
17
    /**
18
     * when: callPingsCount
19
     * should: callNatsConnectionCallPingsCount
20
     *
21
     * @dataProvider methodsDataProvider
22
     */
23
    public function test_callPingsCount_callNatsConnectionCallPingsCount($method, $parameters)
24
    {
25
        $sut = $this->getSUT($method);
26
        call_user_func_array(array($sut, $method), $parameters);
27
    }
28
29
    public function methodsDataProvider()
30
    {
31
        return array(
32
            array('pingsCount', array()),
33
            array('pubsCount', array()),
34
            array('reconnectsCount', array()),
35
            array('subscriptionsCount', array()),
36
            array('getSubscriptions', array()),
37
            array('isConnected', array()),
38
            array('connect', array(2)),
39
            array('ping', array()),
40
            array('request', array('subject', 'payload', 'callback', 1)),
41
            array('publish', array('subject', 'payload')),
42
            array('subscribe', array('subject', function(){})),
43
            array('unsubscribe', array('sid')),
44
            array('wait', array(1)),
45
            array('setStreamTimeout', array(10)),
46
            array('reconnect', array()),
47
            array('close', array())
48
        );
49
    }
50
51
    /**
52
     * @param $method
53
     * @return ConnectionWrapper
54
     */
55
    private function getSUT($method)
56
    {
57
        $connectionMock = $this->getMock('Nats\Connection');
58
        $loggerMock = $this->getMock('Octante\NatsBundle\Logger\NatsLogger');
59
        $connectionMock->expects($this->once())
60
            ->method($method);
61
62
        return new ConnectionWrapper($connectionMock, $loggerMock);
63
    }
64
}
65