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

Function_Test::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 phpDocumentor\Reflection\Types\Mixed_;
19
use phpDocumentor\Reflection\Types\String_;
20
use PHPUnit\Framework\TestCase;
21
22
/**
23
 * Tests the functionality for the Function_ class.
24
 * @coversDefaultClass phpDocumentor\Reflection\Php\Function_
25
 */
26
// @codingStandardsIgnoreStart
27
class Function_Test extends TestCase
28
// @codingStandardsIgnoreEnd
29
{
30
    /** @var Function_ $fixture */
31
    protected $fixture;
32
33
    /** @var Fqsen */
34
    protected $fqsen;
35
36
    /** @var  DocBlock */
37
    protected $docBlock;
38
39
    /**
40
     * Creates a new (emoty) fixture object.
41
     */
42
    protected function setUp()
43
    {
44
        $this->fqsen = new Fqsen('\space\MyFunction()');
45
        $this->docBlock = new DocBlock('aa');
46
        $this->fixture = new Function_($this->fqsen, $this->docBlock);
47
    }
48
49
    protected function tearDown()
50
    {
51
        m::close();
52
    }
53
54
    /**
55
     * @covers ::__construct
56
     * @covers ::getName
57
     */
58
    public function testGetName()
59
    {
60
        $this->assertEquals('MyFunction', $this->fixture->getName());
61
    }
62
63
    /**
64
     * @covers ::addArgument
65
     * @covers ::getArguments
66
     */
67
    public function testAddAndGetArguments()
68
    {
69
        $argument = new Argument('firstArgument');
70
        $this->fixture->addArgument($argument);
71
72
        $this->assertEquals(array($argument), $this->fixture->getArguments());
73
    }
74
75
    /**
76
     * @covers ::__construct
77
     * @covers ::getFqsen
78
     */
79
    public function testGetFqsen()
80
    {
81
        $this->assertSame($this->fqsen, $this->fixture->getFqsen());
82
    }
83
84
    /**
85
     * @covers ::__construct
86
     * @covers ::getDocBlock
87
     */
88
    public function testGetDocblock()
89
    {
90
        $this->assertSame($this->docBlock, $this->fixture->getDocBlock());
91
    }
92
93
    /**
94
     * @covers ::getReturnType
95
     * @covers ::__construct
96
     */
97
    public function testGetDefaultReturnType()
98
    {
99
        $method = new Function_($this->fqsen);
100
        $this->assertEquals(new Mixed_(), $method->getReturnType());
101
    }
102
103
    /**
104
     * @covers ::getReturnType
105
     * @covers ::__construct
106
     */
107
    public function testGetReturnTypeFromConstructor()
108
    {
109
        $returnType = new String_();
110
        $method = new Function_(
111
            $this->fqsen,
112
            null,
113
            null,
114
            $returnType
115
        );
116
117
        $this->assertSame($returnType, $method->getReturnType());
118
    }
119
}
120