Completed
Push — develop ( 28aa0b...3fae3c )
by Jaap
13s
created

PropertyTest::tearDown()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of phpDocumentor.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 *
8
 * @copyright 2010-2015 Mike van Riel<[email protected]>
9
 * @license   http://www.opensource.org/licenses/mit-license.php MIT
10
 * @link      http://phpdoc.org
11
 */
12
13
namespace phpDocumentor\Reflection\Php;
14
15
use \Mockery as m;
16
use phpDocumentor\Reflection\DocBlock;
17
use phpDocumentor\Reflection\Fqsen;
18
use PHPUnit\Framework\TestCase;
19
20
/**
21
 * Tests the functionality for the Property class.
22
 *
23
 * @coversDefaultClass phpDocumentor\Reflection\Php\Property
24
 */
25
class PropertyTest extends TestCase
26
{
27
    /**
28
     * @var Fqsen
29
     */
30
    private $fqsen;
31
32
    /**
33
     * @var Visibility
34
     */
35
    private $visibility;
36
37
    /**
38
     * @var DocBlock
39
     */
40
    private $docBlock;
41
42
    protected function setUp()
43
    {
44
        $this->fqsen = new Fqsen('\My\Class::$property');
45
        $this->visibility = new Visibility('private');
46
        $this->docBlock = new DocBlock('');
47
    }
48
49
    protected function tearDown()
50
    {
51
        m::close();
52
    }
53
54
    /**
55
     * @covers ::getFqsen
56
     * @covers ::getName
57
     * @covers ::__construct
58
     */
59
    public function testGetFqsenAndGetName()
60
    {
61
        $property = new Property($this->fqsen);
62
63
        $this->assertSame($this->fqsen, $property->getFqsen());
64
        $this->assertEquals($this->fqsen->getName(), $property->getName());
65
    }
66
67
    /**
68
     * @covers ::isStatic
69
     * @covers ::__construct
70
     */
71
    public function testGettingWhetherPropertyIsStatic()
72
    {
73
        $property = new Property($this->fqsen, $this->visibility, $this->docBlock, null, false);
74
        $this->assertFalse($property->isStatic());
75
76
        $property = new Property($this->fqsen, $this->visibility, $this->docBlock, null, true);
77
        $this->assertTrue($property->isStatic());
78
    }
79
80
    /**
81
     * @covers ::getVisibility
82
     * @covers ::__construct
83
     */
84
    public function testGettingVisibility()
85
    {
86
        $property = new Property($this->fqsen, $this->visibility, $this->docBlock, null, true);
87
88
        $this->assertSame($this->visibility, $property->getVisibility());
89
    }
90
91
    /**
92
     * @covers ::getTypes
93
     * @covers ::addType
94
     */
95
    public function testSetAndGetTypes()
96
    {
97
        $property = new Property($this->fqsen, $this->visibility, $this->docBlock, null, true);
98
        $this->assertEquals(array(), $property->getTypes());
99
100
        $property->addType('a');
101
        $this->assertEquals(array('a'), $property->getTypes());
102
    }
103
104
    /**
105
     * @covers ::getDefault
106
     * @covers ::__construct
107
     */
108
    public function testGetDefault()
109
    {
110
        $property = new Property($this->fqsen, $this->visibility, $this->docBlock, null, false);
111
        $this->assertNull($property->getDefault());
112
113
        $property = new Property($this->fqsen, $this->visibility, $this->docBlock, 'a', true);
114
        $this->assertEquals('a', $property->getDefault());
115
    }
116
117
    /**
118
     * @covers ::getDocBlock
119
     * @covers ::__construct
120
     */
121
    public function testGetDocBlock()
122
    {
123
        $property = new Property($this->fqsen, $this->visibility, $this->docBlock, null, false);
124
        $this->assertSame($this->docBlock, $property->getDocBlock());
125
    }
126
}
127