NewsClientCommandTraitTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 4
dl 0
loc 32
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetAndInitNewsClient() 0 18 1
A testSetNewsClient() 0 8 1
1
<?php
2
3
namespace Stp\SndApi\News\Test\Command;
4
5
use Stp\SndApi\News\Client;
6
use Stp\SndApi\News\Command\NewsClientCommandTrait;
7
use Symfony\Component\Console\Input\InputInterface;
8
9
class NewsClientCommandTraitTest extends \PHPUnit_Framework_TestCase
10
{
11
    use NewsClientCommandTrait;
12
13
    public function testGetAndInitNewsClient()
14
    {
15
        $input = $this->getMockBuilder(InputInterface::class)
16
            ->disableOriginalConstructor()
17
            ->setMethods(['getOption'])
18
            ->getMockForAbstractClass();
19
20
        $input->expects($this->any())
21
            ->method('getOption')
22
            ->withConsecutive(['key'], ['secret'], ['publicationId'])
23
            ->willReturnOnConsecutiveCalls('key', 'secret', 'sa');
24
25
        $this->assertEmpty($this->newsClient);
26
27
        $this->getNewsClient($input);
28
29
        $this->assertInstanceOf(Client::class, $this->newsClient);
30
    }
31
32
    public function testSetNewsClient()
33
    {
34
        $newsClient = new Client('key', 'secret', 'sa');
35
36
        $this->setNewsClient($newsClient);
37
38
        $this->assertEquals($newsClient, $this->newsClient);
39
    }
40
}
41