CompanyTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 7
Bugs 0 Features 0
Metric Value
wmc 3
c 7
b 0
f 0
lcom 1
cbo 4
dl 0
loc 37
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testRequiredParametersIncludedWhenConvertingToArray() 0 4 1
A testTitleGetsSet() 0 7 1
A testUpdateNameMakesPutRequest() 0 19 1
1
<?php
2
3
namespace Manavo\DoneDone\Test;
4
5
use Manavo\DoneDone\Client;
6
use Manavo\DoneDone\Company;
7
use PHPUnit_Framework_TestCase;
8
9
class CompanyTest extends PHPUnit_Framework_TestCase
10
{
11
12
    public function testRequiredParametersIncludedWhenConvertingToArray()
13
    {
14
        $this->assertArrayHasKey('company_name', (new Company())->toArray());
15
    }
16
17
    public function testTitleGetsSet()
18
    {
19
        $company = new Company();
20
        $company->setName('my name');
21
22
        $this->assertEquals('my name', $company->toArray()['company_name']);
23
    }
24
25
    public function testUpdateNameMakesPutRequest()
26
    {
27
        $responseMock = $this->getMockBuilder('\GuzzleHttp\Message\Response')
28
            ->disableOriginalConstructor()->getMock();
29
        $responseMock->expects($this->once())->method('json')
30
            ->willReturn($this->returnValue(true));
31
32
        $guzzleClientMock = $this->getMockBuilder('\GuzzleHttp\Client')
33
            ->disableOriginalConstructor()->getMock();
34
        $guzzleClientMock->expects($this->once())->method('put')
35
            ->willReturn($responseMock);
36
37
        $client = new Client('team', 'username', 'password');
38
        $client->setClient($guzzleClientMock);
39
40
        $company = $client->company(3);
41
42
        $company->updateName('name');
43
    }
44
45
}
46