Completed
Pull Request — master (#183)
by Danny
11:52
created

ScopePointerTest::notFunctionDataProvider()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 10
nc 1
nop 0
dl 0
loc 14
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Tests\PHPSA;
4
5
use PHPSA\ScopePointer;
6
7
class ScopePointerTest extends TestCase
8
{
9
    /**
10
     * @covers \PHPSA\ScopePointer::getObject
11
     */
12
    public function testGetObject()
13
    {
14
        $object = new \stdClass;
15
        $scopePointer = new ScopePointer($object);
16
17
        $this->assertSame($object, $scopePointer->getObject());
18
    }
19
20
    /**
21
     * @covers \PHPSA\ScopePointer::isClassMethod()
22
     */
23
    public function testIsClassMethod()
24
    {
25
        $class = $this->getMockBuilder('\PHPSA\Definition\ClassMethod')
26
            ->disableOriginalConstructor()
27
            ->getMock();
28
        $scopePointer = new ScopePointer($class);
29
30
        $this->assertTrue($scopePointer->isClassMethod());
31
    }
32
33
    /**
34
     * @covers \PHPSA\ScopePointer::isClassMethod()
35
     * @dataProvider notClassMethodDataProvider
36
     */
37
    public function testIsNotClassMethod($object)
38
    {
39
        $scopePointer = new ScopePointer($object);
40
41
        $this->assertFalse($scopePointer->isClassMethod());
42
    }
43
44
    /**
45
     * @covers \PHPSA\ScopePointer::isFunction()
46
     */
47
    public function testIsFunction()
48
    {
49
        $function = $this->getMockBuilder('\PHPSA\Definition\FunctionDefinition')
50
            ->disableOriginalConstructor()
51
            ->getMock();
52
        $scopePointer = new ScopePointer($function);
53
54
        $this->assertTrue($scopePointer->isFunction());
55
    }
56
57
    /**
58
     * @covers \PHPSA\ScopePointer::isFunction()
59
     * @dataProvider notFunctionDataProvider
60
     */
61
    public function testIsNotFunction($object)
62
    {
63
        $scopePointer = new ScopePointer($object);
64
65
        $this->assertFalse($scopePointer->isFunction());
66
    }
67
68
    public function notClassMethodDataProvider()
69
    {
70
        $function = $this->getMockBuilder('\PHPSA\Definition\FunctionDefinition')
71
            ->disableOriginalConstructor()
72
            ->getMock();
73
74
        return [
75
            'String' => ['Random characters'],
76
            'Integer' => [42],
77
            'Float' => [pi()],
78
            'StdClass' => [new \StdClass],
79
            'FunctionDefinition' => [$function]
80
        ];
81
    }
82
83
    public function notFunctionDataProvider()
84
    {
85
        $class = $this->getMockBuilder('\PHPSA\Definition\ClassMethod')
86
            ->disableOriginalConstructor()
87
            ->getMock();
88
        
89
        return [
90
            'String' => ['Random characters'],
91
            'Integer' => [42],
92
            'Float' => [pi()],
93
            'StdClass' => [new \StdClass],
94
            'ClassMethod' => [$class]
95
        ];
96
    }
97
}
98