Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / symfony / dependency-injection / Tests / Compiler / ExtensionCompilerPassTest.php
index e083611458770b53f415796fdc07df6e0777d86a..810fbe48a573f59f327f26c05607d86549080504 100644 (file)
 namespace Symfony\Component\DependencyInjection\Tests\Compiler;
 
 use PHPUnit\Framework\TestCase;
+use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
 use Symfony\Component\DependencyInjection\Compiler\ExtensionCompilerPass;
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\DependencyInjection\Extension\Extension;
 
 /**
  * @author Wouter J <wouter@wouterj.nl>
@@ -24,33 +27,55 @@ class ExtensionCompilerPassTest extends TestCase
 
     protected function setUp()
     {
-        $this->container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')->getMock();
+        $this->container = new ContainerBuilder();
         $this->pass = new ExtensionCompilerPass();
     }
 
     public function testProcess()
     {
-        $extension1 = $this->createExtensionMock(true);
-        $extension1->expects($this->once())->method('process');
-        $extension2 = $this->createExtensionMock(false);
-        $extension3 = $this->createExtensionMock(false);
-        $extension4 = $this->createExtensionMock(true);
-        $extension4->expects($this->once())->method('process');
-
-        $this->container->expects($this->any())
-            ->method('getExtensions')
-            ->will($this->returnValue(array($extension1, $extension2, $extension3, $extension4)))
-        ;
+        $extension1 = new CompilerPassExtension('extension1');
+        $extension2 = new DummyExtension('extension2');
+        $extension3 = new DummyExtension('extension3');
+        $extension4 = new CompilerPassExtension('extension4');
+
+        $this->container->registerExtension($extension1);
+        $this->container->registerExtension($extension2);
+        $this->container->registerExtension($extension3);
+        $this->container->registerExtension($extension4);
 
         $this->pass->process($this->container);
+
+        $this->assertTrue($this->container->hasDefinition('extension1'));
+        $this->assertFalse($this->container->hasDefinition('extension2'));
+        $this->assertFalse($this->container->hasDefinition('extension3'));
+        $this->assertTrue($this->container->hasDefinition('extension4'));
     }
+}
+
+class DummyExtension extends Extension
+{
+    private $alias;
 
-    private function createExtensionMock($hasInlineCompile)
+    public function __construct($alias)
     {
-        return $this->getMockBuilder('Symfony\Component\DependencyInjection\\'.(
-            $hasInlineCompile
-            ? 'Compiler\CompilerPassInterface'
-            : 'Extension\ExtensionInterface'
-        ))->getMock();
+        $this->alias = $alias;
     }
+
+    public function getAlias()
+    {
+        return $this->alias;
+    }
+
+    public function load(array $configs, ContainerBuilder $container)
+    {
+    }
+
+    public function process(ContainerBuilder $container)
+    {
+        $container->register($this->alias);
+    }
+}
+
+class CompilerPassExtension extends DummyExtension implements CompilerPassInterface
+{
 }