diff --git a/core/modules/serialization/tests/src/Unit/Normalizer/ListNormalizerTest.php b/core/modules/serialization/tests/src/Unit/Normalizer/ListNormalizerTest.php index 97a0711..170fd3e 100644 --- a/core/modules/serialization/tests/src/Unit/Normalizer/ListNormalizerTest.php +++ b/core/modules/serialization/tests/src/Unit/Normalizer/ListNormalizerTest.php @@ -3,6 +3,7 @@ namespace Drupal\Tests\serialization\Unit\Normalizer; use Drupal\Core\TypedData\DataDefinition; +use Drupal\Core\TypedData\TypedDataManagerInterface; use Drupal\Tests\UnitTestCase; use Drupal\serialization\Normalizer\ListNormalizer; use Drupal\Core\TypedData\Plugin\DataType\ItemList; @@ -37,10 +38,7 @@ class ListNormalizerTest extends UnitTestCase { protected function setUp() { // Mock the TypedDataManager to return a TypedDataInterface mock. $typed_data = $this->getMock('Drupal\Core\TypedData\TypedDataInterface'); - $typed_data_manager = $this->getMockBuilder('Drupal\Core\TypedData\TypedDataManager') - ->disableOriginalConstructor() - ->setMethods(array('getPropertyInstance')) - ->getMock(); + $typed_data_manager = $this->getMock(TypedDataManagerInterface::class); $typed_data_manager->expects($this->any()) ->method('getPropertyInstance') ->will($this->returnValue($typed_data)); diff --git a/core/modules/views/tests/src/Unit/EntityViewsDataTest.php b/core/modules/views/tests/src/Unit/EntityViewsDataTest.php index c3e93ed..c1db0cf 100644 --- a/core/modules/views/tests/src/Unit/EntityViewsDataTest.php +++ b/core/modules/views/tests/src/Unit/EntityViewsDataTest.php @@ -18,6 +18,7 @@ use Drupal\Core\Field\Plugin\Field\FieldType\StringItem; use Drupal\Core\Field\Plugin\Field\FieldType\UriItem; use Drupal\Core\Field\Plugin\Field\FieldType\UuidItem; +use Drupal\Core\TypedData\TypedDataManagerInterface; use Drupal\text\Plugin\Field\FieldType\TextLongItem; use Drupal\entity_test\Entity\EntityTest; use Drupal\entity_test\Entity\EntityTestMul; @@ -83,9 +84,7 @@ protected function setUp() { ->getMock(); $this->entityManager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface'); - $typed_data_manager = $this->getMockBuilder('Drupal\Core\TypedData\TypedDataManager') - ->disableOriginalConstructor() - ->getMock(); + $typed_data_manager = $this->getMock(TypedDataManagerInterface::class); $typed_data_manager->expects($this->any()) ->method('createDataDefinition') ->willReturn($this->getMock('Drupal\Core\TypedData\DataDefinitionInterface')); diff --git a/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php b/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php index 4c39b4c..cb73533 100644 --- a/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php @@ -7,6 +7,7 @@ use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Field\BaseFieldDefinition; use Drupal\Core\Language\LanguageInterface; +use Drupal\Core\TypedData\TypedDataManagerInterface; use Drupal\Tests\UnitTestCase; use Drupal\Core\Language\Language; @@ -130,9 +131,7 @@ protected function setUp() { $this->uuid = $this->getMock('\Drupal\Component\Uuid\UuidInterface'); - $this->typedDataManager = $this->getMockBuilder('\Drupal\Core\TypedData\TypedDataManager') - ->disableOriginalConstructor() - ->getMock(); + $this->typedDataManager = $this->getMock(TypedDataManagerInterface::class); $this->typedDataManager->expects($this->any()) ->method('getDefinition') ->with('entity') diff --git a/core/tests/Drupal/Tests/Core/Entity/TypedData/EntityAdapterUnitTest.php b/core/tests/Drupal/Tests/Core/Entity/TypedData/EntityAdapterUnitTest.php index b7debff..646f17a 100644 --- a/core/tests/Drupal/Tests/Core/Entity/TypedData/EntityAdapterUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/TypedData/EntityAdapterUnitTest.php @@ -6,6 +6,7 @@ use Drupal\Core\Entity\Plugin\DataType\EntityAdapter; use Drupal\Core\Field\BaseFieldDefinition; use Drupal\Core\Language\LanguageInterface; +use Drupal\Core\TypedData\TypedDataManagerInterface; use Drupal\Tests\UnitTestCase; use Drupal\Core\Language\Language; @@ -136,9 +137,7 @@ protected function setUp() { $this->uuid = $this->getMock('\Drupal\Component\Uuid\UuidInterface'); - $this->typedDataManager = $this->getMockBuilder('\Drupal\Core\TypedData\TypedDataManager') - ->disableOriginalConstructor() - ->getMock(); + $this->typedDataManager = $this->getMock(TypedDataManagerInterface::class); $this->typedDataManager->expects($this->any()) ->method('getDefinition') ->with('entity') diff --git a/core/tests/Drupal/Tests/Core/Field/BaseFieldDefinitionTestBase.php b/core/tests/Drupal/Tests/Core/Field/BaseFieldDefinitionTestBase.php index 959f7f0..e6a5de8 100644 --- a/core/tests/Drupal/Tests/Core/Field/BaseFieldDefinitionTestBase.php +++ b/core/tests/Drupal/Tests/Core/Field/BaseFieldDefinitionTestBase.php @@ -5,6 +5,7 @@ use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\Core\Field\BaseFieldDefinition; use Drupal\Core\Field\FieldTypePluginManager; +use Drupal\Core\TypedData\TypedDataManagerInterface; use Drupal\Tests\UnitTestCase; /** @@ -35,9 +36,7 @@ protected function setUp() { ->method('moduleExists') ->with($module_name) ->will($this->returnValue(TRUE)); - $typed_data_manager = $this->getMockBuilder('\Drupal\Core\TypedData\TypedDataManager') - ->disableOriginalConstructor() - ->getMock(); + $typed_data_manager = $this->getMock(TypedDataManagerInterface::class); $plugin_manager = new FieldTypePluginManager( $namespaces, $this->getMock('Drupal\Core\Cache\CacheBackendInterface'), diff --git a/core/tests/Drupal/Tests/Core/Plugin/Context/ContextDefinitionTest.php b/core/tests/Drupal/Tests/Core/Plugin/Context/ContextDefinitionTest.php index 7f084e4..fb1a442 100644 --- a/core/tests/Drupal/Tests/Core/Plugin/Context/ContextDefinitionTest.php +++ b/core/tests/Drupal/Tests/Core/Plugin/Context/ContextDefinitionTest.php @@ -3,6 +3,7 @@ namespace Drupal\Tests\Core\Plugin\Context; use Drupal\Core\Plugin\Context\ContextDefinition; +use Drupal\Core\TypedData\TypedDataManagerInterface; use Drupal\Tests\UnitTestCase; /** @@ -61,10 +62,7 @@ public function testGetDataDefinition($is_multiple) { if ($is_multiple) { $create_definition_method = 'createListDataDefinition'; } - $mock_data_manager = $this->getMockBuilder('\Drupal\Core\TypedData\TypedDataManager') - ->disableOriginalConstructor() - ->setMethods(array($create_definition_method)) - ->getMock(); + $mock_data_manager = $this->getMock(TypedDataManagerInterface::class); // Our mocked data manager will return our mocked data definition for a // valid data type. $mock_data_manager->expects($this->once()) @@ -127,10 +125,7 @@ public function testGetDataDefinitionInvalidType($is_multiple) { if ($is_multiple) { $create_definition_method = 'createListDataDefinition'; } - $mock_data_manager = $this->getMockBuilder('\Drupal\Core\TypedData\TypedDataManager') - ->disableOriginalConstructor() - ->setMethods(array($create_definition_method)) - ->getMock(); + $mock_data_manager = $this->getMock(TypedDataManagerInterface::class); // Our mocked data manager will return NULL for a non-valid data type. This // will eventually cause getDataDefinition() to throw an exception. $mock_data_manager->expects($this->once()) diff --git a/core/tests/Drupal/Tests/Core/Plugin/Context/ContextTest.php b/core/tests/Drupal/Tests/Core/Plugin/Context/ContextTest.php index d027f8a..c0d750e 100644 --- a/core/tests/Drupal/Tests/Core/Plugin/Context/ContextTest.php +++ b/core/tests/Drupal/Tests/Core/Plugin/Context/ContextTest.php @@ -10,6 +10,7 @@ use Drupal\Core\Cache\CacheableDependencyInterface; use Drupal\Core\Plugin\Context\Context; use Drupal\Core\TypedData\TypedDataInterface; +use Drupal\Core\TypedData\TypedDataManagerInterface; use Drupal\Tests\UnitTestCase; use Symfony\Component\DependencyInjection\Container; @@ -46,10 +47,7 @@ class ContextTest extends UnitTestCase { protected function setUp() { parent::setUp(); - $this->typedDataManager = $this->getMockBuilder('Drupal\Core\TypedData\TypedDataManager') - ->disableOriginalConstructor() - ->setMethods(array('create')) - ->getMock(); + $this->typedDataManager = $this->getMock(TypedDataManagerInterface::class); } /** diff --git a/core/tests/Drupal/Tests/Core/Plugin/Context/ContextTypedDataTest.php b/core/tests/Drupal/Tests/Core/Plugin/Context/ContextTypedDataTest.php index 5e7df20..dfc9361 100644 --- a/core/tests/Drupal/Tests/Core/Plugin/Context/ContextTypedDataTest.php +++ b/core/tests/Drupal/Tests/Core/Plugin/Context/ContextTypedDataTest.php @@ -7,6 +7,7 @@ use Drupal\Core\Plugin\Context\ContextDefinition; use Drupal\Core\TypedData\DataDefinition; use Drupal\Core\TypedData\Plugin\DataType\StringData; +use Drupal\Core\TypedData\TypedDataManagerInterface; use Drupal\Tests\UnitTestCase; /** @@ -34,9 +35,7 @@ class ContextTypedDataTest extends UnitTestCase { */ public function testGetContextValue() { // Prepare a container that holds the typed data manager mock. - $typed_data_manager = $this->getMockBuilder('Drupal\Core\TypedData\TypedDataManager') - ->disableOriginalConstructor() - ->getMock(); + $typed_data_manager = $this->getMock(TypedDataManagerInterface::class); $typed_data_manager->expects($this->once()) ->method('getCanonicalRepresentation') ->will($this->returnCallback(array($this, 'getCanonicalRepresentation')));