Passed
Push — main ( e110ad...47f0cd )
by Dylan
02:09
created

ResourceTest::testConstruct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 18
rs 9.9
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Lifeboat\Tests\Resource;
4
5
use Lifeboat\Client;
6
use PHPUnit\Framework\TestCase;
7
8
class ResourceTest extends TestCase {
9
10
    private array $mock_resource_data = [
11
        'bool_test'     => '1',
12
        'int_test'      => '8',
13
        'float_test'    => '8.5',
14
        'date_test'     => '2021-10-05 00:13:25'
15
    ];
16
17
    /**
18
     * @test
19
     * @covers \Lifeboat\Resource\ApiResource::__construct
20
     * @covers \Lifeboat\Resource\ApiResource::setClient
21
     * @covers \Lifeboat\Resource\ApiResource::getClient
22
     */
23
    public function testConstruct()
24
    {
25
        $client = new Client('mock', 'mock');
26
        $mock   = new MockResource($client, $this->mock_resource_data);
27
28
        $this->assertEquals($client, $mock->getClient());
29
30
        // Test the casting
31
        $this->assertEquals(true, $mock->bool_test);
32
        $this->assertEquals(8, $mock->int_test);
33
        $this->assertEquals(8.5, $mock->float_test);
34
35
        $date = new \DateTime('2021-10-05 00:13:25 CET');
36
        $this->assertEquals($date->getTimestamp(), $mock->date_test->getTimestamp());
37
38
        $client_2 = new Client('mock2', 'mock2');
39
        $mock->setClient($client_2);
40
        $this->assertEquals($client_2, $mock->getClient());
41
    }
42
43
}
44