diff --git a/composer.json b/composer.json
index 71dcc9605c..db1e3a4d6b 100644
--- a/composer.json
+++ b/composer.json
@@ -50,10 +50,12 @@
"scripts": {
"pre-autoload-dump": "Drupal\\Core\\Composer\\Composer::preAutoloadDump",
"post-autoload-dump": [
- "Drupal\\Core\\Composer\\Composer::ensureHtaccess"
+ "Drupal\\Core\\Composer\\Composer::ensureHtaccess",
+ "Drupal\\Core\\Composer\\Composer::upgradePHPUnit"
],
"post-package-install": "Drupal\\Core\\Composer\\Composer::vendorTestCodeCleanup",
"post-package-update": "Drupal\\Core\\Composer\\Composer::vendorTestCodeCleanup",
+ "drupal-phpunit-upgrade": "@composer upgrade phpunit/phpunit --with-dependencies --no-progress",
"phpcs": "phpcs --standard=core/phpcs.xml.dist --runtime-set installed_paths $($COMPOSER_BINARY config vendor-dir)/drupal/coder/coder_sniffer --",
"phpcbf": "phpcbf --standard=core/phpcs.xml.dist --runtime-set installed_paths $($COMPOSER_BINARY config vendor-dir)/drupal/coder/coder_sniffer --"
},
diff --git a/core/composer.json b/core/composer.json
index 31bc51a0fa..c4bb384b92 100644
--- a/core/composer.json
+++ b/core/composer.json
@@ -44,7 +44,7 @@
"jcalderonzumba/gastonjs": "^1.0.2",
"jcalderonzumba/mink-phantomjs-driver": "^0.3.1",
"mikey179/vfsStream": "^1.2",
- "phpunit/phpunit": ">=4.8.35 <5",
+ "phpunit/phpunit": "^4.8.35 || ^6.1",
"phpspec/prophecy": "^1.4",
"symfony/css-selector": "~3.2.8",
"symfony/phpunit-bridge": "^3.4.0@beta"
diff --git a/core/lib/Drupal/Core/Composer/Composer.php b/core/lib/Drupal/Core/Composer/Composer.php
index 016f93a348..8bfc7bb8c2 100644
--- a/core/lib/Drupal/Core/Composer/Composer.php
+++ b/core/lib/Drupal/Core/Composer/Composer.php
@@ -6,6 +6,7 @@
use Composer\Script\Event;
use Composer\Installer\PackageEvent;
use Composer\Semver\Constraint\Constraint;
+use PHPUnit\Runner\Version;
/**
* Provides static functions for composer script events.
@@ -143,6 +144,24 @@ public static function ensureHtaccess(Event $event) {
}
}
+ /**
+ * Fires the drupal-phpunit-upgrade script event if necessary.
+ *
+ * @param \Composer\Script\Event $event
+ */
+ public static function upgradePHPUnit(Event $event) {
+ if (class_exists('PHPUnit_Runner_Version')) {
+ $phpunit_version = \PHPUnit_Runner_Version::id();
+ }
+ if (class_exists('\PHPUnit\Runner\Version')) {
+ $phpunit_version = Version::id();
+ }
+ // @todo if we haven't determine version throw an error.
+ if (version_compare(PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION, '7.1') >= 0 && version_compare($phpunit_version, '6.0') < 0) {
+ $event->getComposer()->getEventDispatcher()->dispatchScript('drupal-phpunit-upgrade');
+ }
+ }
+
/**
* Remove possibly problematic test files from vendored projects.
*
diff --git a/core/lib/Drupal/Core/Entity/EntityDisplayBase.php b/core/lib/Drupal/Core/Entity/EntityDisplayBase.php
index 7c736e8adf..34ce858b13 100644
--- a/core/lib/Drupal/Core/Entity/EntityDisplayBase.php
+++ b/core/lib/Drupal/Core/Entity/EntityDisplayBase.php
@@ -250,7 +250,7 @@ public function id() {
/**
* {@inheritdoc}
*/
- public function preSave(EntityStorageInterface $storage, $update = TRUE) {
+ public function preSave(EntityStorageInterface $storage) {
// Ensure that a region is set on each component.
foreach ($this->getComponents() as $name => $component) {
$this->handleHiddenType($name, $component);
@@ -263,7 +263,7 @@ public function preSave(EntityStorageInterface $storage, $update = TRUE) {
ksort($this->content);
ksort($this->hidden);
- parent::preSave($storage, $update);
+ parent::preSave($storage);
}
/**
diff --git a/core/lib/Drupal/Core/Field/FieldItemList.php b/core/lib/Drupal/Core/Field/FieldItemList.php
index 152005bcf3..52bf9c9d23 100644
--- a/core/lib/Drupal/Core/Field/FieldItemList.php
+++ b/core/lib/Drupal/Core/Field/FieldItemList.php
@@ -95,18 +95,6 @@ public function filterEmptyItems() {
return $this;
}
- /**
- * {@inheritdoc}
- * @todo Revisit the need when all entity types are converted to NG entities.
- */
- public function getValue($include_computed = FALSE) {
- $values = [];
- foreach ($this->list as $delta => $item) {
- $values[$delta] = $item->getValue($include_computed);
- }
- return $values;
- }
-
/**
* {@inheritdoc}
*/
diff --git a/core/modules/big_pipe/tests/src/Unit/Render/BigPipeResponseAttachmentsProcessorTest.php b/core/modules/big_pipe/tests/src/Unit/Render/BigPipeResponseAttachmentsProcessorTest.php
index a4cbacdf9e..ba69bfee60 100644
--- a/core/modules/big_pipe/tests/src/Unit/Render/BigPipeResponseAttachmentsProcessorTest.php
+++ b/core/modules/big_pipe/tests/src/Unit/Render/BigPipeResponseAttachmentsProcessorTest.php
@@ -101,8 +101,8 @@ public function attachmentsProvider() {
'random attachment type (unofficial), with random assigned value, to prove BigPipeResponseAttachmentsProcessor is a perfect decorator' => [$random_attachments],
];
- $big_pipe_placeholder_attachments = ['big_pipe_placeholders' => $this->randomMachineName()];
- $big_pipe_nojs_placeholder_attachments = ['big_pipe_nojs_placeholders' => $this->randomMachineName()];
+ $big_pipe_placeholder_attachments = ['big_pipe_placeholders' => [$this->randomMachineName()]];
+ $big_pipe_nojs_placeholder_attachments = ['big_pipe_nojs_placeholders' => [$this->randomMachineName()]];
$big_pipe_cases = [
'only big_pipe_placeholders' => [$big_pipe_placeholder_attachments],
'only big_pipe_nojs_placeholders' => [$big_pipe_nojs_placeholder_attachments],
diff --git a/core/modules/block/tests/src/Unit/Plugin/DisplayVariant/BlockPageVariantTest.php b/core/modules/block/tests/src/Unit/Plugin/DisplayVariant/BlockPageVariantTest.php
index 1569411353..5d3a20b6a6 100644
--- a/core/modules/block/tests/src/Unit/Plugin/DisplayVariant/BlockPageVariantTest.php
+++ b/core/modules/block/tests/src/Unit/Plugin/DisplayVariant/BlockPageVariantTest.php
@@ -49,6 +49,7 @@ public function setUpDisplayVariant($configuration = [], $definition = []) {
$container = new Container();
$cache_context_manager = $this->getMockBuilder('Drupal\Core\Cache\CacheContextsManager')
->disableOriginalConstructor()
+ ->setMethods(['assertValidTokens'])
->getMock();
$container->set('cache_contexts_manager', $cache_context_manager);
$cache_context_manager->expects($this->any())
@@ -209,9 +210,6 @@ public function testBuild(array $blocks_config, $visible_block_count, array $exp
$title_block_plugin = $this->getMock('Drupal\Core\Block\TitleBlockPluginInterface');
foreach ($blocks_config as $block_id => $block_config) {
$block = $this->getMock('Drupal\block\BlockInterface');
- $block->expects($this->any())
- ->method('getContexts')
- ->willReturn([]);
$block->expects($this->atLeastOnce())
->method('getPlugin')
->willReturn($block_config[1] ? $main_content_block_plugin : ($block_config[2] ? $messages_block_plugin : ($block_config[3] ? $title_block_plugin : $block_plugin)));
diff --git a/core/modules/comment/src/Plugin/Menu/LocalTask/UnapprovedComments.php b/core/modules/comment/src/Plugin/Menu/LocalTask/UnapprovedComments.php
index 89542d34ff..e946bfb9f8 100644
--- a/core/modules/comment/src/Plugin/Menu/LocalTask/UnapprovedComments.php
+++ b/core/modules/comment/src/Plugin/Menu/LocalTask/UnapprovedComments.php
@@ -7,6 +7,7 @@
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;
+use Symfony\Component\HttpFoundation\Request;
/**
* Provides a local task that shows the amount of unapproved comments.
@@ -53,7 +54,7 @@ public static function create(ContainerInterface $container, array $configuratio
/**
* {@inheritdoc}
*/
- public function getTitle() {
+ public function getTitle(Request $request = NULL) {
return $this->t('Unapproved comments (@count)', ['@count' => $this->commentStorage->getUnapprovedCount()]);
}
diff --git a/core/modules/comment/src/Tests/Views/CommentTestBase.php b/core/modules/comment/src/Tests/Views/CommentTestBase.php
index 3d10858351..c364e2631f 100644
--- a/core/modules/comment/src/Tests/Views/CommentTestBase.php
+++ b/core/modules/comment/src/Tests/Views/CommentTestBase.php
@@ -63,8 +63,8 @@
*/
protected $comment;
- protected function setUp() {
- parent::setUp();
+ protected function setUp($import_test_views = TRUE) {
+ parent::setUp($import_test_views);
ViewTestData::createTestViews(get_class($this), ['comment_test_views']);
diff --git a/core/modules/comment/tests/src/Unit/CommentLinkBuilderTest.php b/core/modules/comment/tests/src/Unit/CommentLinkBuilderTest.php
index 8a0a0f5871..8aaae75609 100644
--- a/core/modules/comment/tests/src/Unit/CommentLinkBuilderTest.php
+++ b/core/modules/comment/tests/src/Unit/CommentLinkBuilderTest.php
@@ -269,7 +269,7 @@ public function getLinkCombinations() {
*/
protected function getMockNode($has_field, $comment_status, $form_location, $comment_count) {
$node = $this->getMock('\Drupal\node\NodeInterface');
- $node->expects($this->once())
+ $node->expects($this->any())
->method('hasField')
->willReturn($has_field);
diff --git a/core/modules/config_translation/src/Plugin/Menu/ContextualLink/ConfigTranslationContextualLink.php b/core/modules/config_translation/src/Plugin/Menu/ContextualLink/ConfigTranslationContextualLink.php
index 63145a5d3b..fff82f0c72 100644
--- a/core/modules/config_translation/src/Plugin/Menu/ContextualLink/ConfigTranslationContextualLink.php
+++ b/core/modules/config_translation/src/Plugin/Menu/ContextualLink/ConfigTranslationContextualLink.php
@@ -5,6 +5,7 @@
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Menu\ContextualLinkDefault;
use Drupal\Core\StringTranslation\StringTranslationTrait;
+use Symfony\Component\HttpFoundation\Request;
/**
* Defines a contextual link plugin with a dynamic title.
@@ -22,7 +23,7 @@ class ConfigTranslationContextualLink extends ContextualLinkDefault {
/**
* {@inheritdoc}
*/
- public function getTitle() {
+ public function getTitle(Request $request = NULL) {
// Use the custom 'config_translation_plugin_id' plugin definition key to
// retrieve the title. We need to retrieve a runtime title (as opposed to
// storing the title on the plugin definition for the link) because it
diff --git a/core/modules/config_translation/src/Plugin/Menu/LocalTask/ConfigTranslationLocalTask.php b/core/modules/config_translation/src/Plugin/Menu/LocalTask/ConfigTranslationLocalTask.php
index 5a88d91d0a..0aa84d2243 100644
--- a/core/modules/config_translation/src/Plugin/Menu/LocalTask/ConfigTranslationLocalTask.php
+++ b/core/modules/config_translation/src/Plugin/Menu/LocalTask/ConfigTranslationLocalTask.php
@@ -5,6 +5,7 @@
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Menu\LocalTaskDefault;
use Drupal\Core\StringTranslation\StringTranslationTrait;
+use Symfony\Component\HttpFoundation\Request;
/**
* Defines a local task plugin with a dynamic title.
@@ -22,7 +23,7 @@ class ConfigTranslationLocalTask extends LocalTaskDefault {
/**
* {@inheritdoc}
*/
- public function getTitle() {
+ public function getTitle(Request $request = NULL) {
// Take custom 'config_translation_plugin_id' plugin definition key to
// retrieve title. We need to retrieve a runtime title (as opposed to
// storing the title on the plugin definition for the link) because
diff --git a/core/modules/config_translation/tests/src/Functional/ConfigTranslationOverviewTest.php b/core/modules/config_translation/tests/src/Functional/ConfigTranslationOverviewTest.php
index dff6270245..9ccbb135d2 100644
--- a/core/modules/config_translation/tests/src/Functional/ConfigTranslationOverviewTest.php
+++ b/core/modules/config_translation/tests/src/Functional/ConfigTranslationOverviewTest.php
@@ -77,7 +77,7 @@ public function testMapperListPage() {
// Make sure there is only a single operation for each dropbutton, either
// 'List' or 'Translate'.
foreach ($this->cssSelect('ul.dropbutton') as $i => $dropbutton) {
- $this->assertIdentical(1, count($dropbutton->find('xpath', 'li')));
+ $this->assertIdentical(1, count($dropbutton->findAll('xpath', 'li')));
$this->assertTrue(($dropbutton->getText() === 'Translate') || ($dropbutton->getText() === 'List'));
}
@@ -103,7 +103,7 @@ public function testMapperListPage() {
// Make sure there is only a single 'Translate' operation for each
// dropbutton.
foreach ($this->cssSelect('ul.dropbutton') as $i => $dropbutton) {
- $this->assertIdentical(1, count($dropbutton->find('xpath', 'li')));
+ $this->assertIdentical(1, count($dropbutton->findAll('xpath', 'li')));
$this->assertIdentical('Translate', $dropbutton->getText());
}
diff --git a/core/modules/contact/tests/src/Unit/MailHandlerTest.php b/core/modules/contact/tests/src/Unit/MailHandlerTest.php
index 04a12b86df..a96b0c69e1 100644
--- a/core/modules/contact/tests/src/Unit/MailHandlerTest.php
+++ b/core/modules/contact/tests/src/Unit/MailHandlerTest.php
@@ -367,7 +367,7 @@ protected function getAuthenticatedMockMessage($copy_sender = FALSE) {
$recipient->expects($this->once())
->method('getEmail')
->willReturn('user2@drupal.org');
- $recipient->expects($this->once())
+ $recipient->expects($this->any())
->method('getDisplayName')
->willReturn('user2');
$recipient->expects($this->once())
diff --git a/core/modules/content_moderation/tests/src/Kernel/EntityStateChangeValidationTest.php b/core/modules/content_moderation/tests/src/Kernel/EntityStateChangeValidationTest.php
index 2fefc0148c..d72000b868 100644
--- a/core/modules/content_moderation/tests/src/Kernel/EntityStateChangeValidationTest.php
+++ b/core/modules/content_moderation/tests/src/Kernel/EntityStateChangeValidationTest.php
@@ -217,7 +217,7 @@ public function testInvalidStateMultilingual() {
/**
* Tests that content without prior moderation information can be moderated.
*/
- public function testLegacyContent() {
+ public function testExistingContentWithNoModeration() {
$node_type = NodeType::create([
'type' => 'example',
]);
@@ -251,7 +251,7 @@ public function testLegacyContent() {
/**
* Tests that content without prior moderation information can be translated.
*/
- public function testLegacyMultilingualContent() {
+ public function testExistingMultilingualContentWithNoModeration() {
// Enable French.
ConfigurableLanguage::createFromLangcode('fr')->save();
diff --git a/core/modules/datetime/src/DateTimeComputed.php b/core/modules/datetime/src/DateTimeComputed.php
index 2208ab7cb7..73fb117862 100644
--- a/core/modules/datetime/src/DateTimeComputed.php
+++ b/core/modules/datetime/src/DateTimeComputed.php
@@ -37,7 +37,7 @@ public function __construct(DataDefinitionInterface $definition, $name = NULL, T
/**
* {@inheritdoc}
*/
- public function getValue($langcode = NULL) {
+ public function getValue() {
if ($this->date !== NULL) {
return $this->date;
}
diff --git a/core/modules/datetime/src/Tests/Views/DateTimeHandlerTestBase.php b/core/modules/datetime/src/Tests/Views/DateTimeHandlerTestBase.php
index 0f068ab9ee..854352eb5b 100644
--- a/core/modules/datetime/src/Tests/Views/DateTimeHandlerTestBase.php
+++ b/core/modules/datetime/src/Tests/Views/DateTimeHandlerTestBase.php
@@ -43,8 +43,8 @@
/**
* {@inheritdoc}
*/
- protected function setUp() {
- parent::setUp();
+ protected function setUp($import_test_views = TRUE) {
+ parent::setUp($import_test_views);
// Add a date field to page nodes.
$node_type = NodeType::create([
diff --git a/core/modules/field/src/Tests/EntityReference/EntityReferenceAdminTest.php b/core/modules/field/src/Tests/EntityReference/EntityReferenceAdminTest.php
index 72a2160e22..08d4c6e5de 100644
--- a/core/modules/field/src/Tests/EntityReference/EntityReferenceAdminTest.php
+++ b/core/modules/field/src/Tests/EntityReference/EntityReferenceAdminTest.php
@@ -345,7 +345,7 @@ public function testFieldAdminHandler() {
$this->drupalPostForm(NULL, $edit, t('Save settings'));
// The term should now exist.
$term = taxonomy_term_load_multiple_by_name($term_name, 'tags')[1];
- $this->assertIdentical(1, count($term), 'Taxonomy term was auto created when set as field default.');
+ $this->assertNotNull($term, 'Taxonomy term was auto created when set as field default.');
}
/**
diff --git a/core/modules/field/src/Tests/Views/FieldTestBase.php b/core/modules/field/src/Tests/Views/FieldTestBase.php
index f04e19fb9b..c01e9604cf 100644
--- a/core/modules/field/src/Tests/Views/FieldTestBase.php
+++ b/core/modules/field/src/Tests/Views/FieldTestBase.php
@@ -42,8 +42,8 @@
*/
public $fields;
- protected function setUp() {
- parent::setUp();
+ protected function setUp($import_test_views = TRUE) {
+ parent::setUp($import_test_views);
// Ensure the page node type exists.
NodeType::create([
diff --git a/core/modules/field/src/Tests/Views/FieldUITest.php b/core/modules/field/src/Tests/Views/FieldUITest.php
index 851b7bdff9..efe768505b 100644
--- a/core/modules/field/src/Tests/Views/FieldUITest.php
+++ b/core/modules/field/src/Tests/Views/FieldUITest.php
@@ -38,8 +38,8 @@ class FieldUITest extends FieldTestBase {
/**
* {@inheritdoc}
*/
- protected function setUp() {
- parent::setUp();
+ protected function setUp($import_test_views = TRUE) {
+ parent::setUp($import_test_views);
$this->account = $this->drupalCreateUser(['administer views']);
$this->drupalLogin($this->account);
diff --git a/core/modules/field/src/Tests/Views/HandlerFieldFieldTest.php b/core/modules/field/src/Tests/Views/HandlerFieldFieldTest.php
index dfbb89bd20..da958e90f5 100644
--- a/core/modules/field/src/Tests/Views/HandlerFieldFieldTest.php
+++ b/core/modules/field/src/Tests/Views/HandlerFieldFieldTest.php
@@ -41,8 +41,8 @@ class HandlerFieldFieldTest extends FieldTestBase {
/**
* {@inheritdoc}
*/
- protected function setUp() {
- parent::setUp();
+ protected function setUp($import_test_views = TRUE) {
+ parent::setUp($import_test_views);
// Setup basic fields.
$this->setUpFieldStorages(3);
diff --git a/core/modules/file/src/Tests/Views/RelationshipUserFileDataTest.php b/core/modules/file/src/Tests/Views/RelationshipUserFileDataTest.php
index 6a5f53b5d3..45e016d169 100644
--- a/core/modules/file/src/Tests/Views/RelationshipUserFileDataTest.php
+++ b/core/modules/file/src/Tests/Views/RelationshipUserFileDataTest.php
@@ -30,8 +30,8 @@ class RelationshipUserFileDataTest extends ViewTestBase {
*/
public static $testViews = ['test_file_user_file_data'];
- protected function setUp() {
- parent::setUp();
+ protected function setUp($import_test_views = TRUE) {
+ parent::setUp($import_test_views);
// Create the user profile field and instance.
FieldStorageConfig::create([
diff --git a/core/modules/file/tests/src/Kernel/Migrate/process/d6/CckFileTest.php b/core/modules/file/tests/src/Kernel/Migrate/process/d6/CckFileTest.php
index e0e1934502..0ab8ba44fd 100644
--- a/core/modules/file/tests/src/Kernel/Migrate/process/d6/CckFileTest.php
+++ b/core/modules/file/tests/src/Kernel/Migrate/process/d6/CckFileTest.php
@@ -20,6 +20,7 @@ class CckFileTest extends MigrateDrupalTestBase {
* Tests configurability of file migration name.
*
* @covers ::__construct
+ * @expectedDeprecation CckFile is deprecated in Drupal 8.3.x and will be be removed before Drupal 9.0.x. Use \Drupal\file\Plugin\migrate\process\d6\FieldFile instead.
*/
public function testConfigurableFileMigration() {
$migration = Migration::create($this->container, [], 'custom_migration', []);
diff --git a/core/modules/file/tests/src/Unit/Plugin/migrate/process/d6/CckFileTest.php b/core/modules/file/tests/src/Unit/Plugin/migrate/process/d6/CckFileTest.php
index 5bad279c0d..8781ef11b4 100644
--- a/core/modules/file/tests/src/Unit/Plugin/migrate/process/d6/CckFileTest.php
+++ b/core/modules/file/tests/src/Unit/Plugin/migrate/process/d6/CckFileTest.php
@@ -17,6 +17,8 @@ class CckFileTest extends UnitTestCase {
/**
* Tests that alt and title attributes are included in transformed values.
+ *
+ * @expectedDeprecation CckFile is deprecated in Drupal 8.3.x and will be be removed before Drupal 9.0.x. Use \Drupal\file\Plugin\migrate\process\d6\FieldFile instead.
*/
public function testTransformAltTitle() {
$executable = $this->prophesize(MigrateExecutableInterface::class)->reveal();
diff --git a/core/modules/forum/src/Form/Overview.php b/core/modules/forum/src/Form/Overview.php
index a51446b173..efc9266418 100644
--- a/core/modules/forum/src/Form/Overview.php
+++ b/core/modules/forum/src/Form/Overview.php
@@ -8,6 +8,7 @@
use Drupal\Core\Url;
use Drupal\taxonomy\Form\OverviewTerms;
use Drupal\Core\Extension\ModuleHandlerInterface;
+use Drupal\taxonomy\VocabularyInterface;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
@@ -47,7 +48,7 @@ public function getFormId() {
/**
* {@inheritdoc}
*/
- public function buildForm(array $form, FormStateInterface $form_state) {
+ public function buildForm(array $form, FormStateInterface $form_state, VocabularyInterface $taxonomy_vocabulary = NULL) {
$forum_config = $this->config('forum.settings');
$vid = $forum_config->get('vocabulary');
$vocabulary = $this->entityManager->getStorage('taxonomy_vocabulary')->load($vid);
diff --git a/core/modules/image/src/Tests/Views/RelationshipUserImageDataTest.php b/core/modules/image/src/Tests/Views/RelationshipUserImageDataTest.php
index 55cecc0fc0..374981f63a 100644
--- a/core/modules/image/src/Tests/Views/RelationshipUserImageDataTest.php
+++ b/core/modules/image/src/Tests/Views/RelationshipUserImageDataTest.php
@@ -30,8 +30,8 @@ class RelationshipUserImageDataTest extends ViewTestBase {
*/
public static $testViews = ['test_image_user_image_data'];
- protected function setUp() {
- parent::setUp();
+ protected function setUp($import_test_views = TRUE) {
+ parent::setUp($import_test_views);
// Create the user profile field and instance.
FieldStorageConfig::create([
diff --git a/core/modules/layout_builder/src/Form/UpdateBlockForm.php b/core/modules/layout_builder/src/Form/UpdateBlockForm.php
index 2f2aa600e4..dfa33e04b6 100644
--- a/core/modules/layout_builder/src/Form/UpdateBlockForm.php
+++ b/core/modules/layout_builder/src/Form/UpdateBlockForm.php
@@ -39,7 +39,7 @@ public function getFormId() {
* @return array
* The form array.
*/
- public function buildForm(array $form, FormStateInterface $form_state, EntityInterface $entity = NULL, $delta = NULL, $region = NULL, $uuid = NULL) {
+ public function buildForm(array $form, FormStateInterface $form_state, EntityInterface $entity = NULL, $delta = NULL, $region = NULL, $uuid = NULL, array $configuration = []) {
/** @var \Drupal\layout_builder\Field\LayoutSectionItemInterface $field */
$field = $entity->layout_builder__layout->get($delta);
$block = $field->getSection()->getBlock($region, $uuid);
diff --git a/core/modules/link/src/Tests/Views/LinkViewsTokensTest.php b/core/modules/link/src/Tests/Views/LinkViewsTokensTest.php
index 80913ece8d..968c02f830 100644
--- a/core/modules/link/src/Tests/Views/LinkViewsTokensTest.php
+++ b/core/modules/link/src/Tests/Views/LinkViewsTokensTest.php
@@ -38,8 +38,8 @@ class LinkViewsTokensTest extends ViewTestBase {
/**
* {@inheritdoc}
*/
- protected function setUp() {
- parent::setUp();
+ protected function setUp($import_test_views = TRUE) {
+ parent::setUp($import_test_views);
ViewTestData::createTestViews(get_class($this), ['link_test_views']);
// Create Basic page node type.
diff --git a/core/modules/link/tests/src/Kernel/Plugin/migrate/cckfield/d7/LinkCckTest.php b/core/modules/link/tests/src/Kernel/Plugin/migrate/cckfield/d7/LinkCckTest.php
index 896c15c9fc..14345a60ef 100644
--- a/core/modules/link/tests/src/Kernel/Plugin/migrate/cckfield/d7/LinkCckTest.php
+++ b/core/modules/link/tests/src/Kernel/Plugin/migrate/cckfield/d7/LinkCckTest.php
@@ -53,6 +53,8 @@ protected function setUp() {
/**
* @covers ::processCckFieldValues
+ * @expectedDeprecation CckFieldPluginBase is deprecated in Drupal 8.3.x and will be be removed before Drupal 9.0.x. Use \Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase instead.
+ * @expectedDeprecation MigrateCckFieldInterface is deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.x. Use \Drupal\migrate_drupal\Annotation\MigrateField instead.
*/
public function testProcessCckFieldValues() {
$this->plugin->processFieldInstance($this->migration);
diff --git a/core/modules/link/tests/src/Unit/Plugin/migrate/cckfield/LinkCckTest.php b/core/modules/link/tests/src/Unit/Plugin/migrate/cckfield/LinkCckTest.php
index 7029d72412..dc3fe7731e 100644
--- a/core/modules/link/tests/src/Unit/Plugin/migrate/cckfield/LinkCckTest.php
+++ b/core/modules/link/tests/src/Unit/Plugin/migrate/cckfield/LinkCckTest.php
@@ -46,6 +46,8 @@ protected function setUp() {
/**
* @covers ::processCckFieldValues
+ * @expectedDeprecation CckFieldPluginBase is deprecated in Drupal 8.3.x and will be be removed before Drupal 9.0.x. Use \Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase instead.
+ * @expectedDeprecation MigrateCckFieldInterface is deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.x. Use \Drupal\migrate_drupal\Annotation\MigrateField instead.
*/
public function testProcessCckFieldValues() {
$this->plugin->processCckFieldValues($this->migration, 'somefieldname', []);
diff --git a/core/modules/migrate/src/Plugin/migrate/source/EmbeddedDataSource.php b/core/modules/migrate/src/Plugin/migrate/source/EmbeddedDataSource.php
index 8cee6ddbe4..11f32cf563 100644
--- a/core/modules/migrate/src/Plugin/migrate/source/EmbeddedDataSource.php
+++ b/core/modules/migrate/src/Plugin/migrate/source/EmbeddedDataSource.php
@@ -108,7 +108,7 @@ public function getIds() {
/**
* {@inheritdoc}
*/
- public function count() {
+ public function count($refresh = FALSE) {
return count($this->dataRows);
}
diff --git a/core/modules/migrate/src/Plugin/migrate/source/EmptySource.php b/core/modules/migrate/src/Plugin/migrate/source/EmptySource.php
index 5f44035e25..09f8a95792 100644
--- a/core/modules/migrate/src/Plugin/migrate/source/EmptySource.php
+++ b/core/modules/migrate/src/Plugin/migrate/source/EmptySource.php
@@ -58,7 +58,7 @@ public function getIds() {
/**
* {@inheritdoc}
*/
- public function count() {
+ public function count($refresh = FALSE) {
return 1;
}
diff --git a/core/modules/migrate/tests/src/Kernel/process/DownloadTest.php b/core/modules/migrate/tests/src/Kernel/process/DownloadTest.php
index 576539eb3f..ee56e32c52 100644
--- a/core/modules/migrate/tests/src/Kernel/process/DownloadTest.php
+++ b/core/modules/migrate/tests/src/Kernel/process/DownloadTest.php
@@ -9,7 +9,6 @@
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\Row;
use GuzzleHttp\Client;
-use GuzzleHttp\Psr7\Response;
/**
* Tests the download process plugin.
@@ -100,14 +99,8 @@ public function testWriteProtectedDestination() {
* The local URI of the downloaded file.
*/
protected function doTransform($destination_uri, $configuration = []) {
- // The HTTP client will return a file with contents 'It worked!'
- $body = fopen('data://text/plain;base64,SXQgd29ya2VkIQ==', 'r');
-
// Prepare a mock HTTP client.
$this->container->set('http_client', $this->getMock(Client::class));
- $this->container->get('http_client')
- ->method('get')
- ->willReturn(new Response(200, [], $body));
// Instantiate the plugin statically so it can pull dependencies out of
// the container.
diff --git a/core/modules/migrate/tests/src/Unit/MigrateTestCase.php b/core/modules/migrate/tests/src/Unit/MigrateTestCase.php
index 20d7662d29..558cecb94a 100644
--- a/core/modules/migrate/tests/src/Unit/MigrateTestCase.php
+++ b/core/modules/migrate/tests/src/Unit/MigrateTestCase.php
@@ -78,11 +78,6 @@ protected function getMigration() {
$configuration = &$this->migrationConfiguration;
- $migration->method('getHighWaterProperty')
- ->willReturnCallback(function () use ($configuration) {
- return isset($configuration['high_water_property']) ? $configuration['high_water_property'] : '';
- });
-
$migration->method('set')
->willReturnCallback(function ($argument, $value) use (&$configuration) {
$configuration[$argument] = $value;
diff --git a/core/modules/statistics/src/Tests/Views/IntegrationTest.php b/core/modules/statistics/src/Tests/Views/IntegrationTest.php
index 18f5581587..740ecf5e53 100644
--- a/core/modules/statistics/src/Tests/Views/IntegrationTest.php
+++ b/core/modules/statistics/src/Tests/Views/IntegrationTest.php
@@ -42,8 +42,8 @@ class IntegrationTest extends ViewTestBase {
*/
public static $testViews = ['test_statistics_integration'];
- protected function setUp() {
- parent::setUp();
+ protected function setUp($import_test_views = TRUE) {
+ parent::setUp($import_test_views);
ViewTestData::createTestViews(get_class($this), ['statistics_test_views']);
diff --git a/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/ContextualLink/TestContextualLink.php b/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/ContextualLink/TestContextualLink.php
index 271922936e..8257d32232 100644
--- a/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/ContextualLink/TestContextualLink.php
+++ b/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/ContextualLink/TestContextualLink.php
@@ -3,6 +3,7 @@
namespace Drupal\menu_test\Plugin\Menu\ContextualLink;
use Drupal\Core\Menu\ContextualLinkDefault;
+use Symfony\Component\HttpFoundation\Request;
/**
* Defines a contextual link plugin with a dynamic title from user input.
@@ -12,7 +13,7 @@ class TestContextualLink extends ContextualLinkDefault {
/**
* {@inheritdoc}
*/
- public function getTitle() {
+ public function getTitle(Request $request = NULL) {
return "";
}
diff --git a/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalAction/TestLocalAction.php b/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalAction/TestLocalAction.php
index 4b9289eef1..13f2e5a023 100644
--- a/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalAction/TestLocalAction.php
+++ b/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalAction/TestLocalAction.php
@@ -3,6 +3,7 @@
namespace Drupal\menu_test\Plugin\Menu\LocalAction;
use Drupal\Core\Menu\LocalActionDefault;
+use Symfony\Component\HttpFoundation\Request;
/**
* Defines a test local action plugin class.
@@ -12,7 +13,7 @@ class TestLocalAction extends LocalActionDefault {
/**
* {@inheritdoc}
*/
- public function getTitle() {
+ public function getTitle(Request $request = NULL) {
return 'Title override';
}
diff --git a/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalAction/TestLocalAction4.php b/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalAction/TestLocalAction4.php
index 1f8300a4ba..eb8b1893c5 100644
--- a/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalAction/TestLocalAction4.php
+++ b/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalAction/TestLocalAction4.php
@@ -4,6 +4,7 @@
use Drupal\Core\Menu\LocalActionDefault;
use Drupal\Core\StringTranslation\StringTranslationTrait;
+use Symfony\Component\HttpFoundation\Request;
/**
* Defines a local action plugin with a dynamic title.
@@ -15,7 +16,7 @@ class TestLocalAction4 extends LocalActionDefault {
/**
* {@inheritdoc}
*/
- public function getTitle() {
+ public function getTitle(Request $request = NULL) {
return $this->t('My @arg action', ['@arg' => 'dynamic-title']);
}
diff --git a/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalAction/TestLocalAction5.php b/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalAction/TestLocalAction5.php
index 0bd7fc3875..e960e26613 100644
--- a/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalAction/TestLocalAction5.php
+++ b/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalAction/TestLocalAction5.php
@@ -3,6 +3,7 @@
namespace Drupal\menu_test\Plugin\Menu\LocalAction;
use Drupal\Core\Menu\LocalActionDefault;
+use Symfony\Component\HttpFoundation\Request;
/**
* Defines a local action plugin with a dynamic title from user input.
@@ -12,7 +13,7 @@ class TestLocalAction5 extends LocalActionDefault {
/**
* {@inheritdoc}
*/
- public function getTitle() {
+ public function getTitle(Request $request = NULL) {
return "";
}
diff --git a/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalAction/TestLocalActionWithConfig.php b/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalAction/TestLocalActionWithConfig.php
index 54a2f42246..4f56977e86 100644
--- a/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalAction/TestLocalActionWithConfig.php
+++ b/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalAction/TestLocalActionWithConfig.php
@@ -6,6 +6,7 @@
use Drupal\Core\Menu\LocalActionDefault;
use Drupal\Core\Routing\RouteProviderInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
+use Symfony\Component\HttpFoundation\Request;
/**
* Defines a test local action plugin class.
@@ -20,7 +21,7 @@ class TestLocalActionWithConfig extends LocalActionDefault {
/**
* {@inheritdoc}
*/
- public function getTitle() {
+ public function getTitle(Request $request = NULL) {
return $this->config->get('title');
}
diff --git a/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalTask/TestTasksSettingsSub1.php b/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalTask/TestTasksSettingsSub1.php
index 7ba7548846..61ac9705a0 100644
--- a/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalTask/TestTasksSettingsSub1.php
+++ b/core/modules/system/tests/modules/menu_test/src/Plugin/Menu/LocalTask/TestTasksSettingsSub1.php
@@ -4,6 +4,7 @@
use Drupal\Core\Menu\LocalTaskDefault;
use Drupal\Core\StringTranslation\StringTranslationTrait;
+use Symfony\Component\HttpFoundation\Request;
class TestTasksSettingsSub1 extends LocalTaskDefault {
@@ -12,7 +13,7 @@ class TestTasksSettingsSub1 extends LocalTaskDefault {
/**
* {@inheritdoc}
*/
- public function getTitle() {
+ public function getTitle(Request $request = NULL) {
return $this->t('Dynamic title for @class', ['@class' => 'TestTasksSettingsSub1']);
}
diff --git a/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php b/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php
index 2fe4a8335d..a24313f4af 100644
--- a/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php
+++ b/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php
@@ -134,8 +134,6 @@ protected function setUp() {
->disableOriginalConstructor()
->getMock();
$cache_contexts_manager->method('assertValidTokens')->willReturn(TRUE);
- $cache_contexts_manager->expects($this->any())
- ->method('validate_tokens');
$container = new Container();
$container->set('cache_contexts_manager', $cache_contexts_manager);
\Drupal::setContainer($container);
diff --git a/core/modules/taxonomy/tests/src/Functional/LegacyTest.php b/core/modules/taxonomy/tests/src/Functional/EarlyDateTest.php
similarity index 95%
rename from core/modules/taxonomy/tests/src/Functional/LegacyTest.php
rename to core/modules/taxonomy/tests/src/Functional/EarlyDateTest.php
index 667ed5542f..e4490f3431 100644
--- a/core/modules/taxonomy/tests/src/Functional/LegacyTest.php
+++ b/core/modules/taxonomy/tests/src/Functional/EarlyDateTest.php
@@ -11,7 +11,7 @@
*
* @group taxonomy
*/
-class LegacyTest extends TaxonomyTestBase {
+class EarlyDateTest extends TaxonomyTestBase {
/**
* Modules to enable.
@@ -51,7 +51,7 @@ protected function setUp() {
/**
* Test taxonomy functionality with nodes prior to 1970.
*/
- public function testTaxonomyLegacyNode() {
+ public function testTaxonomyEarlyDateNode() {
// Posts an article with a taxonomy term and a date prior to 1970.
$date = new DrupalDateTime('1969-01-01 00:00:00');
$edit = [];
diff --git a/core/modules/tour/src/Tests/TourTestBase.php b/core/modules/tour/src/Tests/TourTestBase.php
index e139650706..f551c8151b 100644
--- a/core/modules/tour/src/Tests/TourTestBase.php
+++ b/core/modules/tour/src/Tests/TourTestBase.php
@@ -14,6 +14,17 @@
*/
abstract class TourTestBase extends WebTestBase {
+ /**
+ * {@inheritdoc}
+ */
+ protected function setUp() {
+ // Support both PHPUnit 4 and 6.
+ if (!class_exists('\PHPUnit_Util_XML') && class_exists('\PHPUnit\Util\XML')) {
+ class_alias('\PHPUnit\Util\XML', '\PHPUnit_Util_XML');
+ }
+ parent::setUp();
+ }
+
/**
* Assert function to determine if tips rendered to the page
* have a corresponding page element.
diff --git a/core/modules/tour/tests/src/Functional/TourTestBase.php b/core/modules/tour/tests/src/Functional/TourTestBase.php
index 522e8e6f36..a8487def61 100644
--- a/core/modules/tour/tests/src/Functional/TourTestBase.php
+++ b/core/modules/tour/tests/src/Functional/TourTestBase.php
@@ -50,14 +50,13 @@ public function assertTourTips($tips = []) {
// Check for corresponding page elements.
$total = 0;
$modals = 0;
- $raw_content = $this->getSession()->getPage()->getContent();
foreach ($tips as $tip) {
if (!empty($tip['data-id'])) {
- $elements = \PHPUnit_Util_XML::cssSelect('#' . $tip['data-id'], TRUE, $raw_content, TRUE);
+ $elements = $this->getSession()->getPage()->findAll('css', '#' . $tip['data-id']);
$this->assertTrue(!empty($elements) && count($elements) === 1, format_string('Found corresponding page element for tour tip with id #%data-id', ['%data-id' => $tip['data-id']]));
}
elseif (!empty($tip['data-class'])) {
- $elements = \PHPUnit_Util_XML::cssSelect('.' . $tip['data-class'], TRUE, $raw_content, TRUE);
+ $elements = $this->getSession()->getPage()->findAll('css', '.' . $tip['data-class']);
$this->assertFalse(empty($elements), format_string('Found corresponding page element for tour tip with class .%data-class', ['%data-class' => $tip['data-class']]));
}
else {
diff --git a/core/modules/tracker/src/Tests/Views/TrackerTestBase.php b/core/modules/tracker/src/Tests/Views/TrackerTestBase.php
index 9746a22a51..4dfaab03bc 100644
--- a/core/modules/tracker/src/Tests/Views/TrackerTestBase.php
+++ b/core/modules/tracker/src/Tests/Views/TrackerTestBase.php
@@ -41,8 +41,8 @@
*/
protected $comment;
- protected function setUp() {
- parent::setUp();
+ protected function setUp($import_test_views = TRUE) {
+ parent::setUp($import_test_views);
ViewTestData::createTestViews(get_class($this), ['tracker_test_views']);
diff --git a/core/modules/views/src/Tests/FieldApiDataTest.php b/core/modules/views/src/Tests/FieldApiDataTest.php
index f6d5159dd8..d2d035cfcc 100644
--- a/core/modules/views/src/Tests/FieldApiDataTest.php
+++ b/core/modules/views/src/Tests/FieldApiDataTest.php
@@ -35,8 +35,8 @@ class FieldApiDataTest extends FieldTestBase {
*/
protected $translationNodes;
- protected function setUp() {
- parent::setUp(FALSE);
+ protected function setUp($import_test_views = TRUE) {
+ parent::setUp($import_test_views);
$field_names = $this->setUpFieldStorages(4);
diff --git a/core/modules/views/src/Tests/Plugin/DisplayFeedTest.php b/core/modules/views/src/Tests/Plugin/DisplayFeedTest.php
index e8d2549176..04ba4cab99 100644
--- a/core/modules/views/src/Tests/Plugin/DisplayFeedTest.php
+++ b/core/modules/views/src/Tests/Plugin/DisplayFeedTest.php
@@ -26,8 +26,8 @@ class DisplayFeedTest extends PluginTestBase {
*/
public static $modules = ['block', 'node', 'views'];
- protected function setUp() {
- parent::setUp();
+ protected function setUp($import_test_views = TRUE) {
+ parent::setUp($import_test_views);
$this->enableViewsTestModule();
diff --git a/core/modules/views/src/Tests/Plugin/StyleOpmlTest.php b/core/modules/views/src/Tests/Plugin/StyleOpmlTest.php
index 4e84433dca..66a8bc826b 100644
--- a/core/modules/views/src/Tests/Plugin/StyleOpmlTest.php
+++ b/core/modules/views/src/Tests/Plugin/StyleOpmlTest.php
@@ -27,8 +27,8 @@ class StyleOpmlTest extends PluginTestBase {
/**
* {@inheritdoc}
*/
- protected function setUp() {
- parent::setUp();
+ protected function setUp($import_test_views = TRUE) {
+ parent::setUp($import_test_views);
$this->enableViewsTestModule();
diff --git a/core/modules/views/src/Tests/ViewAjaxTest.php b/core/modules/views/src/Tests/ViewAjaxTest.php
index 5a966a8f76..820d9e2bc0 100644
--- a/core/modules/views/src/Tests/ViewAjaxTest.php
+++ b/core/modules/views/src/Tests/ViewAjaxTest.php
@@ -19,8 +19,8 @@ class ViewAjaxTest extends ViewTestBase {
*/
public static $testViews = ['test_ajax_view', 'test_view'];
- protected function setUp() {
- parent::setUp();
+ protected function setUp($import_test_views = TRUE) {
+ parent::setUp($import_test_views);
$this->enableViewsTestModule();
}
diff --git a/core/modules/views/src/Tests/Wizard/WizardTestBase.php b/core/modules/views/src/Tests/Wizard/WizardTestBase.php
index ba7509c865..29b96d38c1 100644
--- a/core/modules/views/src/Tests/Wizard/WizardTestBase.php
+++ b/core/modules/views/src/Tests/Wizard/WizardTestBase.php
@@ -21,8 +21,8 @@
*/
public static $modules = ['node', 'views_ui', 'block', 'rest'];
- protected function setUp() {
- parent::setUp();
+ protected function setUp($import_test_views = TRUE) {
+ parent::setUp($import_test_views);
// Create and log in a user with administer views permission.
$views_admin = $this->drupalCreateUser(['administer views', 'administer blocks', 'bypass node access', 'access user profiles', 'view all revisions']);
diff --git a/core/modules/views/tests/src/Functional/Update/LegacyBulkFormUpdateTest.php b/core/modules/views/tests/src/Functional/Update/BulkFormUpdateTest.php
similarity index 94%
rename from core/modules/views/tests/src/Functional/Update/LegacyBulkFormUpdateTest.php
rename to core/modules/views/tests/src/Functional/Update/BulkFormUpdateTest.php
index 75e2b54b65..5db54d2c67 100644
--- a/core/modules/views/tests/src/Functional/Update/LegacyBulkFormUpdateTest.php
+++ b/core/modules/views/tests/src/Functional/Update/BulkFormUpdateTest.php
@@ -10,7 +10,7 @@
*
* @group views
*/
-class LegacyBulkFormUpdateTest extends UpdatePathTestBase {
+class BulkFormUpdateTest extends UpdatePathTestBase {
/**
* {@inheritdoc}
diff --git a/core/modules/views/tests/src/Unit/Plugin/Block/ViewsBlockTest.php b/core/modules/views/tests/src/Unit/Plugin/Block/ViewsBlockTest.php
index 9323b04438..f9bd6d2f1b 100644
--- a/core/modules/views/tests/src/Unit/Plugin/Block/ViewsBlockTest.php
+++ b/core/modules/views/tests/src/Unit/Plugin/Block/ViewsBlockTest.php
@@ -70,7 +70,7 @@ protected function setUp() {
$this->executable = $this->getMockBuilder('Drupal\views\ViewExecutable')
->disableOriginalConstructor()
- ->setMethods(['buildRenderable', 'setDisplay', 'setItemsPerPage'])
+ ->setMethods(['buildRenderable', 'setDisplay', 'setItemsPerPage', 'getShowAdminLinks'])
->getMock();
$this->executable->expects($this->any())
->method('setDisplay')
diff --git a/core/modules/views_ui/src/Tests/UITestBase.php b/core/modules/views_ui/src/Tests/UITestBase.php
index 83f2f85980..752be6e339 100644
--- a/core/modules/views_ui/src/Tests/UITestBase.php
+++ b/core/modules/views_ui/src/Tests/UITestBase.php
@@ -36,8 +36,8 @@
/**
* {@inheritdoc}
*/
- protected function setUp() {
- parent::setUp();
+ protected function setUp($import_test_views = TRUE) {
+ parent::setUp($import_test_views);
$this->enableViewsTestModule();
diff --git a/core/phpunit.xml.dist b/core/phpunit.xml.dist
index 750c6e2b50..ed3216d369 100644
--- a/core/phpunit.xml.dist
+++ b/core/phpunit.xml.dist
@@ -30,7 +30,7 @@
-
+
diff --git a/core/scripts/run-tests.sh b/core/scripts/run-tests.sh
index 5ebf9f0c9f..e545318b87 100755
--- a/core/scripts/run-tests.sh
+++ b/core/scripts/run-tests.sh
@@ -793,7 +793,11 @@ function simpletest_script_run_one_test($test_id, $test_class) {
putenv('SYMFONY_DEPRECATIONS_HELPER=disabled');
}
else {
- putenv('SYMFONY_DEPRECATIONS_HELPER=strict');
+ // Prevent deprecations caused by vendor code calling deprecated code.
+ // This also prevents PHPUnit 6's mock code that triggers silenced
+ // deprecations from breaking the test suite. We should consider changing
+ // this to 'strict' once we are no longer use PHPUnit 4.
+ putenv('SYMFONY_DEPRECATIONS_HELPER=weak_vendors');
}
if (is_subclass_of($test_class, TestCase::class)) {
$status = simpletest_script_run_phpunit($test_id, $test_class);
diff --git a/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
index 95ee39fd3a..38e610c3b5 100644
--- a/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
+++ b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
@@ -188,7 +188,7 @@ public function testInvalidLinkNotExistsExact() {
/**
* Tests legacy text asserts.
*/
- public function testLegacyTextAsserts() {
+ public function testTextAsserts() {
$this->drupalGet('test-encoded');
$dangerous = 'Bad html ';
$sanitized = Html::escape($dangerous);
@@ -202,7 +202,7 @@ public function testLegacyTextAsserts() {
/**
* Tests legacy field asserts which use xpath directly.
*/
- public function testLegacyXpathAsserts() {
+ public function testXpathAsserts() {
$this->drupalGet('test-field-xpath');
$this->assertFieldsByValue($this->xpath("//h1[@class = 'page-title']"), NULL);
$this->assertFieldsByValue($this->xpath('//table/tbody/tr[2]/td[1]'), 'one');
@@ -245,7 +245,7 @@ public function testLegacyXpathAsserts() {
/**
* Tests legacy field asserts using textfields.
*/
- public function testLegacyFieldAssertsForTextfields() {
+ public function testFieldAssertsForTextfields() {
$this->drupalGet('test-field-xpath');
// *** 1. assertNoField().
@@ -387,7 +387,7 @@ public function testLegacyFieldAssertsForTextfields() {
/**
* Tests legacy field asserts for options field type.
*/
- public function testLegacyFieldAssertsForOptions() {
+ public function testFieldAssertsForOptions() {
$this->drupalGet('test-field-xpath');
// Option field type.
@@ -443,7 +443,7 @@ public function testLegacyFieldAssertsForOptions() {
/**
* Tests legacy field asserts for button field type.
*/
- public function testLegacyFieldAssertsForButton() {
+ public function testFieldAssertsForButton() {
$this->drupalGet('test-field-xpath');
$this->assertFieldById('edit-save', NULL);
@@ -485,7 +485,7 @@ public function testLegacyFieldAssertsForButton() {
/**
* Tests legacy field asserts for checkbox field type.
*/
- public function testLegacyFieldAssertsForCheckbox() {
+ public function testFieldAssertsForCheckbox() {
$this->drupalGet('test-field-xpath');
// Part 1 - Test by name.
diff --git a/core/tests/Drupal/Tests/BrowserTestBase.php b/core/tests/Drupal/Tests/BrowserTestBase.php
index 93df3dbf13..d1ab0a1ec2 100644
--- a/core/tests/Drupal/Tests/BrowserTestBase.php
+++ b/core/tests/Drupal/Tests/BrowserTestBase.php
@@ -497,6 +497,11 @@ protected function setUp() {
if ($disable_gc) {
gc_enable();
}
+
+ // Ensure that the test is not marked as risky because of no assertions. In
+ // PHPIUnit 6 tests that only make assertions using $this->assertSession()
+ // can be marked as risky.
+ $this->addToAssertionCount(1);
}
/**
diff --git a/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php b/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php
index 297125bf63..b89d351c75 100644
--- a/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php
+++ b/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php
@@ -87,7 +87,13 @@ public function testDateDiff($input1, $input2, $absolute, \DateInterval $expecte
* @dataProvider providerTestInvalidDateDiff
*/
public function testInvalidDateDiff($input1, $input2, $absolute) {
- $this->setExpectedException(\BadMethodCallException::class, 'Method Drupal\Component\Datetime\DateTimePlus::diff expects parameter 1 to be a \DateTime or \Drupal\Component\Datetime\DateTimePlus object');
+ if (method_exists($this, 'expectException')) {
+ $this->expectException(\BadMethodCallException::class);
+ $this->expectExceptionMessage('Method Drupal\Component\Datetime\DateTimePlus::diff expects parameter 1 to be a \DateTime or \Drupal\Component\Datetime\DateTimePlus object');
+ }
+ else {
+ $this->setExpectedException(\BadMethodCallException::class, 'Method Drupal\Component\Datetime\DateTimePlus::diff expects parameter 1 to be a \DateTime or \Drupal\Component\Datetime\DateTimePlus object');
+ }
$interval = $input1->diff($input2, $absolute);
}
@@ -104,7 +110,12 @@ public function testInvalidDateDiff($input1, $input2, $absolute) {
* @dataProvider providerTestInvalidDateArrays
*/
public function testInvalidDateArrays($input, $timezone, $class) {
- $this->setExpectedException($class);
+ if (method_exists($this, 'expectException')) {
+ $this->expectException($class);
+ }
+ else {
+ $this->setExpectedException($class);
+ }
$this->assertInstanceOf(
'\Drupal\Component\DateTimePlus',
DateTimePlus::createFromArray($input, $timezone)
@@ -242,7 +253,12 @@ public function testDateFormat($input, $timezone, $format, $format_date, $expect
* @dataProvider providerTestInvalidDates
*/
public function testInvalidDates($input, $timezone, $format, $message, $class) {
- $this->setExpectedException($class);
+ if (method_exists($this, 'expectException')) {
+ $this->expectException($class);
+ }
+ else {
+ $this->setExpectedException($class);
+ }
DateTimePlus::createFromFormat($format, $input, $timezone);
}
@@ -800,7 +816,12 @@ public function testValidateFormat() {
// Parse the same date with ['validate_format' => TRUE] and make sure we
// get the expected exception.
- $this->setExpectedException(\UnexpectedValueException::class);
+ if (method_exists($this, 'expectException')) {
+ $this->expectException(\UnexpectedValueException::class);
+ }
+ else {
+ $this->setExpectedException(\UnexpectedValueException::class);
+ }
$date = DateTimePlus::createFromFormat('Y-m-d H:i:s', '11-03-31 17:44:00', 'UTC', ['validate_format' => TRUE]);
}
@@ -859,7 +880,13 @@ public function testChainableNonChainable() {
* @covers ::__call
*/
public function testChainableNonCallable() {
- $this->setExpectedException(\BadMethodCallException::class, 'Call to undefined method Drupal\Component\Datetime\DateTimePlus::nonexistent()');
+ if (method_exists($this, 'expectException')) {
+ $this->expectException(\BadMethodCallException::class);
+ $this->expectExceptionMessage('Call to undefined method Drupal\Component\Datetime\DateTimePlus::nonexistent()');
+ }
+ else {
+ $this->setExpectedException(\BadMethodCallException::class, 'Call to undefined method Drupal\Component\Datetime\DateTimePlus::nonexistent()');
+ }
$date = new DateTimePlus('now', 'Australia/Sydney');
$date->setTimezone(new \DateTimeZone('America/New_York'))->nonexistent();
}
diff --git a/core/tests/Drupal/Tests/Component/Datetime/TimeTest.php b/core/tests/Drupal/Tests/Component/Datetime/TimeTest.php
index 4a5fa80205..29c27b23c7 100644
--- a/core/tests/Drupal/Tests/Component/Datetime/TimeTest.php
+++ b/core/tests/Drupal/Tests/Component/Datetime/TimeTest.php
@@ -37,7 +37,12 @@ class TimeTest extends TestCase {
protected function setUp() {
parent::setUp();
- $this->requestStack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack');
+ if (method_exists($this, 'createMock')) {
+ $this->requestStack = $this->createMock('Symfony\Component\HttpFoundation\RequestStack');
+ }
+ else {
+ $this->requestStack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack');
+ }
$this->time = new Time($this->requestStack);
}
diff --git a/core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php b/core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php
index 0e6a1472cd..1e2fbfec8b 100644
--- a/core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php
+++ b/core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php
@@ -983,6 +983,28 @@ protected function getCollection($collection, $resolve = TRUE) {
];
}
+ /**
+ * Compatibility layer for PHPUnit 6 to support PHPUnit 4 code.
+ *
+ * @param mixed $class
+ * @param string $message
+ * @param int $exception_code
+ */
+ public function setExpectedException($class, $message = '', $exception_code = NULL) {
+ if (method_exists($this, 'expectException')) {
+ $this->expectException($class);
+ if (!empty($message)) {
+ $this->expectExceptionMessage($message);
+ }
+ if ($exception_code !== NULL) {
+ $this->expectExceptionCode($exception_code);
+ }
+ }
+ else {
+ parent::setExpectedException($class, $message, $exception_code);
+ }
+ }
+
}
/**
diff --git a/core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumperTest.php b/core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumperTest.php
index 3c44752748..c1b70954d1 100644
--- a/core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumperTest.php
+++ b/core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumperTest.php
@@ -545,7 +545,12 @@ public function testGetServiceDefinitionForDecoratedService() {
$services['bar'] = $bar_definition;
$this->containerBuilder->getDefinitions()->willReturn($services);
- $this->setExpectedException(InvalidArgumentException::class);
+ if (method_exists($this, 'expectException')) {
+ $this->expectException(InvalidArgumentException::class);
+ }
+ else {
+ $this->setExpectedException(InvalidArgumentException::class);
+ }
$this->dumper->getArray();
}
@@ -562,7 +567,12 @@ public function testGetServiceDefinitionForExpression() {
$services['bar'] = $bar_definition;
$this->containerBuilder->getDefinitions()->willReturn($services);
- $this->setExpectedException(RuntimeException::class);
+ if (method_exists($this, 'expectException')) {
+ $this->expectException(RuntimeException::class);
+ }
+ else {
+ $this->setExpectedException(RuntimeException::class);
+ }
$this->dumper->getArray();
}
@@ -579,7 +589,12 @@ public function testGetServiceDefinitionForObject() {
$services['bar'] = $bar_definition;
$this->containerBuilder->getDefinitions()->willReturn($services);
- $this->setExpectedException(RuntimeException::class);
+ if (method_exists($this, 'expectException')) {
+ $this->expectException(RuntimeException::class);
+ }
+ else {
+ $this->setExpectedException(RuntimeException::class);
+ }
$this->dumper->getArray();
}
@@ -596,7 +611,12 @@ public function testGetServiceDefinitionForResource() {
$services['bar'] = $bar_definition;
$this->containerBuilder->getDefinitions()->willReturn($services);
- $this->setExpectedException(RuntimeException::class);
+ if (method_exists($this, 'expectException')) {
+ $this->expectException(RuntimeException::class);
+ }
+ else {
+ $this->setExpectedException(RuntimeException::class);
+ }
$this->dumper->getArray();
}
diff --git a/core/tests/Drupal/Tests/Component/Diff/Engine/DiffOpTest.php b/core/tests/Drupal/Tests/Component/Diff/Engine/DiffOpTest.php
index 1a649ae510..dbbb6ec081 100644
--- a/core/tests/Drupal/Tests/Component/Diff/Engine/DiffOpTest.php
+++ b/core/tests/Drupal/Tests/Component/Diff/Engine/DiffOpTest.php
@@ -4,6 +4,7 @@
use Drupal\Component\Diff\Engine\DiffOp;
use PHPUnit\Framework\TestCase;
+use PHPUnit\Framework\Error\Error;
/**
* Test DiffOp base class.
@@ -24,7 +25,12 @@ class DiffOpTest extends TestCase {
* @covers ::reverse
*/
public function testReverse() {
- $this->setExpectedException(\PHPUnit_Framework_Error::class);
+ if (method_exists($this, 'expectException')) {
+ $this->expectException(Error::class);
+ }
+ else {
+ $this->setExpectedException(\PHPUnit_Framework_Error::class);
+ }
$op = new DiffOp();
$result = $op->reverse();
}
diff --git a/core/tests/Drupal/Tests/Component/Discovery/YamlDirectoryDiscoveryTest.php b/core/tests/Drupal/Tests/Component/Discovery/YamlDirectoryDiscoveryTest.php
index 86134a7bdf..9ac807d744 100644
--- a/core/tests/Drupal/Tests/Component/Discovery/YamlDirectoryDiscoveryTest.php
+++ b/core/tests/Drupal/Tests/Component/Discovery/YamlDirectoryDiscoveryTest.php
@@ -124,7 +124,13 @@ public function testDiscoveryAlternateId() {
* @covers ::getIdentifier
*/
public function testDiscoveryNoIdException() {
- $this->setExpectedException(DiscoveryException::class, 'The vfs://modules/test_1/item_1.test.yml contains no data in the identifier key \'id\'');
+ if (method_exists($this, 'expectException')) {
+ $this->expectException(DiscoveryException::class);
+ $this->expectExceptionMessage('The vfs://modules/test_1/item_1.test.yml contains no data in the identifier key \'id\'');
+ }
+ else {
+ $this->setExpectedException(DiscoveryException::class, 'The vfs://modules/test_1/item_1.test.yml contains no data in the identifier key \'id\'');
+ }
vfsStream::setup('modules', NULL, [
'test_1' => [
'item_1.test.yml' => "",
@@ -144,7 +150,13 @@ public function testDiscoveryNoIdException() {
* @covers ::findAll
*/
public function testDiscoveryInvalidYamlException() {
- $this->setExpectedException(DiscoveryException::class, 'The vfs://modules/test_1/item_1.test.yml contains invalid YAML');
+ if (method_exists($this, 'expectException')) {
+ $this->expectException(DiscoveryException::class);
+ $this->expectExceptionMessage('The vfs://modules/test_1/item_1.test.yml contains invalid YAML');
+ }
+ else {
+ $this->setExpectedException(DiscoveryException::class, 'The vfs://modules/test_1/item_1.test.yml contains invalid YAML');
+ }
vfsStream::setup('modules', NULL, [
'test_1' => [
'item_1.test.yml' => "id: invalid\nfoo : [bar}",
diff --git a/core/tests/Drupal/Tests/Component/EventDispatcher/ContainerAwareEventDispatcherTest.php b/core/tests/Drupal/Tests/Component/EventDispatcher/ContainerAwareEventDispatcherTest.php
index ea0685a717..a750ecaf09 100644
--- a/core/tests/Drupal/Tests/Component/EventDispatcher/ContainerAwareEventDispatcherTest.php
+++ b/core/tests/Drupal/Tests/Component/EventDispatcher/ContainerAwareEventDispatcherTest.php
@@ -38,7 +38,7 @@ public function testGetListenersWithCallables()
// When passing in callables exclusively as listeners into the event
// dispatcher constructor, the event dispatcher must not attempt to
// resolve any services.
- $container = $this->getMock(ContainerInterface::class);
+ $container = $this->getMockBuilder(ContainerInterface::class)->getMock();
$container->expects($this->never())->method($this->anything());
$firstListener = new CallableClass();
@@ -73,7 +73,7 @@ public function testDispatchWithCallables()
// When passing in callables exclusively as listeners into the event
// dispatcher constructor, the event dispatcher must not attempt to
// resolve any services.
- $container = $this->getMock(ContainerInterface::class);
+ $container = $this->getMockBuilder(ContainerInterface::class)->getMock();
$container->expects($this->never())->method($this->anything());
$firstListener = new CallableClass();
diff --git a/core/tests/Drupal/Tests/Component/FileCache/FileCacheFactoryTest.php b/core/tests/Drupal/Tests/Component/FileCache/FileCacheFactoryTest.php
index 995f5fc851..f919598434 100644
--- a/core/tests/Drupal/Tests/Component/FileCache/FileCacheFactoryTest.php
+++ b/core/tests/Drupal/Tests/Component/FileCache/FileCacheFactoryTest.php
@@ -59,7 +59,13 @@ public function testGet() {
*/
public function testGetNoPrefix() {
FileCacheFactory::setPrefix(NULL);
- $this->setExpectedException(\InvalidArgumentException::class, 'Required prefix configuration is missing');
+ if (method_exists($this, 'expectException')) {
+ $this->expectException(\InvalidArgumentException::class);
+ $this->expectExceptionMessage('Required prefix configuration is missing');
+ }
+ else {
+ $this->setExpectedException(\InvalidArgumentException::class, 'Required prefix configuration is missing');
+ }
FileCacheFactory::get('test_foo_settings', []);
}
diff --git a/core/tests/Drupal/Tests/Component/PhpStorage/FileStorageTest.php b/core/tests/Drupal/Tests/Component/PhpStorage/FileStorageTest.php
index 52e1b83c03..168d1603e3 100644
--- a/core/tests/Drupal/Tests/Component/PhpStorage/FileStorageTest.php
+++ b/core/tests/Drupal/Tests/Component/PhpStorage/FileStorageTest.php
@@ -5,7 +5,7 @@
use Drupal\Component\PhpStorage\FileStorage;
use Drupal\Component\Utility\Random;
use org\bovigo\vfs\vfsStreamDirectory;
-use PHPUnit_Framework_Error_Warning;
+use PHPUnit\Framework\Error\Warning;
/**
* @coversDefaultClass \Drupal\Component\PhpStorage\FileStorage
@@ -99,7 +99,13 @@ public function testCreateDirectoryFailWarning() {
'bin' => 'test',
]);
$code = "setExpectedException(PHPUnit_Framework_Error_Warning::class, 'mkdir(): Permission Denied');
+ if (method_exists($this, 'expectException')) {
+ $this->expectException(Warning::class);
+ $this->expectExceptionMessage('mkdir(): Permission Denied');
+ }
+ else {
+ $this->setExpectedException(\PHPUnit_Framework_Error_Warning::class, 'mkdir(): Permission Denied');
+ }
$storage->save('subdirectory/foo.php', $code);
}
diff --git a/core/tests/Drupal/Tests/Component/Plugin/Context/ContextTest.php b/core/tests/Drupal/Tests/Component/Plugin/Context/ContextTest.php
index 6a2cf46673..aee8d09318 100644
--- a/core/tests/Drupal/Tests/Component/Plugin/Context/ContextTest.php
+++ b/core/tests/Drupal/Tests/Component/Plugin/Context/ContextTest.php
@@ -71,10 +71,16 @@ public function testGetContextValue($expected, $context_value, $is_required, $da
// Set expectation for exception.
if ($is_required) {
- $this->setExpectedException(
- 'Drupal\Component\Plugin\Exception\ContextException',
- sprintf("The %s context is required and not present.", $data_type)
- );
+ if (method_exists($this, 'expectException')) {
+ $this->expectException('Drupal\Component\Plugin\Exception\ContextException');
+ $this->expectExceptionMessage(sprintf("The %s context is required and not present.", $data_type));
+ }
+ else {
+ $this->setExpectedException(
+ 'Drupal\Component\Plugin\Exception\ContextException',
+ sprintf("The %s context is required and not present.", $data_type)
+ );
+ }
}
// Exercise getContextValue().
diff --git a/core/tests/Drupal/Tests/Component/Plugin/DefaultFactoryTest.php b/core/tests/Drupal/Tests/Component/Plugin/DefaultFactoryTest.php
index b6bb32c841..00e407215d 100644
--- a/core/tests/Drupal/Tests/Component/Plugin/DefaultFactoryTest.php
+++ b/core/tests/Drupal/Tests/Component/Plugin/DefaultFactoryTest.php
@@ -35,7 +35,7 @@ public function testGetPluginClassWithValidArrayPluginDefinition() {
*/
public function testGetPluginClassWithValidObjectPluginDefinition() {
$plugin_class = Cherry::class;
- $plugin_definition = $this->getMock(PluginDefinitionInterface::class);
+ $plugin_definition = $this->getMockBuilder(PluginDefinitionInterface::class)->getMock();
$plugin_definition->expects($this->atLeastOnce())
->method('getClass')
->willReturn($plugin_class);
@@ -60,7 +60,7 @@ public function testGetPluginClassWithMissingClassWithArrayPluginDefinition() {
* @covers ::getPluginClass
*/
public function testGetPluginClassWithMissingClassWithObjectPluginDefinition() {
- $plugin_definition = $this->getMock(PluginDefinitionInterface::class);
+ $plugin_definition = $this->getMockBuilder(PluginDefinitionInterface::class)->getMock();
$this->setExpectedException(PluginException::class, 'The plugin (cherry) did not specify an instance class.');
DefaultFactory::getPluginClass('cherry', $plugin_definition);
}
@@ -82,7 +82,7 @@ public function testGetPluginClassWithNotExistingClassWithArrayPluginDefinition(
*/
public function testGetPluginClassWithNotExistingClassWithObjectPluginDefinition() {
$plugin_class = '\Drupal\plugin_test\Plugin\plugin_test\fruit\Kiwifruit';
- $plugin_definition = $this->getMock(PluginDefinitionInterface::class);
+ $plugin_definition = $this->getMockBuilder(PluginDefinitionInterface::class)->getMock();
$plugin_definition->expects($this->atLeastOnce())
->method('getClass')
->willReturn($plugin_class);
@@ -109,7 +109,7 @@ public function testGetPluginClassWithInterfaceWithArrayPluginDefinition() {
*/
public function testGetPluginClassWithInterfaceWithObjectPluginDefinition() {
$plugin_class = Cherry::class;
- $plugin_definition = $this->getMock(PluginDefinitionInterface::class);
+ $plugin_definition = $this->getMockBuilder(PluginDefinitionInterface::class)->getMock();
$plugin_definition->expects($this->atLeastOnce())
->method('getClass')
->willReturn($plugin_class);
@@ -136,7 +136,7 @@ public function testGetPluginClassWithInterfaceAndInvalidClassWithArrayPluginDef
*/
public function testGetPluginClassWithInterfaceAndInvalidClassWithObjectPluginDefinition() {
$plugin_class = Kale::class;
- $plugin_definition = $this->getMock(PluginDefinitionInterface::class);
+ $plugin_definition = $this->getMockBuilder(PluginDefinitionInterface::class)->getMock();
$plugin_definition->expects($this->atLeastOnce())
->method('getClass')
->willReturn($plugin_class);
@@ -144,4 +144,26 @@ public function testGetPluginClassWithInterfaceAndInvalidClassWithObjectPluginDe
DefaultFactory::getPluginClass('cherry', $plugin_definition, FruitInterface::class);
}
+ /**
+ * Compatibility layer for PHPUnit 6 to support PHPUnit 4 code.
+ *
+ * @param mixed $class
+ * @param string $message
+ * @param int $exception_code
+ */
+ public function setExpectedException($class, $message = '', $exception_code = NULL) {
+ if (method_exists($this, 'expectException')) {
+ $this->expectException($class);
+ if (!empty($message)) {
+ $this->expectExceptionMessage($message);
+ }
+ if ($exception_code !== NULL) {
+ $this->expectExceptionCode($exception_code);
+ }
+ }
+ else {
+ parent::setExpectedException($class, $message, $exception_code);
+ }
+ }
+
}
diff --git a/core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryTraitTest.php b/core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryTraitTest.php
index c37a4b5a18..1a5c36e7b8 100644
--- a/core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryTraitTest.php
+++ b/core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryTraitTest.php
@@ -69,7 +69,12 @@ public function testDoGetDefinitionException($expected, $definitions, $plugin_id
$method_ref = new \ReflectionMethod($trait, 'doGetDefinition');
$method_ref->setAccessible(TRUE);
// Call doGetDefinition, with $exception_on_invalid always TRUE.
- $this->setExpectedException(PluginNotFoundException::class);
+ if (method_exists($this, 'expectException')) {
+ $this->expectException(PluginNotFoundException::class);
+ }
+ else {
+ $this->setExpectedException(PluginNotFoundException::class);
+ }
$method_ref->invoke($trait, $definitions, $plugin_id, TRUE);
}
@@ -106,7 +111,12 @@ public function testGetDefinitionException($expected, $definitions, $plugin_id)
->method('getDefinitions')
->willReturn($definitions);
// Call getDefinition(), with $exception_on_invalid always TRUE.
- $this->setExpectedException(PluginNotFoundException::class);
+ if (method_exists($this, 'expectException')) {
+ $this->expectException(PluginNotFoundException::class);
+ }
+ else {
+ $this->setExpectedException(PluginNotFoundException::class);
+ }
$trait->getDefinition($plugin_id, TRUE);
}
diff --git a/core/tests/Drupal/Tests/Component/Plugin/Discovery/StaticDiscoveryDecoratorTest.php b/core/tests/Drupal/Tests/Component/Plugin/Discovery/StaticDiscoveryDecoratorTest.php
index a44721bd9b..5b01093092 100644
--- a/core/tests/Drupal/Tests/Component/Plugin/Discovery/StaticDiscoveryDecoratorTest.php
+++ b/core/tests/Drupal/Tests/Component/Plugin/Discovery/StaticDiscoveryDecoratorTest.php
@@ -100,7 +100,12 @@ public function testGetDefinition($expected, $has_register_definitions, $excepti
$ref_decorated->setValue($mock_decorator, $mock_decorated);
if ($exception_on_invalid) {
- $this->setExpectedException('Drupal\Component\Plugin\Exception\PluginNotFoundException');
+ if (method_exists($this, 'expectException')) {
+ $this->expectException('Drupal\Component\Plugin\Exception\PluginNotFoundException');
+ }
+ else {
+ $this->setExpectedException('Drupal\Component\Plugin\Exception\PluginNotFoundException');
+ }
}
// Exercise getDefinition(). It calls parent::getDefinition().
diff --git a/core/tests/Drupal/Tests/Component/Plugin/Factory/ReflectionFactoryTest.php b/core/tests/Drupal/Tests/Component/Plugin/Factory/ReflectionFactoryTest.php
index 7e8fbefd1d..20d2f76edf 100644
--- a/core/tests/Drupal/Tests/Component/Plugin/Factory/ReflectionFactoryTest.php
+++ b/core/tests/Drupal/Tests/Component/Plugin/Factory/ReflectionFactoryTest.php
@@ -123,7 +123,12 @@ public function testGetInstanceArguments($expected, $reflector_name, $plugin_id,
// us to use one data set for this test method as well as
// testCreateInstance().
if ($plugin_id == 'arguments_no_constructor') {
- $this->setExpectedException('\ReflectionException');
+ if (method_exists($this, 'expectException')) {
+ $this->expectException('\ReflectionException');
+ }
+ else {
+ $this->setExpectedException('\ReflectionException');
+ }
}
// Finally invoke getInstanceArguments() on our mocked factory.
diff --git a/core/tests/Drupal/Tests/Component/Serialization/YamlPeclTest.php b/core/tests/Drupal/Tests/Component/Serialization/YamlPeclTest.php
index c2e0a0d888..5a71f48381 100644
--- a/core/tests/Drupal/Tests/Component/Serialization/YamlPeclTest.php
+++ b/core/tests/Drupal/Tests/Component/Serialization/YamlPeclTest.php
@@ -87,7 +87,12 @@ public function testGetFileExtension() {
* @covers ::errorHandler
*/
public function testError() {
- $this->setExpectedException(InvalidDataTypeException::class);
+ if (method_exists($this, 'expectException')) {
+ $this->expectException(InvalidDataTypeException::class);
+ }
+ else {
+ $this->setExpectedException(InvalidDataTypeException::class);
+ }
YamlPecl::decode('foo: [ads');
}
diff --git a/core/tests/Drupal/Tests/Component/Serialization/YamlSymfonyTest.php b/core/tests/Drupal/Tests/Component/Serialization/YamlSymfonyTest.php
index 86c818c18e..d857d097a5 100644
--- a/core/tests/Drupal/Tests/Component/Serialization/YamlSymfonyTest.php
+++ b/core/tests/Drupal/Tests/Component/Serialization/YamlSymfonyTest.php
@@ -59,7 +59,12 @@ public function testGetFileExtension() {
* @covers ::decode
*/
public function testError() {
- $this->setExpectedException(InvalidDataTypeException::class);
+ if (method_exists($this, 'expectException')) {
+ $this->expectException(InvalidDataTypeException::class);
+ }
+ else {
+ $this->setExpectedException(InvalidDataTypeException::class);
+ }
YamlSymfony::decode('foo: [ads');
}
@@ -69,7 +74,13 @@ public function testError() {
* @covers ::encode
*/
public function testObjectSupportDisabled() {
- $this->setExpectedException(InvalidDataTypeException::class, 'Object support when dumping a YAML file has been disabled.');
+ if (method_exists($this, 'expectException')) {
+ $this->expectException(InvalidDataTypeException::class);
+ $this->expectExceptionMessage('Object support when dumping a YAML file has been disabled.');
+ }
+ else {
+ $this->setExpectedException(InvalidDataTypeException::class, 'Object support when dumping a YAML file has been disabled.');
+ }
$object = new \stdClass();
$object->foo = 'bar';
YamlSymfony::encode([$object]);
diff --git a/core/tests/Drupal/Tests/Component/Utility/ArgumentsResolverTest.php b/core/tests/Drupal/Tests/Component/Utility/ArgumentsResolverTest.php
index f15f14b85a..695edf4ba6 100644
--- a/core/tests/Drupal/Tests/Component/Utility/ArgumentsResolverTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/ArgumentsResolverTest.php
@@ -96,9 +96,16 @@ public function testGetWildcardArgument() {
* Tests getArgument() with a Route, Request, and Account object.
*/
public function testGetArgumentOrder() {
- $a1 = $this->getMock('\Drupal\Tests\Component\Utility\Test1Interface');
- $a2 = $this->getMock('\Drupal\Tests\Component\Utility\TestClass');
- $a3 = $this->getMock('\Drupal\Tests\Component\Utility\Test2Interface');
+ if (method_exists($this, 'createMock')) {
+ $a1 = $this->createMock('\Drupal\Tests\Component\Utility\Test1Interface');
+ $a2 = $this->createMock('\Drupal\Tests\Component\Utility\TestClass');
+ $a3 = $this->createMock('\Drupal\Tests\Component\Utility\Test2Interface');
+ }
+ else {
+ $a1 = $this->getMock('\Drupal\Tests\Component\Utility\Test1Interface');
+ $a2 = $this->getMock('\Drupal\Tests\Component\Utility\TestClass');
+ $a3 = $this->getMock('\Drupal\Tests\Component\Utility\Test2Interface');
+ }
$objects = [
't1' => $a1,
@@ -123,12 +130,23 @@ public function testGetArgumentOrder() {
* Without the typehint, the wildcard object will not be passed to the callable.
*/
public function testGetWildcardArgumentNoTypehint() {
- $a = $this->getMock('\Drupal\Tests\Component\Utility\Test1Interface');
+ if (method_exists($this, 'createMock')) {
+ $a = $this->createMock('\Drupal\Tests\Component\Utility\Test1Interface');
+ }
+ else {
+ $a = $this->getMock('\Drupal\Tests\Component\Utility\Test1Interface');
+ }
$wildcards = [$a];
$resolver = new ArgumentsResolver([], [], $wildcards);
$callable = function ($route) {};
- $this->setExpectedException(\RuntimeException::class, 'requires a value for the "$route" argument.');
+ if (method_exists($this, 'expectException')) {
+ $this->expectException(\RuntimeException::class);
+ $this->expectExceptionMessage('requires a value for the "$route" argument.');
+ }
+ else {
+ $this->setExpectedException(\RuntimeException::class, 'requires a value for the "$route" argument.');
+ }
$resolver->getArguments($callable);
}
@@ -156,7 +174,13 @@ public function testHandleNotUpcastedArgument() {
$resolver = new ArgumentsResolver($scalars, $objects, []);
$callable = function (\stdClass $foo) {};
- $this->setExpectedException(\RuntimeException::class, 'requires a value for the "$foo" argument.');
+ if (method_exists($this, 'expectException')) {
+ $this->expectException(\RuntimeException::class);
+ $this->expectExceptionMessage('requires a value for the "$foo" argument.');
+ }
+ else {
+ $this->setExpectedException(\RuntimeException::class, 'requires a value for the "$foo" argument.');
+ }
$resolver->getArguments($callable);
}
@@ -167,7 +191,13 @@ public function testHandleNotUpcastedArgument() {
*/
public function testHandleUnresolvedArgument($callable) {
$resolver = new ArgumentsResolver([], [], []);
- $this->setExpectedException(\RuntimeException::class, 'requires a value for the "$foo" argument.');
+ if (method_exists($this, 'expectException')) {
+ $this->expectException(\RuntimeException::class);
+ $this->expectExceptionMessage('requires a value for the "$foo" argument.');
+ }
+ else {
+ $this->setExpectedException(\RuntimeException::class, 'requires a value for the "$foo" argument.');
+ }
$resolver->getArguments($callable);
}
diff --git a/core/tests/Drupal/Tests/Component/Utility/ColorTest.php b/core/tests/Drupal/Tests/Component/Utility/ColorTest.php
index cbb9d7e8eb..aea1779841 100644
--- a/core/tests/Drupal/Tests/Component/Utility/ColorTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/ColorTest.php
@@ -26,7 +26,12 @@ class ColorTest extends TestCase {
*/
public function testHexToRgb($value, $expected, $invalid = FALSE) {
if ($invalid) {
- $this->setExpectedException('InvalidArgumentException');
+ if (method_exists($this, 'expectException')) {
+ $this->expectException('InvalidArgumentException');
+ }
+ else {
+ $this->setExpectedException('InvalidArgumentException');
+ }
}
$this->assertSame($expected, Color::hexToRgb($value));
}
diff --git a/core/tests/Drupal/Tests/Component/Utility/CryptTest.php b/core/tests/Drupal/Tests/Component/Utility/CryptTest.php
index c87628f75c..80208ef294 100644
--- a/core/tests/Drupal/Tests/Component/Utility/CryptTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/CryptTest.php
@@ -77,7 +77,12 @@ public function testHmacBase64($data, $key, $expected_hmac) {
* Key to use in hashing process.
*/
public function testHmacBase64Invalid($data, $key) {
- $this->setExpectedException(\InvalidArgumentException::class);
+ if (method_exists($this, 'expectException')) {
+ $this->expectException('InvalidArgumentException');
+ }
+ else {
+ $this->setExpectedException('InvalidArgumentException');
+ }
Crypt::hmacBase64($data, $key);
}
diff --git a/core/tests/Drupal/Tests/Component/Utility/HtmlTest.php b/core/tests/Drupal/Tests/Component/Utility/HtmlTest.php
index 1860e04105..a8a8af0e6c 100644
--- a/core/tests/Drupal/Tests/Component/Utility/HtmlTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/HtmlTest.php
@@ -343,7 +343,12 @@ public function testTransformRootRelativeUrlsToAbsolute($html, $scheme_and_host,
* @dataProvider providerTestTransformRootRelativeUrlsToAbsoluteAssertion
*/
public function testTransformRootRelativeUrlsToAbsoluteAssertion($scheme_and_host) {
- $this->setExpectedException(\AssertionError::class);
+ if (method_exists($this, 'expectException')) {
+ $this->expectException(\AssertionError::class);
+ }
+ else {
+ $this->setExpectedException(\AssertionError::class);
+ }
Html::transformRootRelativeUrlsToAbsolute('', $scheme_and_host);
}
diff --git a/core/tests/Drupal/Tests/Component/Utility/RandomTest.php b/core/tests/Drupal/Tests/Component/Utility/RandomTest.php
index 64f0eaac1b..7523c8be06 100644
--- a/core/tests/Drupal/Tests/Component/Utility/RandomTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/RandomTest.php
@@ -62,7 +62,12 @@ public function testRandomNameException() {
// There are fewer than 100 possibilities so an exception should occur to
// prevent infinite loops.
$random = new Random();
- $this->setExpectedException(\RuntimeException::class);
+ if (method_exists($this, 'expectException')) {
+ $this->expectException(\RuntimeException::class);
+ }
+ else {
+ $this->setExpectedException(\RuntimeException::class);
+ }
for ($i = 0; $i <= 100; $i++) {
$str = $random->name(1, TRUE);
$names[$str] = TRUE;
@@ -78,7 +83,12 @@ public function testRandomStringException() {
// There are fewer than 100 possibilities so an exception should occur to
// prevent infinite loops.
$random = new Random();
- $this->setExpectedException(\RuntimeException::class);
+ if (method_exists($this, 'expectException')) {
+ $this->expectException(\RuntimeException::class);
+ }
+ else {
+ $this->setExpectedException(\RuntimeException::class);
+ }
for ($i = 0; $i <= 100; $i++) {
$str = $random->string(1, TRUE);
$names[$str] = TRUE;
diff --git a/core/tests/Drupal/Tests/Component/Utility/RectangleTest.php b/core/tests/Drupal/Tests/Component/Utility/RectangleTest.php
index 49d08333ef..ef46b7963a 100644
--- a/core/tests/Drupal/Tests/Component/Utility/RectangleTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/RectangleTest.php
@@ -17,7 +17,12 @@ class RectangleTest extends TestCase {
* @covers ::rotate
*/
public function testWrongWidth() {
- $this->setExpectedException(\InvalidArgumentException::class);
+ if (method_exists($this, 'expectException')) {
+ $this->expectException(\InvalidArgumentException::class);
+ }
+ else {
+ $this->setExpectedException(\InvalidArgumentException::class);
+ }
$rect = new Rectangle(-40, 20);
}
@@ -27,7 +32,12 @@ public function testWrongWidth() {
* @covers ::rotate
*/
public function testWrongHeight() {
- $this->setExpectedException(\InvalidArgumentException::class);
+ if (method_exists($this, 'expectException')) {
+ $this->expectException(\InvalidArgumentException::class);
+ }
+ else {
+ $this->setExpectedException(\InvalidArgumentException::class);
+ }
$rect = new Rectangle(40, 0);
}
diff --git a/core/tests/Drupal/Tests/Component/Utility/SafeMarkupTest.php b/core/tests/Drupal/Tests/Component/Utility/SafeMarkupTest.php
index 7f249d9bea..f811c16c15 100644
--- a/core/tests/Drupal/Tests/Component/Utility/SafeMarkupTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/SafeMarkupTest.php
@@ -37,7 +37,7 @@ protected function tearDown() {
* @covers ::isSafe
*/
public function testIsSafe() {
- $safe_string = $this->getMock('\Drupal\Component\Render\MarkupInterface');
+ $safe_string = $this->getMockBuilder('\Drupal\Component\Render\MarkupInterface')->getMock();
$this->assertTrue(SafeMarkup::isSafe($safe_string));
$string_object = new SafeMarkupTestString('test');
$this->assertFalse(SafeMarkup::isSafe($string_object));
diff --git a/core/tests/Drupal/Tests/Component/Utility/UnicodeTest.php b/core/tests/Drupal/Tests/Component/Utility/UnicodeTest.php
index 6bfc6cb0d2..ba1757ffc5 100644
--- a/core/tests/Drupal/Tests/Component/Utility/UnicodeTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/UnicodeTest.php
@@ -33,7 +33,12 @@ protected function setUp() {
*/
public function testStatus($value, $expected, $invalid = FALSE) {
if ($invalid) {
- $this->setExpectedException('InvalidArgumentException');
+ if (method_exists($this, 'expectException')) {
+ $this->expectException('InvalidArgumentException');
+ }
+ else {
+ $this->setExpectedException('InvalidArgumentException');
+ }
}
Unicode::setStatus($value);
$this->assertEquals($expected, Unicode::getStatus());
diff --git a/core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php b/core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php
index db78cd9458..d185219c9a 100644
--- a/core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php
@@ -578,7 +578,12 @@ public function providerTestExternalIsLocal() {
* @dataProvider providerTestExternalIsLocalInvalid
*/
public function testExternalIsLocalInvalid($url, $base_url) {
- $this->setExpectedException(\InvalidArgumentException::class);
+ if (method_exists($this, 'expectException')) {
+ $this->expectException(\InvalidArgumentException::class);
+ }
+ else {
+ $this->setExpectedException(\InvalidArgumentException::class);
+ }
UrlHelper::externalIsLocal($url, $base_url);
}
diff --git a/core/tests/Drupal/Tests/Core/Entity/Access/EntityFormDisplayAccessControlHandlerTest.php b/core/tests/Drupal/Tests/Core/Entity/Access/EntityFormDisplayAccessControlHandlerTest.php
index 1ee804d539..a92d76abb7 100644
--- a/core/tests/Drupal/Tests/Core/Entity/Access/EntityFormDisplayAccessControlHandlerTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/Access/EntityFormDisplayAccessControlHandlerTest.php
@@ -164,10 +164,6 @@ protected function setUp() {
->willReturnMap([
['entity_display', $storage_access_control_handler],
]);
- $entity_type_manager
- ->expects($this->any())
- ->method('getFieldDefinitions')
- ->willReturn([]);
$entity_type_manager
->expects($this->any())
->method('getDefinition')
diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityListBuilderTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityListBuilderTest.php
index ad68e2df68..55928b98a6 100644
--- a/core/tests/Drupal/Tests/Core/Entity/EntityListBuilderTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/EntityListBuilderTest.php
@@ -123,9 +123,6 @@ public function testGetOperations() {
$url = $this->getMockBuilder('\Drupal\Core\Url')
->disableOriginalConstructor()
->getMock();
- $url->expects($this->any())
- ->method('toArray')
- ->will($this->returnValue([]));
$url->expects($this->atLeastOnce())
->method('mergeOptions')
->with(['query' => ['destination' => '/foo/bar']]);
diff --git a/core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php b/core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php
index 4a2dac5653..846ce0a59f 100644
--- a/core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/KeyValueStore/KeyValueEntityStorageTest.php
@@ -361,7 +361,7 @@ public function testSaveConfigEntity() {
$this->assertSame('foo', $entity->getOriginalId());
$expected = ['id' => 'foo'];
- $entity->expects($this->once())
+ $entity->expects($this->atLeastOnce())
->method('toArray')
->will($this->returnValue($expected));
diff --git a/core/tests/Drupal/Tests/Core/Listeners/DrupalStandardsListenerDeprecationTest.php b/core/tests/Drupal/Tests/Core/Listeners/DrupalStandardsListenerDeprecationTest.php
index 61b62118af..ad3930440b 100644
--- a/core/tests/Drupal/Tests/Core/Listeners/DrupalStandardsListenerDeprecationTest.php
+++ b/core/tests/Drupal/Tests/Core/Listeners/DrupalStandardsListenerDeprecationTest.php
@@ -21,6 +21,7 @@
* would trigger another deprecation error.
*
* @group Listeners
+ * @group legacy
*
* @coversDefaultClass \Drupal\deprecation_test\Deprecation\FixtureDeprecatedClass
*/
@@ -29,6 +30,8 @@ class DrupalStandardsListenerDeprecationTest extends UnitTestCase {
/**
* Exercise DrupalStandardsListener's coverage validation.
*
+ * @expectedDeprecation Drupal\deprecation_test\Deprecation\FixtureDeprecatedClass is deprecated.
+ *
* @covers ::testFunction
*/
public function testDeprecation() {
diff --git a/core/tests/Drupal/Tests/Core/Logger/LoggerChannelTest.php b/core/tests/Drupal/Tests/Core/Logger/LoggerChannelTest.php
index 2512602afa..0f934ebf8e 100644
--- a/core/tests/Drupal/Tests/Core/Logger/LoggerChannelTest.php
+++ b/core/tests/Drupal/Tests/Core/Logger/LoggerChannelTest.php
@@ -102,12 +102,12 @@ public function testSortLoggers() {
*/
public function providerTestLog() {
$account_mock = $this->getMock('Drupal\Core\Session\AccountInterface');
- $account_mock->expects($this->exactly(2))
+ $account_mock->expects($this->any())
->method('id')
->will($this->returnValue(1));
- $request_mock = $this->getMock('Symfony\Component\HttpFoundation\Request');
- $request_mock->expects($this->exactly(2))
+ $request_mock = $this->getMock('Symfony\Component\HttpFoundation\Request', ['getClientIp']);
+ $request_mock->expects($this->any())
->method('getClientIp')
->will($this->returnValue('127.0.0.1'));
$request_mock->headers = $this->getMock('Symfony\Component\HttpFoundation\ParameterBag');
diff --git a/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php b/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php
index 929930a521..e6215caac8 100644
--- a/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php
+++ b/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php
@@ -76,12 +76,6 @@ protected function setUp() {
$language_manager->expects($this->any())
->method('getLanguageTypes')
->will($this->returnValue([LanguageInterface::TYPE_INTERFACE]));
- $language_manager->expects($this->any())
- ->method('getNegotiationMethods')
- ->will($this->returnValue($method_definitions));
- $language_manager->expects($this->any())
- ->method('getNegotiationMethodInstance')
- ->will($this->returnValue($method_instance));
$method_instance->setLanguageManager($language_manager);
$this->languageManager = $language_manager;
diff --git a/core/tests/Drupal/Tests/Core/Plugin/Context/ContextTest.php b/core/tests/Drupal/Tests/Core/Plugin/Context/ContextTest.php
index 2190d53918..7dead3d32e 100644
--- a/core/tests/Drupal/Tests/Core/Plugin/Context/ContextTest.php
+++ b/core/tests/Drupal/Tests/Core/Plugin/Context/ContextTest.php
@@ -104,6 +104,7 @@ public function testSetContextValueCacheableDependency() {
$container = new Container();
$cache_context_manager = $this->getMockBuilder('Drupal\Core\Cache\CacheContextsManager')
->disableOriginalConstructor()
+ ->setMethods(['validateTokens'])
->getMock();
$container->set('cache_contexts_manager', $cache_context_manager);
$cache_context_manager->expects($this->any())
diff --git a/core/tests/Drupal/Tests/Core/Render/BubbleableMetadataTest.php b/core/tests/Drupal/Tests/Core/Render/BubbleableMetadataTest.php
index 1fca8179a8..a881e7c2ce 100644
--- a/core/tests/Drupal/Tests/Core/Render/BubbleableMetadataTest.php
+++ b/core/tests/Drupal/Tests/Core/Render/BubbleableMetadataTest.php
@@ -38,6 +38,7 @@ public function testMerge(BubbleableMetadata $a, CacheableMetadata $b, Bubbleabl
if (!$b instanceof BubbleableMetadata) {
$renderer = $this->getMockBuilder('Drupal\Core\Render\Renderer')
->disableOriginalConstructor()
+ ->setMethods(['mergeAttachments'])
->getMock();
$renderer->expects($this->never())
->method('mergeAttachments');
diff --git a/core/tests/bootstrap.php b/core/tests/bootstrap.php
index f78b69ff04..731110aba0 100644
--- a/core/tests/bootstrap.php
+++ b/core/tests/bootstrap.php
@@ -166,3 +166,41 @@ function drupal_phpunit_populate_class_loader() {
// make PHP 5 and 7 handle assertion failures the same way, but this call does
// not turn runtime assertions on if they weren't on already.
Handle::register();
+
+// @todo Decide if we need put in some code for WebTestBase too since there are
+// tests using PHPUnit_Util_XML for example.
+// PHPUnit 4 to PHPUnit 6 bridge. Tests written for PHPUnit 4 need to work on
+// PHPUnit 6 with a minimum of fuss.
+if (!class_exists('\PHPUnit_Framework_AssertionFailedError') && class_exists('\PHPUnit\Framework\AssertionFailedError')) {
+ class_alias('\PHPUnit\Framework\AssertionFailedError', '\PHPUnit_Framework_AssertionFailedError');
+}
+if (!class_exists('\PHPUnit_Framework_Error_Warning') && class_exists('\PHPUnit\Framework\Error\Warning')) {
+ class_alias('\PHPUnit\Framework\Error\Warning', '\PHPUnit_Framework_Error_Warning');
+}
+if (!class_exists('\PHPUnit_Framework_Error') && class_exists('\PHPUnit\Framework\Error\Error')) {
+ class_alias('\PHPUnit\Framework\Error\Error', '\PHPUnit_Framework_Error');
+}
+if (!class_exists('\PHPUnit_Framework_TestCase') && class_exists('\PHPUnit\Framework\TestCase')) {
+ class_alias('\PHPUnit\Framework\TestCase', '\PHPUnit_Framework_TestCase');
+}
+if (!class_exists('\PHPUnit_Util_Test') && class_exists('\PHPUnit\Util\Test')) {
+ class_alias('\PHPUnit\Util\Test', '\PHPUnit_Util_Test');
+}
+if (!class_exists('\PHPUnit_Util_XML') && class_exists('\PHPUnit\Util\XML')) {
+ class_alias('\PHPUnit\Util\XML', '\PHPUnit_Util_XML');
+}
+if (!class_exists('\PHPUnit_Framework_SkippedTestError') && class_exists('\PHPUnit\Framework\SkippedTestError')) {
+ class_alias('\PHPUnit\Framework\SkippedTestError', '\PHPUnit_Framework_SkippedTestError');
+}
+if (!class_exists('\PHPUnit_Framework_Exception') && class_exists('\PHPUnit\Framework\Exception')) {
+ class_alias('\PHPUnit\Framework\Exception', '\PHPUnit_Framework_Exception');
+}
+if (!class_exists('\PHPUnit_Framework_ExpectationFailedException') && class_exists('\PHPUnit\Framework\ExpectationFailedException')) {
+ class_alias('\PHPUnit\Framework\ExpectationFailedException', '\PHPUnit_Framework_ExpectationFailedException');
+}
+if (!class_exists('\PHPUnit_Framework_Constraint_Count') && class_exists('\PHPUnit\Framework\Constraint\Count')) {
+ class_alias('\PHPUnit\Framework\Constraint\Count', '\PHPUnit_Framework_Constraint_Count');
+}
+if (!class_exists('\PHPUnit_Framework_MockObject_Matcher_InvokedRecorder') && class_exists('\PHPUnit\Framework\MockObject\Matcher\InvokedRecorder')) {
+ class_alias('\PHPUnit\Framework\MockObject\Matcher\InvokedRecorder', '\PHPUnit_Framework_MockObject_Matcher_InvokedRecorder');
+}