File: DCOM55Test.php

package info (click to toggle)
php-doctrine-annotations 1.11.2-1%2Bdeb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,028 kB
  • sloc: php: 8,480; makefile: 19
file content (72 lines) | stat: -rw-r--r-- 1,956 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php

namespace Doctrine\Tests\Common\Annotations\Ticket;

use Doctrine\Common\Annotations\AnnotationException;
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Tests\Common\Annotations\Fixtures\Controller;
use PHPUnit\Framework\TestCase;
use ReflectionClass;

/**
 * @group
 */
class DCOM55Test extends TestCase
{
    public function testIssue(): void
    {
        $class  = new ReflectionClass(__NAMESPACE__ . '\\Dummy');
        $reader = new AnnotationReader();
        $this->expectException(AnnotationException::class);
        $this->expectExceptionMessage(
            '[Semantical Error] The class "Doctrine\Tests\Common\Annotations\Fixtures\Controller"' .
            ' is not annotated with @Annotation.
Are you sure this class can be used as annotation?
If so, then you need to add @Annotation to the _class_ doc comment of' .
            ' "Doctrine\Tests\Common\Annotations\Fixtures\Controller".
If it is indeed no annotation, then you need to add @IgnoreAnnotation("Controller")' .
            ' to the _class_ doc comment of class Doctrine\Tests\Common\Annotations\Ticket\Dummy.'
        );
        $reader->getClassAnnotations($class);
    }

    public function testAnnotation(): void
    {
        $class  = new ReflectionClass(__NAMESPACE__ . '\\DCOM55Consumer');
        $reader = new AnnotationReader();
        $annots = $reader->getClassAnnotations($class);

        self::assertCount(1, $annots);
        self::assertInstanceOf(__NAMESPACE__ . '\\DCOM55Annotation', $annots[0]);
    }

    public function testParseAnnotationDocblocks(): void
    {
        $class  = new ReflectionClass(__NAMESPACE__ . '\\DCOM55Annotation');
        $reader = new AnnotationReader();
        $annots = $reader->getClassAnnotations($class);

        self::assertEmpty($annots);
    }
}

/**
 * @Controller
 */
class Dummy
{
}

/**
 * @Annotation
 */
class DCOM55Annotation
{
}

/**
 * @DCOM55Annotation
 */
class DCOM55Consumer
{
}