Completed
Pull Request — master (#468)
by Christophe
01:40
created

MagicCallPatchTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 4
dl 0
loc 24
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A it_supports_classes_with_invalid_tags() 0 18 3
1
<?php
2
3
namespace Tests\Prophecy\Doubler\ClassPatch;
4
5
use PHPUnit\Framework\TestCase;
6
use Prophecy\Doubler\ClassPatch\MagicCallPatch;
7
use Prophecy\Doubler\Generator\ClassMirror;
8
9
class MagicCallPatchTest extends TestCase
10
{
11
    /**
12
     * @test
13
     */
14
    public function it_supports_classes_with_invalid_tags()
15
    {
16
        $class = new \ReflectionClass('Fixtures\Prophecy\WithPhpdocClass');
17
18
        $mirror = new ClassMirror();
19
        $classNode = $mirror->reflect($class, array());
20
21
        $patch = new MagicCallPatch();
22
23
        $patch->apply($classNode);
24
25
        // Newer phpDocumentor versions allow reading valid method tags, even when some other tags are invalid
26
        if (class_exists('phpDocumentor\Reflection\DocBlockFactory') && class_exists('phpDocumentor\Reflection\Types\ContextFactory')) {
27
            $this->assertTrue($classNode->hasMethod('name'));
28
        }
29
30
        $this->assertFalse($classNode->hasMethod('randomElement'));
31
    }
32
}
33