Commit c2e91dcc authored by catch's avatar catch

Issue #3191986 by mondrake, daffie: Replace usages of deprecated...

Issue #3191986 by mondrake, daffie: Replace usages of deprecated AssertLegacyTrait::assertNotIdentical
parent e1fcfc01
......@@ -64,7 +64,7 @@ public function testPageEdit() {
// Ensure that the block revision has been created.
\Drupal::entityTypeManager()->getStorage('block_content')->resetCache([$block->id()]);
$revised_block = BlockContent::load($block->id());
$this->assertNotIdentical($block->getRevisionId(), $revised_block->getRevisionId(), 'A new revision has been created.');
$this->assertNotSame($block->getRevisionId(), $revised_block->getRevisionId(), 'A new revision has been created.');
// Test deleting the block.
$this->drupalGet("block/" . $revised_block->id());
......
......@@ -85,7 +85,7 @@ public function testExport() {
$archiver->extract($temp_directory, ['system.maintenance.yml']);
$file_contents = file_get_contents($temp_directory . '/' . 'system.maintenance.yml');
$exported = Yaml::decode($file_contents);
$this->assertNotIdentical($exported['message'], 'Foo');
$this->assertNotSame('Foo', $exported['message']);
// Check the single export form doesn't have "form-required" elements.
$this->drupalGet('admin/config/development/configuration/single/export');
......
......@@ -116,7 +116,7 @@ public function testNodeEdit() {
// Ensure that the node revision has been created.
$revised_node = $this->drupalGetNodeByTitle($edit['title[0][value]'], TRUE);
$this->assertNotIdentical($node->getRevisionId(), $revised_node->getRevisionId(), 'A new revision has been created.');
$this->assertNotSame($node->getRevisionId(), $revised_node->getRevisionId(), 'A new revision has been created.');
// Ensure that the node author is preserved when it was not changed in the
// edit form.
$this->assertIdentical($node->getOwnerId(), $revised_node->getOwnerId(), 'The node author has been preserved.');
......@@ -124,7 +124,7 @@ public function testNodeEdit() {
// made by different users.
$first_node_version = node_revision_load($node->getRevisionId());
$second_node_version = node_revision_load($revised_node->getRevisionId());
$this->assertNotIdentical($first_node_version->getRevisionUser()->id(), $second_node_version->getRevisionUser()->id(), 'Each revision has a distinct user.');
$this->assertNotSame($first_node_version->getRevisionUser()->id(), $second_node_version->getRevisionUser()->id(), 'Each revision has a distinct user.');
// Check if the node revision checkbox is rendered on node edit form.
$this->drupalGet('node/' . $node->id() . '/edit');
......
......@@ -521,7 +521,7 @@ public function testRevisionTranslationRendering() {
$original_revision_url = $original_revision->toUrl('revision')->toString();
// Should be different from regular node URL.
$this->assertNotIdentical($original_revision_url, $original_revision->toUrl()->toString());
$this->assertNotSame($original_revision_url, $original_revision->toUrl()->toString());
$this->drupalGet($original_revision_url);
$this->assertSession()->statusCodeEquals(200);
......@@ -533,8 +533,8 @@ public function testRevisionTranslationRendering() {
$url_fr = $original_revision->getTranslation('fr')->toUrl('revision')->toString();
// Should have different URL from English.
$this->assertNotIdentical($url_fr, $original_revision->toUrl()->toString());
$this->assertNotIdentical($url_fr, $original_revision_url);
$this->assertNotSame($url_fr, $original_revision->toUrl()->toString());
$this->assertNotSame($url_fr, $original_revision_url);
$this->drupalGet($url_fr);
$this->assertSession()->statusCodeEquals(200);
......
......@@ -103,7 +103,7 @@ public function testAdminPasswordPreserved() {
$user_account = User::load(2);
$this->assertIdentical($user_account->getAccountName(), 'random_user');
$this->assertIdentical($user_account->getEmail(), 'random_user@example.com');
$this->assertNotIdentical($user_account->getPassword(), $this->originalPasswords[2]);
$this->assertNotSame($this->originalPasswords[2], $user_account->getPassword());
}
}
......@@ -78,7 +78,7 @@ protected function assertNotIdenticalResultset($view, $expected_result, $column_
* (optional) The message to display with the assertion.
*
* @return bool
* TRUE if the assertion succeeded, or FALSE otherwise.
* TRUE if the assertion succeeded.
*/
protected function assertIdenticalResultsetHelper($view, $expected_result, $column_map, $assert_method, $message = NULL) {
// Convert $view->result to an array of arrays.
......@@ -144,7 +144,17 @@ protected function assertIdenticalResultsetHelper($view, $expected_result, $colu
'@expected' => var_export($expected_result, TRUE),
]);
}
return $this->$assert_method($result, $expected_result, $message);
switch ($assert_method) {
case 'assertIdentical':
$this->assertSame($expected_result, $result, $message);
return TRUE;
case 'assertNotIdentical':
$this->assertNotSame($expected_result, $result, $message);
return TRUE;
}
}
}
......@@ -321,7 +321,7 @@ public function testCreateDuplicate() {
$this->assertInstanceOf(View::class, $copy);
// Check that the original view and the copy have different UUIDs.
$this->assertNotIdentical($view->storage->uuid(), $copy->uuid(), 'The copied view has a new UUID.');
$this->assertNotSame($view->storage->uuid(), $copy->uuid(), 'The copied view has a new UUID.');
// Check the 'name' (ID) is using the View objects default value (NULL) as it
// gets unset.
......
......@@ -34,7 +34,7 @@ public function testNormalize() {
'additional_key' => TRUE,
] + $config->getRawData();
$config->setData($data)->save();
$this->assertNotIdentical($config_entity->toArray(), $config->getRawData(), 'Stored config entity is not is equivalent to config schema.');
$this->assertNotSame($config_entity->toArray(), $config->getRawData(), 'Stored config entity is not is equivalent to config schema.');
$config_entity = \Drupal::entityTypeManager()->getStorage('config_test')->load('system');
$config_entity->save();
......
......@@ -102,8 +102,8 @@ public function testConfigOverride() {
// Load override free to ensure that loading the config entity again does
// not return the overridden value.
$entity_no_override = $storage->loadOverrideFree($this->entityId);
$this->assertNotIdentical($entity_no_override->label, 'Overridden label');
$this->assertNotIdentical($entity_override->_loadStamp, $entity_no_override->_loadStamp);
$this->assertNotSame('Overridden label', $entity_no_override->label);
$this->assertNotSame($entity_override->_loadStamp, $entity_no_override->_loadStamp);
// Reload the entity and ensure the cache is used.
$this->assertIdentical($storage->loadOverrideFree($this->entityId)->_loadStamp, $entity_no_override->_loadStamp);
......
......@@ -30,7 +30,7 @@ public function testConnectionRouting() {
$this->assertNotNull($db1, 'default connection is a real connection object.');
$this->assertNotNull($db2, 'replica connection is a real connection object.');
$this->assertNotIdentical($db1, $db2, 'Each target refers to a different connection.');
$this->assertNotSame($db1, $db2, 'Each target refers to a different connection.');
// Try to open those targets another time, that should return the same objects.
$db1b = Database::getConnection('default', 'default');
......@@ -79,7 +79,7 @@ public function testConnectionClosing() {
$db2 = Database::getConnection('default', 'default');
// Opening a connection after closing it should yield an object different than the original.
$this->assertNotIdentical($db1, $db2, 'Opening the default connection after it is closed returns a new object.');
$this->assertNotSame($db1, $db2, 'Opening the default connection after it is closed returns a new object.');
}
/**
......
......@@ -546,7 +546,7 @@ public function testSelectDuplicateAlias() {
$query = $this->connection->select('test', 't');
$alias1 = $query->addField('t', 'name', 'the_alias');
$alias2 = $query->addField('t', 'age', 'the_alias');
$this->assertNotIdentical($alias1, $alias2, 'Duplicate aliases are renamed.');
$this->assertNotSame($alias1, $alias2, 'Duplicate aliases are renamed.');
}
/**
......
......@@ -152,9 +152,9 @@ public function testTransactionRollBackSupported() {
// Neither of the rows we inserted in the two transaction layers
// should be present in the tables post-rollback.
$saved_age = $this->connection->query('SELECT [age] FROM {test} WHERE [name] = :name', [':name' => 'DavidB'])->fetchField();
$this->assertNotIdentical($saved_age, '24', 'Cannot retrieve DavidB row after commit.');
$this->assertNotSame('24', $saved_age, 'Cannot retrieve DavidB row after commit.');
$saved_age = $this->connection->query('SELECT [age] FROM {test} WHERE [name] = :name', [':name' => 'DanielB'])->fetchField();
$this->assertNotIdentical($saved_age, '19', 'Cannot retrieve DanielB row after commit.');
$this->assertNotSame('19', $saved_age, 'Cannot retrieve DanielB row after commit.');
}
catch (\Exception $e) {
$this->fail($e->getMessage());
......
......@@ -364,7 +364,7 @@ protected function doTestEntityTranslationAPI($entity_type) {
$name_translated = $langcode . '_' . $this->randomMachineName();
$translation = $entity->addTranslation($langcode);
$this->assertTrue($translation->isNewTranslation(), 'Newly added translations are marked as new.');
$this->assertNotIdentical($entity, $translation, 'The entity and the translation object differ from one another.');
$this->assertNotSame($entity, $translation, 'The entity and the translation object differ from one another.');
$this->assertTrue($entity->hasTranslation($langcode), 'The new translation exists.');
$this->assertEqual($translation->language()->getId(), $langcode, 'The translation language matches the specified one.');
$this->assertEqual($translation->{$langcode_key}->value, $langcode, 'The translation field language value matches the specified one.');
......@@ -531,7 +531,7 @@ protected function doTestEntityTranslationAPI($entity_type) {
$entity->getTranslation($langcode);
$cloned = clone $entity;
$translation = $cloned->getTranslation($langcode);
$this->assertNotIdentical($entity, $translation->getUntranslated(), 'A cloned entity object has no reference to the original one.');
$this->assertNotSame($entity, $translation->getUntranslated(), 'A cloned entity object has no reference to the original one.');
$entity->removeTranslation($langcode);
$this->assertFalse($entity->hasTranslation($langcode));
$this->assertTrue($cloned->hasTranslation($langcode));
......
......@@ -338,6 +338,16 @@ public function testAssertIdenticalObject() {
$this->assertIdenticalObject((object) ['foo' => 'bar'], (object) ['foo' => 'bar']);
}
/**
* Tests the deprecation of AssertLegacyTrait::assertNotIdentical.
*
* @group legacy
*/
public function testAssertNotIdentical() {
$this->expectDeprecation('AssertLegacyTrait::assertNotIdentical() is deprecated in drupal:8.0.0 and is removed from drupal:10.0.0. Use $this->assertNotSame() instead. See https://www.drupal.org/node/3129738');
$this->assertNotIdentical('foo', 'bar');
}
/**
* Tests the deprecation of ::installSchema with the tables key_value(_expire).
*
......
......@@ -124,7 +124,6 @@ public static function getSkippedDeprecations() {
'AssertLegacyTrait::assertEqual() is deprecated in drupal:8.0.0 and is removed from drupal:10.0.0. Use $this->assertEquals() instead. See https://www.drupal.org/node/3129738',
'AssertLegacyTrait::assertNotEqual() is deprecated in drupal:8.0.0 and is removed from drupal:10.0.0. Use $this->assertNotEquals() instead. See https://www.drupal.org/node/3129738',
'AssertLegacyTrait::assertIdentical() is deprecated in drupal:8.0.0 and is removed from drupal:10.0.0. Use $this->assertSame() instead. See https://www.drupal.org/node/3129738',
'AssertLegacyTrait::assertNotIdentical() is deprecated in drupal:8.0.0 and is removed from drupal:10.0.0. Use $this->assertNotSame() instead. See https://www.drupal.org/node/3129738',
'AssertLegacyTrait::assertText() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->responseContains() or $this->assertSession()->pageTextContains() instead. See https://www.drupal.org/node/3129738',
'AssertLegacyTrait::assertNoText() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->responseNotContains() or $this->assertSession()->pageTextNotContains() instead. See https://www.drupal.org/node/3129738',
'AssertLegacyTrait::assertRaw() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->responseContains() instead. See https://www.drupal.org/node/3129738',
......
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