"Fossies" - the Fresh Open Source Software Archive

Member "contao-4.4.48/core-bundle/tests/DependencyInjection/Compiler/AddPackagesPassTest.php" (2 Apr 2020, 1890 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\AddPackagesPass;
   14 use Contao\CoreBundle\Tests\TestCase;
   15 use Symfony\Component\DependencyInjection\ContainerBuilder;
   16 
   17 /**
   18  * Tests the AddPackagesPass class.
   19  *
   20  * @author Andreas Schempp <http://github.com/aschempp>
   21  */
   22 class AddPackagesPassTest extends TestCase
   23 {
   24     /**
   25      * Tests adding the packages.
   26      */
   27     public function testAddsThePackages()
   28     {
   29         $pass = new AddPackagesPass($this->getRootDir().'/vendor/composer/installed.json');
   30         $container = new ContainerBuilder();
   31 
   32         $pass->process($container);
   33 
   34         $this->assertTrue($container->hasParameter('kernel.packages'));
   35 
   36         $packages = $container->getParameter('kernel.packages');
   37 
   38         $this->assertInternalType('array', $packages);
   39         $this->assertArrayHasKey('contao/test-bundle1', $packages);
   40         $this->assertArrayHasKey('contao/test-bundle2', $packages);
   41         $this->assertArrayNotHasKey('contao/test-bundle3', $packages);
   42 
   43         $this->assertSame('1.0.0', $packages['contao/test-bundle1']);
   44         $this->assertSame('dev-develop', $packages['contao/test-bundle2']);
   45     }
   46 
   47     /**
   48      * Tests adding packages without a JSON file.
   49      */
   50     public function testAddsAnEmptyArrayIfThereIsNoJsonFile()
   51     {
   52         $pass = new AddPackagesPass($this->getRootDir().'/vendor/composer/invalid.json');
   53         $container = new ContainerBuilder();
   54 
   55         $pass->process($container);
   56 
   57         $this->assertTrue($container->hasParameter('kernel.packages'));
   58 
   59         $packages = $container->getParameter('kernel.packages');
   60 
   61         $this->assertInternalType('array', $packages);
   62         $this->assertEmpty($container->getParameter('kernel.packages'));
   63     }
   64 }