Subversion Repositories php-qbpwcf

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 liveuser 1
<?php
2
 
3
/*
4
 * This file is part of the Symfony package.
5
 *
6
 * (c) Fabien Potencier <fabien@symfony.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
 
12
namespace Symfony\Component\Routing\Tests\Loader;
13
 
14
use Symfony\Component\Routing\Loader\AnnotationFileLoader;
15
use Symfony\Component\Config\FileLocator;
16
use Symfony\Component\Routing\Annotation\Route;
17
 
18
class AnnotationFileLoaderTest extends AbstractAnnotationLoaderTest
19
{
20
    protected $loader;
21
    protected $reader;
22
 
23
    protected function setUp()
24
    {
25
        parent::setUp();
26
 
27
        $this->reader = $this->getReader();
28
        $this->loader = new AnnotationFileLoader(new FileLocator(), $this->getClassLoader($this->reader));
29
    }
30
 
31
    public function testLoad()
32
    {
33
        $this->reader->expects($this->once())->method('getClassAnnotation');
34
 
35
        $this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses/FooClass.php');
36
    }
37
 
38
    /**
39
     * @requires PHP 5.4
40
     */
41
    public function testLoadTraitWithClassConstant()
42
    {
43
        $this->reader->expects($this->never())->method('getClassAnnotation');
44
 
45
        $this->loader->load(__DIR__.'/../Fixtures/AnnotatedClasses/FooTrait.php');
46
    }
47
 
48
    /**
49
     * @requires PHP 5.6
50
     */
51
    public function testLoadVariadic()
52
    {
53
        $route = new Route(array('path' => '/path/to/{id}'));
54
        $this->reader->expects($this->once())->method('getClassAnnotation');
55
        $this->reader->expects($this->once())->method('getMethodAnnotations')
56
            ->will($this->returnValue(array($route)));
57
 
58
        $this->loader->load(__DIR__.'/../Fixtures/OtherAnnotatedClasses/VariadicClass.php');
59
    }
60
 
61
    public function testSupports()
62
    {
63
        $fixture = __DIR__.'/../Fixtures/annotated.php';
64
 
65
        $this->assertTrue($this->loader->supports($fixture), '->supports() returns true if the resource is loadable');
66
        $this->assertFalse($this->loader->supports('foo.foo'), '->supports() returns true if the resource is loadable');
67
 
68
        $this->assertTrue($this->loader->supports($fixture, 'annotation'), '->supports() checks the resource type if specified');
69
        $this->assertFalse($this->loader->supports($fixture, 'foo'), '->supports() checks the resource type if specified');
70
    }
71
}