| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace Evheniy\MaterializeBundle\Tests\DependencyInjection; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Symfony\Component\DependencyInjection\ContainerBuilder; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use Symfony\Component\Config\FileLocator; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Evheniy\MaterializeBundle\DependencyInjection\MaterializeExtension; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * Class MaterializeExtensionTest | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * @package Evheniy\MaterializeBundle\Tests\DependencyInjection | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 14 |  |  |  */ | 
            
                                                                        
                            
            
                                    
            
            
                | 15 |  |  | class MaterializeExtensionTest extends \PHPUnit_Framework_TestCase | 
            
                                                                        
                            
            
                                    
            
            
                | 16 |  |  | { | 
            
                                                                        
                            
            
                                    
            
            
                | 17 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 18 |  |  |      * @var MaterializeExtension | 
            
                                                                        
                            
            
                                    
            
            
                | 19 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 20 |  |  |     private $extension; | 
            
                                                                        
                            
            
                                    
            
            
                | 21 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 22 |  |  |      * @var ContainerBuilder | 
            
                                                                        
                            
            
                                    
            
            
                | 23 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 24 |  |  |     private $container; | 
            
                                                                        
                            
            
                                    
            
            
                | 25 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 26 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 27 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     protected function setUp() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |         $this->extension = new MaterializeExtension(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |         $this->container = new ContainerBuilder(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |         $this->container->registerExtension($this->extension); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 35 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  |      * @param ContainerBuilder $container | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  |      * @param string           $resource | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 41 |  |  |      * @return ContainerBuilder | 
            
                                                                        
                            
            
                                    
            
            
                | 42 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |     protected function loadConfiguration(ContainerBuilder $container, $resource) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |         $loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/Fixtures/')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |         $loader->load($resource . '.yml'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |         return $container; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 49 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 51 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 52 |  |  |      * Test empty config | 
            
                                                                        
                            
            
                                    
            
            
                | 53 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |     public function testWithoutConfiguration() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |         $this->container->loadFromExtension($this->extension->getAlias())->compile(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |         $materialize = $this->container->getParameter('materialize'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |         $this->assertEquals($materialize['local_js'], '@MaterializeBundle/Resources/public/js/materialize.min.js'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |         $this->assertEquals($this->container->getParameter('materialize.local_js'), '@MaterializeBundle/Resources/public/js/materialize.min.js'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |         $this->assertEquals($materialize['local_fonts_dir'], '@MaterializeBundle/Resources/public/fonts/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |         $this->assertEquals($this->container->getParameter('materialize.local_fonts_dir'), '@MaterializeBundle/Resources/public/fonts/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |         $this->assertEquals($materialize['local_css'], '@MaterializeBundle/Resources/public/css/materialize.min.css'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |         $this->assertEquals($this->container->getParameter('materialize.local_css'), '@MaterializeBundle/Resources/public/css/materialize.min.css'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |         $this->assertEmpty($materialize['local_cdn']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |         $this->assertEquals($materialize['local_cdn'], ''); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |         $this->assertEquals($materialize['version'], '0.97.0'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |         $this->assertNotEmpty($materialize['html5']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |         $this->assertTrue($materialize['html5']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |         $this->assertEmpty($materialize['async']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |         $this->assertFalse($materialize['async']); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 72 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 73 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 74 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 75 |  |  |      * Test normal config | 
            
                                                                        
                            
            
                                    
            
            
                | 76 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |     public function testTest() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |         $this->loadConfiguration($this->container, 'test')->compile(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |         $this->assertTrue($this->container->hasParameter('materialize')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |         $this->assertTrue($this->container->hasParameter('materialize.local_js')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |         $materialize = $this->container->getParameter('materialize'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |         $this->assertEquals($materialize['local_js'], $this->container->getParameter('materialize.local_js')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |         $this->assertEquals($this->container->getParameter('materialize.local_js'), 'materialize.min.js'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |         $this->assertEquals($materialize['local_fonts_dir'], $this->container->getParameter('materialize.local_fonts_dir')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |         $this->assertEquals($this->container->getParameter('materialize.local_fonts_dir'), 'fonts/'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |         $this->assertEquals($materialize['local_css'], $this->container->getParameter('materialize.local_css')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |         $this->assertEquals($this->container->getParameter('materialize.local_css'), 'materialize.min.css'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |         $this->assertNotEmpty($materialize['local_cdn']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |         $this->assertEquals($materialize['local_cdn'], '//cdn.site.com'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |         $this->assertEquals($materialize['version'], '3.3.0'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |         $this->assertEmpty($materialize['html5']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |         $this->assertFalse($materialize['html5']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |         $this->assertNotEmpty($materialize['async']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |         $this->assertTrue($materialize['async']); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 96 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 97 |  |  | } |