Loading core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php +2 −2 Original line number Diff line number Diff line Loading @@ -47,9 +47,9 @@ class ConfigNamesMapperTest extends UnitTestCase { protected $localeConfigManager; /** * The locale configuration manager. * The typed configuration manager. * * @var \Drupal\locale\LocaleConfigManager|\PHPUnit\Framework\MockObject\MockObject * @var \Drupal\Core\Config\TypedConfigManagerInterface|\PHPUnit\Framework\MockObject\MockObject */ protected $typedConfigManager; Loading core/modules/help_topics/tests/src/Unit/HelpTopicTwigLoaderTest.php +15 −35 Original line number Diff line number Diff line Loading @@ -2,6 +2,8 @@ namespace Drupal\Tests\help_topics\Unit; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Extension\ThemeHandlerInterface; use Drupal\help_topics\HelpTopicTwigLoader; use Drupal\Tests\UnitTestCase; use org\bovigo\vfs\vfsStream; Loading Loading @@ -36,10 +38,19 @@ protected function setUp(): void { parent::setUp(); $this->setUpVfs(); $this->helpLoader = new HelpTopicTwigLoader('\fake\root\path', $this->getHandlerMock('module'), $this->getHandlerMock('theme') ); $module_handler = $this->createMock(ModuleHandlerInterface::class); $module_handler ->method('getModuleDirectories') ->willReturn($this->directories['module']); /** @var \Drupal\Core\Extension\ThemeHandlerInterface|\Prophecy\Prophecy\ObjectProphecy $module_handler */ $theme_handler = $this->createMock(ThemeHandlerInterface::class); $theme_handler ->method('getThemeDirectories') ->willReturn($this->directories['theme']); $this->helpLoader = new HelpTopicTwigLoader('\fake\root\path', $module_handler, $theme_handler); } /** Loading Loading @@ -72,37 +83,6 @@ public function testGetSourceContextException() { $this->helpLoader->getSourceContext('@' . HelpTopicTwigLoader::MAIN_NAMESPACE . '/test.invalid_yaml.html.twig'); } /** * Creates a mock module or theme handler class for the test. * * @param string $type * Type of handler to return: 'module' or 'theme'. * * @return \PHPUnit\Framework\MockObject\MockObject * The mock of module or theme handler. */ protected function getHandlerMock($type) { if ($type == 'module') { $class = 'Drupal\Core\Extension\ModuleHandlerInterface'; $method = 'getModuleDirectories'; } else { $class = 'Drupal\Core\Extension\ThemeHandlerInterface'; $method = 'getThemeDirectories'; } $handler = $this ->getMockBuilder($class) ->disableOriginalConstructor() ->getMock(); $handler ->method($method) ->willReturn($this->directories[$type]); return $handler; } /** * Sets up the virtual file system. */ Loading core/modules/serialization/tests/src/Unit/Normalizer/ContentEntityNormalizerTest.php +10 −14 Original line number Diff line number Diff line Loading @@ -5,11 +5,14 @@ use Drupal\Core\Entity\EntityFieldManagerInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\EntityTypeRepositoryInterface; use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\TypedData\ComplexDataInterface; use Drupal\Core\TypedData\DataDefinitionInterface; use Drupal\serialization\Normalizer\ContentEntityNormalizer; use Drupal\Tests\UnitTestCase; use Prophecy\Argument; use Symfony\Component\Serializer\Serializer; /** * @coversDefaultClass \Drupal\serialization\Normalizer\ContentEntityNormalizer Loading @@ -20,7 +23,7 @@ class ContentEntityNormalizerTest extends UnitTestCase { /** * The mock serializer. * * @var \Symfony\Component\Serializer\SerializerInterface|\PHPUnit\Framework\MockObject\MockObject * @var \Symfony\Component\Serializer\Serializer|\Prophecy\Prophecy\ObjectProphecy */ protected $serializer; Loading @@ -43,11 +46,8 @@ protected function setUp(): void { $this->contentEntityNormalizer = new ContentEntityNormalizer($entity_type_manager, $entity_type_repository, $entity_field_manager); $this->serializer = $this->getMockBuilder('Symfony\Component\Serializer\Serializer') ->disableOriginalConstructor() ->onlyMethods(['normalize']) ->getMock(); $this->contentEntityNormalizer->setSerializer($this->serializer); $this->serializer = $this->prophesize(Serializer::class); $this->contentEntityNormalizer->setSerializer($this->serializer->reveal()); } /** Loading @@ -66,10 +66,8 @@ public function testSupportsNormalization() { * @covers ::normalize */ public function testNormalize() { $this->serializer->expects($this->any()) ->method('normalize') ->with($this->containsOnlyInstancesOf('Drupal\Core\Field\FieldItemListInterface'), 'test_format', ['account' => NULL]) ->willReturn('test'); $this->serializer->normalize(Argument::type(FieldItemListInterface::class), 'test_format', ['account' => NULL])->willReturn('test'); $definitions = [ 'field_accessible_external' => $this->createMockFieldListItem(TRUE, FALSE), Loading Loading @@ -100,10 +98,8 @@ public function testNormalizeWithAccountContext() { 'account' => $mock_account, ]; $this->serializer->expects($this->any()) ->method('normalize') ->with($this->containsOnlyInstancesOf('Drupal\Core\Field\FieldItemListInterface'), 'test_format', $context) ->willReturn('test'); $this->serializer->normalize(Argument::type(FieldItemListInterface::class), 'test_format', $context)->willReturn('test'); // The mock account should get passed directly into the access() method on // field items from $context['account']. Loading core/modules/views/tests/src/Unit/EventSubscriber/RouteSubscriberTest.php +2 −2 Original line number Diff line number Diff line Loading @@ -28,9 +28,9 @@ class RouteSubscriberTest extends UnitTestCase { protected $entityTypeManager; /** * The mocked view storage. * The mocked config entity storage. * * @var \Drupal\Tests\views\Kernel\ViewStorageTest|\PHPUnit\Framework\MockObject\MockObject * @var \Drupal\Core\Config\Entity\ConfigEntityStorageInterface|\PHPUnit\Framework\MockObject\MockObject */ protected $viewStorage; Loading core/modules/views/tests/src/Unit/ViewExecutableTest.php +2 −2 Original line number Diff line number Diff line Loading @@ -84,9 +84,9 @@ class ViewExecutableTest extends UnitTestCase { protected $viewsData; /** * The mocked display handler. * The mocked display router handler. * * @var \Drupal\views\Plugin\views\display\DisplayPluginInterface|\PHPUnit\Framework\MockObject\MockObject * @var \Drupal\views\Plugin\views\display\DisplayRouterInterface|\PHPUnit\Framework\MockObject\MockObject */ protected $displayHandler; Loading Loading
core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php +2 −2 Original line number Diff line number Diff line Loading @@ -47,9 +47,9 @@ class ConfigNamesMapperTest extends UnitTestCase { protected $localeConfigManager; /** * The locale configuration manager. * The typed configuration manager. * * @var \Drupal\locale\LocaleConfigManager|\PHPUnit\Framework\MockObject\MockObject * @var \Drupal\Core\Config\TypedConfigManagerInterface|\PHPUnit\Framework\MockObject\MockObject */ protected $typedConfigManager; Loading
core/modules/help_topics/tests/src/Unit/HelpTopicTwigLoaderTest.php +15 −35 Original line number Diff line number Diff line Loading @@ -2,6 +2,8 @@ namespace Drupal\Tests\help_topics\Unit; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Extension\ThemeHandlerInterface; use Drupal\help_topics\HelpTopicTwigLoader; use Drupal\Tests\UnitTestCase; use org\bovigo\vfs\vfsStream; Loading Loading @@ -36,10 +38,19 @@ protected function setUp(): void { parent::setUp(); $this->setUpVfs(); $this->helpLoader = new HelpTopicTwigLoader('\fake\root\path', $this->getHandlerMock('module'), $this->getHandlerMock('theme') ); $module_handler = $this->createMock(ModuleHandlerInterface::class); $module_handler ->method('getModuleDirectories') ->willReturn($this->directories['module']); /** @var \Drupal\Core\Extension\ThemeHandlerInterface|\Prophecy\Prophecy\ObjectProphecy $module_handler */ $theme_handler = $this->createMock(ThemeHandlerInterface::class); $theme_handler ->method('getThemeDirectories') ->willReturn($this->directories['theme']); $this->helpLoader = new HelpTopicTwigLoader('\fake\root\path', $module_handler, $theme_handler); } /** Loading Loading @@ -72,37 +83,6 @@ public function testGetSourceContextException() { $this->helpLoader->getSourceContext('@' . HelpTopicTwigLoader::MAIN_NAMESPACE . '/test.invalid_yaml.html.twig'); } /** * Creates a mock module or theme handler class for the test. * * @param string $type * Type of handler to return: 'module' or 'theme'. * * @return \PHPUnit\Framework\MockObject\MockObject * The mock of module or theme handler. */ protected function getHandlerMock($type) { if ($type == 'module') { $class = 'Drupal\Core\Extension\ModuleHandlerInterface'; $method = 'getModuleDirectories'; } else { $class = 'Drupal\Core\Extension\ThemeHandlerInterface'; $method = 'getThemeDirectories'; } $handler = $this ->getMockBuilder($class) ->disableOriginalConstructor() ->getMock(); $handler ->method($method) ->willReturn($this->directories[$type]); return $handler; } /** * Sets up the virtual file system. */ Loading
core/modules/serialization/tests/src/Unit/Normalizer/ContentEntityNormalizerTest.php +10 −14 Original line number Diff line number Diff line Loading @@ -5,11 +5,14 @@ use Drupal\Core\Entity\EntityFieldManagerInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\EntityTypeRepositoryInterface; use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\TypedData\ComplexDataInterface; use Drupal\Core\TypedData\DataDefinitionInterface; use Drupal\serialization\Normalizer\ContentEntityNormalizer; use Drupal\Tests\UnitTestCase; use Prophecy\Argument; use Symfony\Component\Serializer\Serializer; /** * @coversDefaultClass \Drupal\serialization\Normalizer\ContentEntityNormalizer Loading @@ -20,7 +23,7 @@ class ContentEntityNormalizerTest extends UnitTestCase { /** * The mock serializer. * * @var \Symfony\Component\Serializer\SerializerInterface|\PHPUnit\Framework\MockObject\MockObject * @var \Symfony\Component\Serializer\Serializer|\Prophecy\Prophecy\ObjectProphecy */ protected $serializer; Loading @@ -43,11 +46,8 @@ protected function setUp(): void { $this->contentEntityNormalizer = new ContentEntityNormalizer($entity_type_manager, $entity_type_repository, $entity_field_manager); $this->serializer = $this->getMockBuilder('Symfony\Component\Serializer\Serializer') ->disableOriginalConstructor() ->onlyMethods(['normalize']) ->getMock(); $this->contentEntityNormalizer->setSerializer($this->serializer); $this->serializer = $this->prophesize(Serializer::class); $this->contentEntityNormalizer->setSerializer($this->serializer->reveal()); } /** Loading @@ -66,10 +66,8 @@ public function testSupportsNormalization() { * @covers ::normalize */ public function testNormalize() { $this->serializer->expects($this->any()) ->method('normalize') ->with($this->containsOnlyInstancesOf('Drupal\Core\Field\FieldItemListInterface'), 'test_format', ['account' => NULL]) ->willReturn('test'); $this->serializer->normalize(Argument::type(FieldItemListInterface::class), 'test_format', ['account' => NULL])->willReturn('test'); $definitions = [ 'field_accessible_external' => $this->createMockFieldListItem(TRUE, FALSE), Loading Loading @@ -100,10 +98,8 @@ public function testNormalizeWithAccountContext() { 'account' => $mock_account, ]; $this->serializer->expects($this->any()) ->method('normalize') ->with($this->containsOnlyInstancesOf('Drupal\Core\Field\FieldItemListInterface'), 'test_format', $context) ->willReturn('test'); $this->serializer->normalize(Argument::type(FieldItemListInterface::class), 'test_format', $context)->willReturn('test'); // The mock account should get passed directly into the access() method on // field items from $context['account']. Loading
core/modules/views/tests/src/Unit/EventSubscriber/RouteSubscriberTest.php +2 −2 Original line number Diff line number Diff line Loading @@ -28,9 +28,9 @@ class RouteSubscriberTest extends UnitTestCase { protected $entityTypeManager; /** * The mocked view storage. * The mocked config entity storage. * * @var \Drupal\Tests\views\Kernel\ViewStorageTest|\PHPUnit\Framework\MockObject\MockObject * @var \Drupal\Core\Config\Entity\ConfigEntityStorageInterface|\PHPUnit\Framework\MockObject\MockObject */ protected $viewStorage; Loading
core/modules/views/tests/src/Unit/ViewExecutableTest.php +2 −2 Original line number Diff line number Diff line Loading @@ -84,9 +84,9 @@ class ViewExecutableTest extends UnitTestCase { protected $viewsData; /** * The mocked display handler. * The mocked display router handler. * * @var \Drupal\views\Plugin\views\display\DisplayPluginInterface|\PHPUnit\Framework\MockObject\MockObject * @var \Drupal\views\Plugin\views\display\DisplayRouterInterface|\PHPUnit\Framework\MockObject\MockObject */ protected $displayHandler; Loading