Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / modules / responsive_image / tests / src / Unit / ResponsiveImageStyleConfigEntityUnitTest.php
index bc9663dcf2603cb3483edf4fc076fe8449ea5760..0c64b05ed8575c8d226a417a80869715ed17e0e7 100644 (file)
@@ -3,6 +3,8 @@
 namespace Drupal\Tests\responsive_image\Unit;
 
 use Drupal\Core\DependencyInjection\ContainerBuilder;
+use Drupal\Core\Entity\EntityTypeManagerInterface;
+use Drupal\Core\Entity\EntityTypeRepositoryInterface;
 use Drupal\responsive_image\Entity\ResponsiveImageStyle;
 use Drupal\Tests\UnitTestCase;
 
@@ -20,11 +22,11 @@ class ResponsiveImageStyleConfigEntityUnitTest extends UnitTestCase {
   protected $entityType;
 
   /**
-   * The entity manager used for testing.
+   * The entity type manager used for testing.
    *
-   * @var \Drupal\Core\Entity\EntityManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+   * @var \Drupal\Core\Entity\EntityTypeManagerInterface|\PHPUnit_Framework_MockObject_MockObject
    */
-  protected $entityManager;
+  protected $entityTypeManager;
 
   /**
    * The breakpoint manager used for testing.
@@ -42,8 +44,8 @@ class ResponsiveImageStyleConfigEntityUnitTest extends UnitTestCase {
       ->method('getProvider')
       ->will($this->returnValue('responsive_image'));
 
-    $this->entityManager = $this->getMock('\Drupal\Core\Entity\EntityManagerInterface');
-    $this->entityManager->expects($this->any())
+    $this->entityTypeManager = $this->getMock(EntityTypeManagerInterface::class);
+    $this->entityTypeManager->expects($this->any())
       ->method('getDefinition')
       ->with('responsive_image_style')
       ->will($this->returnValue($this->entityType));
@@ -51,7 +53,7 @@ class ResponsiveImageStyleConfigEntityUnitTest extends UnitTestCase {
     $this->breakpointManager = $this->getMock('\Drupal\breakpoint\BreakpointManagerInterface');
 
     $container = new ContainerBuilder();
-    $container->set('entity.manager', $this->entityManager);
+    $container->set('entity_type.manager', $this->entityTypeManager);
     $container->set('breakpoint.manager', $this->breakpointManager);
     \Drupal::setContainer($container);
   }
@@ -74,11 +76,14 @@ class ResponsiveImageStyleConfigEntityUnitTest extends UnitTestCase {
       ->method('loadMultiple')
       ->with(array_keys($styles))
       ->willReturn($styles);
-    $this->entityManager->expects($this->any())
+
+    $this->entityTypeManager->expects($this->any())
       ->method('getStorage')
       ->with('image_style')
       ->willReturn($storage);
-    $this->entityManager->expects($this->any())
+
+    $entity_type_repository = $this->getMockForAbstractClass(EntityTypeRepositoryInterface::class);
+    $entity_type_repository->expects($this->any())
       ->method('getEntityTypeFromClass')
       ->with('Drupal\image\Entity\ImageStyle')
       ->willReturn('image_style');
@@ -103,6 +108,8 @@ class ResponsiveImageStyleConfigEntityUnitTest extends UnitTestCase {
       ->with('test_group')
       ->willReturn(['bartik' => 'theme', 'toolbar' => 'module']);
 
+    \Drupal::getContainer()->set('entity_type.repository', $entity_type_repository);
+
     $dependencies = $entity->calculateDependencies()->getDependencies();
     $this->assertEquals(['toolbar'], $dependencies['module']);
     $this->assertEquals(['bartik'], $dependencies['theme']);