Test Failed
Push — uuid_annotation ( d6506f )
by David
06:37
created

AnnotationParserTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 37
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testParse() 0 16 1
A testException() 0 8 1
A testParseComments() 0 8 1
1
<?php
2
3
namespace TheCodingMachine\TDBM\Utils\Annotation;
4
5
use TheCodingMachine\TDBM\TDBMException;
6
7
class AnnotationParserTest extends \PHPUnit_Framework_TestCase
8
{
9
    public function testParse()
10
    {
11
        $parser = new AnnotationParser();
12
        $annotations = $parser->parse('@UUID');
13
14
        $annotation = $annotations->findAnnotation('UUID');
15
        $this->assertSame('UUID', $annotation->getAnnotationType());
16
17
        $annotationsArray = $annotations->getAnnotations();
18
        $this->assertCount(1, $annotationsArray);
19
        $this->assertSame($annotation, $annotationsArray[0]);
20
21
22
        $annotation = $annotations->findAnnotation('not_exist');
23
        $this->assertNull($annotation);
24
    }
25
26
    public function testException()
27
    {
28
        $parser = new AnnotationParser();
29
        $annotations = $parser->parse("@UUID\n@UUID");
30
31
        $this->expectException(TDBMException::class);
32
        $annotations->findAnnotation('UUID');
33
    }
34
35
    public function testParseComments()
36
    {
37
        $parser = new AnnotationParser();
38
        $annotations = $parser->parse('@Name foobar');
39
40
        $annotation = $annotations->findAnnotation('Name');
41
        $this->assertSame('foobar', $annotation->getAnnotationComment());
42
    }
43
}
44