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

AnnotationParserTest::testException()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
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