Classes List

Symfony\Component\HttpKernel\Tests\DependencyInjection\AddAnnotatedClassesToCachePassTest

 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 
 73 
 74 
 75 
 76 
 77 
 78 
 79 
 80 
 81 
 82 
 83 
 84 
 85 
 86 
 87 
 88 
 89 
 90 
 91 
 92 
 93 
 94 
 95 
 96 
 97 
 98 
 99 
 100 
<?php

/* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */


namespace Symfony\Component\HttpKernel\Tests\DependencyInjection;

use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpKernel\DependencyInjection\AddAnnotatedClassesToCachePass;

class AddAnnotatedClassesToCachePassTest extends TestCase
{
    public function testExpandClasses()
    {
        $r = new \ReflectionClass(AddAnnotatedClassesToCachePass::class);
        $pass = $r->newInstanceWithoutConstructor();
        $r = new \ReflectionMethod(AddAnnotatedClassesToCachePass::class'expandClasses');
        $r->setAccessible(true);
        $expand = $r->getClosure($pass);

        $this->assertSame('Foo'$expand(array('Foo'), array())[0]);
        $this->assertSame('Foo'$expand(array('\\Foo'), array())[0]);
        $this->assertSame('Foo'$expand(array('Foo'), array('\\Foo'))[0]);
        $this->assertSame('Foo'$expand(array('Foo'), array('Foo'))[0]);
        $this->assertSame('Foo'$expand(array('\\Foo'), array('\\Foo\\Bar'))[0]);
        $this->assertSame('Foo'$expand(array('Foo'), array('\\Foo\\Bar'))[0]);
        $this->assertSame('Foo'$expand(array('\\Foo'), array('\\Foo\\Bar\\Acme'))[0]);

        $this->assertSame('Foo\\Bar'$expand(array('Foo\\'), array('\\Foo\\Bar'))[0]);
        $this->assertSame('Foo\\Bar\\Acme'$expand(array('Foo\\'), array('\\Foo\\Bar\\Acme'))[0]);
        $this->assertEmpty($expand(array('Foo\\'), array('\\Foo')));

        $this->assertSame('Acme\\Foo\\Bar'$expand(array('**\\Foo\\'), array('\\Acme\\Foo\\Bar'))[0]);
        $this->assertEmpty($expand(array('**\\Foo\\'), array('\\Foo\\Bar')));
        $this->assertEmpty($expand(array('**\\Foo\\'), array('\\Acme\\Foo')));
        $this->assertEmpty($expand(array('**\\Foo\\'), array('\\Foo')));

        $this->assertSame('Acme\\Foo'$expand(array('**\\Foo'), array('\\Acme\\Foo'))[0]);
        $this->assertEmpty($expand(array('**\\Foo'), array('\\Acme\\Foo\\AcmeBundle')));
        $this->assertEmpty($expand(array('**\\Foo'), array('\\Acme\\FooBar\\AcmeBundle')));

        $this->assertSame('Foo\\Acme\\Bar'$expand(array('Foo\\*\\Bar'), array('\\Foo\\Acme\\Bar'))[0]);
        $this->assertEmpty($expand(array('Foo\\*\\Bar'), array('\\Foo\\Acme\\Bundle\\Bar')));

        $this->assertSame('Foo\\Acme\\Bar'$expand(array('Foo\\**\\Bar'), array('\\Foo\\Acme\\Bar'))[0]);
        $this->assertSame('Foo\\Acme\\Bundle\\Bar'$expand(array('Foo\\**\\Bar'), array('\\Foo\\Acme\\Bundle\\Bar'))[0]);

        $this->assertSame('Acme\\Bar'$expand(array('*\\Bar'), array('\\Acme\\Bar'))[0]);
        $this->assertEmpty($expand(array('*\\Bar'), array('\\Bar')));
        $this->assertEmpty($expand(array('*\\Bar'), array('\\Foo\\Acme\\Bar')));

        $this->assertSame('Foo\\Acme\\Bar'$expand(array('**\\Bar'), array('\\Foo\\Acme\\Bar'))[0]);
        $this->assertSame('Foo\\Acme\\Bundle\\Bar'$expand(array('**\\Bar'), array('\\Foo\\Acme\\Bundle\\Bar'))[0]);
        $this->assertEmpty($expand(array('**\\Bar'), array('\\Bar')));

        $this->assertSame('Foo\\Bar'$expand(array('Foo\\*'), array('\\Foo\\Bar'))[0]);
        $this->assertEmpty($expand(array('Foo\\*'), array('\\Foo\\Acme\\Bar')));

        $this->assertSame('Foo\\Bar'$expand(array('Foo\\**'), array('\\Foo\\Bar'))[0]);
        $this->assertSame('Foo\\Acme\\Bar'$expand(array('Foo\\**'), array('\\Foo\\Acme\\Bar'))[0]);

        $this->assertSame(array('Foo\\Bar'), $expand(array('Foo\\*'), array('Foo\\Bar''Foo\\BarTest')));
        $this->assertSame(array('Foo\\Bar''Foo\\BarTest'), $expand(array('Foo\\*''Foo\\*Test'), array('Foo\\Bar''Foo\\BarTest')));

        $this->assertSame(
            'Acme\\FooBundle\\Controller\\DefaultController',
            $expand(array('**Bundle\\Controller\\'), array('\\Acme\\FooBundle\\Controller\\DefaultController'))[0]
        );

        $this->assertSame(
            'FooBundle\\Controller\\DefaultController',
            $expand(array('**Bundle\\Controller\\'), array('\\FooBundle\\Controller\\DefaultController'))[0]
        );

        $this->assertSame(
            'Acme\\FooBundle\\Controller\\Bar\\DefaultController',
            $expand(array('**Bundle\\Controller\\'), array('\\Acme\\FooBundle\\Controller\\Bar\\DefaultController'))[0]
        );

        $this->assertSame(
            'Bundle\\Controller\\Bar\\DefaultController',
            $expand(array('**Bundle\\Controller\\'), array('\\Bundle\\Controller\\Bar\\DefaultController'))[0]
        );

        $this->assertSame(
            'Acme\\Bundle\\Controller\\Bar\\DefaultController',
            $expand(array('**Bundle\\Controller\\'), array('\\Acme\\Bundle\\Controller\\Bar\\DefaultController'))[0]
        );

        $this->assertSame('Foo\\Bar'$expand(array('Foo\\Bar'), array())[0]);
        $this->assertSame('Foo\\Acme\\Bar'$expand(array('Foo\\**'), array('\\Foo\\Acme\\Bar'))[0]);
    }
}