Completed
Branch master (cf27fb)
by Vladimir
02:33
created

PulseUnitTestCase::assertIsString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
namespace allejo\DaPulse\Tests;
4
5
use allejo\DaPulse\PulseBoard;
6
use allejo\DaPulse\Tests\Utilities\AuthenticatedClient;
7
use PHPUnit_Framework_TestCase;
8
use VCR\VCR;
9
10
abstract class PulseUnitTestCase extends PHPUnit_Framework_TestCase
11
{
12
    const MainUser = 303448;
0 ignored issues
show
Coding Style introduced by
This class constant is not uppercase (expected MAINUSER).
Loading history...
13
    const SecondUser = 361981;
0 ignored issues
show
Coding Style introduced by
This class constant is not uppercase (expected SECONDUSER).
Loading history...
14
    const BoardId = 3844236;
0 ignored issues
show
Coding Style introduced by
This class constant is not uppercase (expected BOARDID).
Loading history...
15
16
    public function setUp()
17
    {
18
        $authClient = new AuthenticatedClient("phpunit-auth.json");
19
20
        if (!$authClient->isAuthenticationSetup())
21
        {
22
            $this->markTestSkipped();
23
        }
24
25
        PulseBoard::setApiKey($authClient->getApiToken());
26
27
        $cassette = (getenv('TRAVIS') == 'true') ? 'PhpPulseVCR-sanitized' : 'PhpPulseVCR';
28
29
        VCR::turnOn();
30
        VCR::insertCassette($cassette);
31
    }
32
33
    public function tearDown ()
34
    {
35
        VCR::eject();
36
        VCR::turnOff();
37
    }
38
39
    protected function assertIsInt($expected, $message = "")
40
    {
41
        $this->assertTrue(is_int($expected), $message);
42
    }
43
44
    protected function assertIsString($expected, $message = "")
45
    {
46
        $this->assertTrue(is_string($expected), $message);
47
    }
48
49
    protected function assertIsArray($expected, $message = "")
50
    {
51
        $this->assertTrue(is_array($expected), $message);
52
    }
53
54
    protected function assertCountEqual($expected, $actual, $message = "")
55
    {
56
        $this->assertEquals($expected, count($actual), $message);
57
    }
58
59
    protected function assertCountLessThan($expected, $actual, $message = "")
60
    {
61
        $this->assertLessThan($expected, count($actual), $message);
62
    }
63
64
    protected function assertCountGreaterThan($expected, $actual, $message = "")
65
    {
66
        $this->assertGreaterThan($expected, count($actual), $message);
67
    }
68
69
    protected function assertPulseObjectType($instanceName, $actual, $message = "")
70
    {
71
        $instanceOf = "allejo\\DaPulse\\" . $instanceName;
72
73
        $this->assertInstanceOf($instanceOf, $actual, $message);
74
    }
75
76
    protected function assertPulseArrayContains($needle, $haystack, $message = "")
77
    {
78
        $resultFound = false;
79
80
        foreach ($haystack as $hay)
81
        {
82
            if ($needle->getId() === $hay->getId())
83
            {
84
                $resultFound = true;
85
                break;
86
            }
87
        }
88
89
        $this->assertTrue($resultFound, $message);
90
    }
91
}
92