DocBlockTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 0
Metric Value
dl 0
loc 51
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 6 1
A testMatches() 0 5 1
A testCreateWithNullReturnsNull() 0 4 1
A testCreateCallsFactory() 0 13 1
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-2018 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\Factory;
14
15
use Mockery as m;
16
use phpDocumentor\Reflection\DocBlock as DocblockDescriptor;
17
use phpDocumentor\Reflection\DocBlockFactoryInterface;
18
use phpDocumentor\Reflection\Php\StrategyContainer;
19
use PhpParser\Comment\Doc;
20
21
/**
22
 * Test case for \phpDocumentor\Reflection\Php\Factory\DocBlock
23
 * @coversDefaultClass \phpDocumentor\Reflection\Php\Factory\DocBlock
24
 */
25
class DocBlockTest extends TestCase
26
{
27
    /**
28
     * @var m\MockInterface
29
     */
30
    private $factoryMock;
31
32
    private $strategiesMock;
33
34
    protected function setUp()
35
    {
36
        $this->factoryMock = m::mock(DocBlockFactoryInterface::class);
37
        $this->strategiesMock = m::mock(StrategyContainer::class);
38
        $this->fixture = new DocBlock($this->factoryMock);
39
    }
40
41
    /**
42
     * @covers ::matches
43
     */
44
    public function testMatches()
45
    {
46
        $this->assertFalse($this->fixture->matches(new \stdClass()));
47
        $this->assertTrue($this->fixture->matches(m::mock(Doc::class)));
48
    }
49
50
    /**
51
     * @covers ::create
52
     */
53
    public function testCreateWithNullReturnsNull()
54
    {
55
        $this->assertNull($this->fixture->create(null, $this->strategiesMock));
56
    }
57
58
    /**
59
     * @covers ::__construct
60
     * @covers ::create
61
     */
62
    public function testCreateCallsFactory()
63
    {
64
        $expected = new DocblockDescriptor('');
65
        $this->factoryMock->shouldReceive('create')->once()->andReturn($expected);
66
67
        $docMock = m::mock(Doc::class);
68
        $docMock->shouldReceive('getText')->andReturn('');
69
        $docMock->shouldReceive('getLine')->andReturn(1);
70
71
        $result = $this->fixture->create($docMock, $this->strategiesMock);
72
73
        $this->assertSame($expected, $result);
74
    }
75
}
76