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;
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.
->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));
$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);
}
->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');
->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']);