"Fossies" - the Fresh Open Source Software Archive

Member "contao-4.4.48/core-bundle/tests/DependencyInjection/Compiler/AddResourcesPathsPassTest.php" (2 Apr 2020, 1746 Bytes) of package /linux/www/contao-4.4.48.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 <?php
    2 
    3 /*
    4  * This file is part of Contao.
    5  *
    6  * (c) Leo Feyer
    7  *
    8  * @license LGPL-3.0-or-later
    9  */
   10 
   11 namespace Contao\CoreBundle\Tests\DependencyInjection\Compiler;
   12 
   13 use Contao\CoreBundle\DependencyInjection\Compiler\AddResourcesPathsPass;
   14 use Contao\CoreBundle\HttpKernel\Bundle\ContaoModuleBundle;
   15 use Contao\CoreBundle\Tests\TestCase;
   16 use Contao\TestBundle\ContaoTestBundle;
   17 use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
   18 use Symfony\Component\DependencyInjection\ContainerBuilder;
   19 
   20 /**
   21  * Tests the AddResourcesPathsPass class.
   22  *
   23  * @author Leo Feyer <http://github.com/leofeyer>
   24  */
   25 class AddResourcesPathsPassTest extends TestCase
   26 {
   27     /**
   28      * Tests adding the resources paths.
   29      */
   30     public function testAddsTheResourcesPaths()
   31     {
   32         $pass = new AddResourcesPathsPass();
   33 
   34         $container = new ContainerBuilder();
   35         $container->setParameter('kernel.project_dir', $this->getRootDir());
   36 
   37         $container->setParameter('kernel.bundles', [
   38             'FrameworkBundle' => FrameworkBundle::class,
   39             'ContaoTestBundle' => ContaoTestBundle::class,
   40             'foobar' => ContaoModuleBundle::class,
   41         ]);
   42 
   43         $pass->process($container);
   44 
   45         $this->assertTrue($container->hasParameter('contao.resources_paths'));
   46 
   47         $path = $this->getRootDir().'/vendor/contao/test-bundle';
   48 
   49         if ('\\' === \DIRECTORY_SEPARATOR) {
   50             $path = strtr($path, '/', '\\');
   51         }
   52 
   53         $this->assertSame(
   54             [
   55                 $path.'/Resources/contao',
   56                 $this->getRootDir().'/system/modules/foobar',
   57                 $this->getRootDir().'/app/Resources/contao',
   58             ],
   59             $container->getParameter('contao.resources_paths')
   60         );
   61     }
   62 }