Completed
Push — master ( 861a0b...569933 )
by Philip
03:02
created

CompanyTest::testUpdateNameMakesPutRequest()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 19
rs 9.4285
cc 1
eloc 13
nc 1
nop 0
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