Commit 1b66ab0c authored by catch's avatar catch
Browse files

Issue #3130606 by shaktik, mondrake, KapilV, longwave, daffie:...

Issue #3130606 by shaktik, mondrake, KapilV, longwave, daffie: MockBuilder::setMethods is deprecated in PHPUnit8 and removed from PHPUnit10
parent fe2e7c3f
......@@ -84,7 +84,7 @@ public function testSettingsForm() {
]);
$test_processor = $this->getMockBuilder('Drupal\aggregator_test\Plugin\aggregator\processor\TestProcessor')
->setMethods(['buildConfigurationForm', 'validateConfigurationForm', 'submitConfigurationForm'])
->onlyMethods(['buildConfigurationForm', 'validateConfigurationForm', 'submitConfigurationForm'])
->setConstructorArgs([[], 'aggregator_test', ['description' => ''], $this->configFactory])
->getMock();
$test_processor->expects($this->once())
......
......@@ -96,7 +96,7 @@ public function testCalculateDependencies() {
// Mock the entity under test so that we can mock getPluginCollections().
$entity = $this->getMockBuilder('\Drupal\block\Entity\Block')
->setConstructorArgs([$values, $this->entityTypeId])
->setMethods(['getPluginCollections'])
->onlyMethods(['getPluginCollections'])
->getMock();
// Create a configurable plugin that would add a dependency.
$instance_id = $this->randomMachineName();
......@@ -106,7 +106,7 @@ public function testCalculateDependencies() {
// Create a plugin collection to contain the instance.
$plugin_collection = $this->getMockBuilder('\Drupal\Core\Plugin\DefaultLazyPluginCollection')
->disableOriginalConstructor()
->setMethods(['get'])
->onlyMethods(['get'])
->getMock();
$plugin_collection->expects($this->atLeastOnce())
->method('get')
......
......@@ -47,9 +47,9 @@ class BlockPageVariantTest extends UnitTestCase {
public function setUpDisplayVariant($configuration = [], $definition = []) {
$container = new Container();
$cache_context_manager = $this->getMockBuilder('Drupal\Core\Cache\CacheContextsManager')
$cache_context_manager = $this->getMockBuilder('Drupal\Core\Cache\Context\CacheContextsManager')
->disableOriginalConstructor()
->setMethods(['assertValidTokens'])
->onlyMethods(['assertValidTokens'])
->getMock();
$container->set('cache_contexts_manager', $cache_context_manager);
$cache_context_manager->expects($this->any())
......@@ -62,7 +62,7 @@ public function setUpDisplayVariant($configuration = [], $definition = []) {
return $this->getMockBuilder('Drupal\block\Plugin\DisplayVariant\BlockPageVariant')
->setConstructorArgs([$configuration, 'test', $definition, $this->blockRepository, $this->blockViewBuilder, ['config:block_list']])
->setMethods(['getRegionNames'])
->addMethods(['getRegionNames'])
->getMock();
}
......
......@@ -89,7 +89,7 @@ public function testTransformException() {
$migrate_lookup = $this->prophesize(MigrateLookupInterface::class);
$this->row = $this->getMockBuilder('Drupal\migrate\Row')
->disableOriginalConstructor()
->setMethods(['getSourceProperty'])
->onlyMethods(['getSourceProperty'])
->getMock();
$this->row->expects($this->exactly(2))
->method('getSourceProperty')
......
......@@ -22,7 +22,7 @@ protected function setUp(): void {
parent::setUp();
$this->bookUninstallValidator = $this->getMockBuilder('Drupal\book\BookUninstallValidator')
->disableOriginalConstructor()
->setMethods(['hasBookOutlines', 'hasBookNodes'])
->onlyMethods(['hasBookOutlines', 'hasBookNodes'])
->getMock();
$this->bookUninstallValidator->setStringTranslation($this->getStringTranslationStub());
}
......
......@@ -51,7 +51,7 @@ public function testLocks() {
$methods[] = 'invalidateTagsOnSave';
$comment = $this->getMockBuilder('Drupal\comment\Entity\Comment')
->disableOriginalConstructor()
->setMethods($methods)
->onlyMethods($methods)
->getMock();
$comment->expects($this->once())
->method('isNew')
......
......@@ -29,7 +29,7 @@ protected function setUp(): void {
parent::setUp();
$this->fieldUninstallValidator = $this->getMockBuilder('Drupal\field\FieldUninstallValidator')
->disableOriginalConstructor()
->setMethods(['getFieldStoragesByModule', 'getFieldTypeLabel'])
->onlyMethods(['getFieldStoragesByModule', 'getFieldTypeLabel'])
->getMock();
$this->fieldUninstallValidator->setStringTranslation($this->getStringTranslationStub());
}
......
......@@ -22,7 +22,7 @@ protected function setUp(): void {
parent::setUp();
$this->filterUninstallValidator = $this->getMockBuilder('Drupal\filter\FilterUninstallValidator')
->disableOriginalConstructor()
->setMethods(['getFilterDefinitionsByProvider', 'getEnabledFilterFormats'])
->onlyMethods(['getFilterDefinitionsByProvider', 'getEnabledFilterFormats'])
->getMock();
$this->filterUninstallValidator->setStringTranslation($this->getStringTranslationStub());
}
......
......@@ -59,7 +59,7 @@ public function testApplies($expected, $route_name = NULL, $parameter_map = [])
$forum_manager,
$translation_manager,
])
->setMethods(NULL)
->onlyMethods([])
->getMock();
$route_match = $this->createMock('Drupal\Core\Routing\RouteMatchInterface');
......
......@@ -66,7 +66,7 @@ public function testApplies($expected, $route_name = NULL, $parameter_map = [])
$translation_manager,
]
)
->setMethods(NULL)
->onlyMethods([])
->getMock();
$route_match = $this->createMock('Drupal\Core\Routing\RouteMatchInterface');
......
......@@ -61,7 +61,7 @@ public function testGetIndex() {
->getMock();
$manager = $this->getMockBuilder('\Drupal\forum\ForumManager')
->setMethods(['getChildren'])
->onlyMethods(['getChildren'])
->setConstructorArgs([
$config_factory,
$entity_type_manager,
......
......@@ -23,7 +23,7 @@ protected function setUp(): void {
parent::setUp();
$this->forumUninstallValidator = $this->getMockBuilder('Drupal\forum\ForumUninstallValidator')
->disableOriginalConstructor()
->setMethods(['hasForumNodes', 'hasTermsForVocabulary', 'getForumVocabulary'])
->onlyMethods(['hasForumNodes', 'hasTermsForVocabulary', 'getForumVocabulary'])
->getMock();
$this->forumUninstallValidator->setStringTranslation($this->getStringTranslationStub());
}
......
......@@ -52,7 +52,7 @@ public function testFieldItemNormalizerDenormalizeExceptions($context) {
*/
public function providerNormalizerDenormalizeExceptions() {
$mock = $this->getMockBuilder('\Drupal\Core\Field\Plugin\DataType\FieldItem')
->setMethods(['getParent'])
->addMethods(['getParent'])
->getMock();
$mock->expects($this->any())
->method('getParent')
......
......@@ -54,18 +54,13 @@ protected function getImageStyleMock($image_effect_id, $image_effect, $stubs = [
->method('createInstance')
->with($image_effect_id)
->will($this->returnValue($image_effect));
$default_stubs = [
'getImageEffectPluginManager',
'fileUriScheme',
'fileUriTarget',
'fileDefaultScheme',
];
$default_stubs = ['getImageEffectPluginManager', 'fileDefaultScheme'];
$image_style = $this->getMockBuilder('\Drupal\image\Entity\ImageStyle')
->setConstructorArgs([
['effects' => [$image_effect_id => ['id' => $image_effect_id]]],
$this->entityTypeId,
])
->setMethods(array_merge($default_stubs, $stubs))
->onlyMethods(array_merge($default_stubs, $stubs))
->getMock();
$image_style->expects($this->any())
......
......@@ -116,7 +116,7 @@ public function testResolveCacheMissWithoutFallback() {
$locale_lookup = $this->getMockBuilder('Drupal\locale\LocaleLookup')
->setConstructorArgs(['en', 'irrelevant', $this->storage, $this->cache, $this->lock, $this->configFactory, $this->languageManager, $this->requestStack])
->setMethods(['persist'])
->onlyMethods(['persist'])
->getMock();
$locale_lookup->expects($this->never())
->method('persist');
......@@ -234,7 +234,7 @@ public function testResolveCacheMissWithPersist() {
$this->configFactory = $this->getConfigFactoryStub(['locale.settings' => ['cache_strings' => TRUE]]);
$locale_lookup = $this->getMockBuilder('Drupal\locale\LocaleLookup')
->setConstructorArgs(['en', 'irrelevant', $this->storage, $this->cache, $this->lock, $this->configFactory, $this->languageManager, $this->requestStack])
->setMethods(['persist'])
->onlyMethods(['persist'])
->getMock();
$locale_lookup->expects($this->once())
->method('persist');
......@@ -264,7 +264,7 @@ public function testResolveCacheMissNoTranslation() {
$locale_lookup = $this->getMockBuilder('Drupal\locale\LocaleLookup')
->setConstructorArgs(['en', 'irrelevant', $this->storage, $this->cache, $this->lock, $this->configFactory, $this->languageManager, $this->requestStack])
->setMethods(['persist'])
->onlyMethods(['persist'])
->getMock();
$locale_lookup->expects($this->never())
->method('persist');
......
......@@ -176,14 +176,14 @@ public function testFieldProvidersExist() {
public function testFieldProviderMissingRequiredProperty(array $definitions, $missing_property) {
$discovery = $this->getMockBuilder(MigrateFieldPluginManager::class)
->disableOriginalConstructor()
->setMethods(['getDefinitions'])
->onlyMethods(['getDefinitions'])
->getMock();
$discovery->method('getDefinitions')
->willReturn($definitions);
$plugin_manager = $this->getMockBuilder(MigrateFieldPluginManager::class)
->disableOriginalConstructor()
->setMethods(['getDiscovery'])
->onlyMethods(['getDiscovery'])
->getMock();
$plugin_manager->method('getDiscovery')
->willReturn($discovery);
......
......@@ -483,7 +483,7 @@ protected function getMockSource() {
$class = 'Drupal\migrate\Plugin\migrate\source\SourcePluginBase';
$source = $this->getMockBuilder($class)
->disableOriginalConstructor()
->setMethods(get_class_methods($class))
->onlyMethods(get_class_methods($class))
->getMockForAbstractClass();
$source->expects($this->once())
->method('rewind')
......
......@@ -112,7 +112,7 @@ protected function getSource($configuration = [], $migrate_config = [], $status
$constructor_args = [$configuration, 'd6_action', [], $this->migration];
$methods = ['getModuleHandler', 'fields', 'getIds', '__toString', 'prepareRow', 'initializeIterator'];
$source_plugin = $this->getMockBuilder(SourcePluginBase::class)
->setMethods($methods)
->onlyMethods($methods)
->setConstructorArgs($constructor_args)
->getMock();
......
......@@ -40,12 +40,12 @@ protected function setUp(): void {
->getMock();
$this->view = $this->getMockBuilder('\Drupal\views\Entity\View')
->setMethods(['initHandlers'])
->addMethods(['initHandlers'])
->setConstructorArgs([['id' => 'test_view'], 'view'])
->getMock();
$view_executable = $this->getMockBuilder('\Drupal\views\ViewExecutable')
->setMethods(['initHandlers', 'getTitle'])
->onlyMethods(['initHandlers', 'getTitle'])
->disableOriginalConstructor()
->getMock();
$view_executable->expects($this->any())
......@@ -116,7 +116,7 @@ protected function setUp(): void {
->will($this->returnValue($none));
$style_plugin = $this->getMockBuilder('\Drupal\rest\Plugin\views\style\Serializer')
->setMethods(['getFormats', 'init'])
->onlyMethods(['getFormats', 'init'])
->disableOriginalConstructor()
->getMock();
......
......@@ -51,7 +51,7 @@ public function testFailedValidate() {
$violations = $this->getMockBuilder(EntityConstraintViolationList::class)
->setConstructorArgs([$entity->reveal(), [$violation1->reveal(), $violation2->reveal()]])
->setMethods(['filterByFieldAccess'])
->onlyMethods(['filterByFieldAccess'])
->getMock();
$violations->expects($this->once())
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment