Issue #3139402 by mondrake: Replace usages of AssertLegacyTrait::assertIdenticalObject(), which is deprecated
parent
c61c5dc139
commit
d9b70a9f46
|
@ -44,20 +44,20 @@ class DatabaseStorageExpirableTest extends StorageTestBase {
|
||||||
// Verify that an item can be stored with setWithExpire().
|
// Verify that an item can be stored with setWithExpire().
|
||||||
// Use a random expiration in each test.
|
// Use a random expiration in each test.
|
||||||
$stores[0]->setWithExpire('foo', $this->objects[0], rand(500, 100000));
|
$stores[0]->setWithExpire('foo', $this->objects[0], rand(500, 100000));
|
||||||
$this->assertIdenticalObject($this->objects[0], $stores[0]->get('foo'));
|
$this->assertEquals($this->objects[0], $stores[0]->get('foo'));
|
||||||
// Verify that the other collection is not affected.
|
// Verify that the other collection is not affected.
|
||||||
$this->assertNull($stores[1]->get('foo'));
|
$this->assertNull($stores[1]->get('foo'));
|
||||||
|
|
||||||
// Verify that an item can be updated with setWithExpire().
|
// Verify that an item can be updated with setWithExpire().
|
||||||
$stores[0]->setWithExpire('foo', $this->objects[1], rand(500, 100000));
|
$stores[0]->setWithExpire('foo', $this->objects[1], rand(500, 100000));
|
||||||
$this->assertIdenticalObject($this->objects[1], $stores[0]->get('foo'));
|
$this->assertEquals($this->objects[1], $stores[0]->get('foo'));
|
||||||
// Verify that the other collection is still not affected.
|
// Verify that the other collection is still not affected.
|
||||||
$this->assertNull($stores[1]->get('foo'));
|
$this->assertNull($stores[1]->get('foo'));
|
||||||
|
|
||||||
// Verify that the expirable data key is unique.
|
// Verify that the expirable data key is unique.
|
||||||
$stores[1]->setWithExpire('foo', $this->objects[2], rand(500, 100000));
|
$stores[1]->setWithExpire('foo', $this->objects[2], rand(500, 100000));
|
||||||
$this->assertIdenticalObject($this->objects[1], $stores[0]->get('foo'));
|
$this->assertEquals($this->objects[1], $stores[0]->get('foo'));
|
||||||
$this->assertIdenticalObject($this->objects[2], $stores[1]->get('foo'));
|
$this->assertEquals($this->objects[2], $stores[1]->get('foo'));
|
||||||
|
|
||||||
// Verify that multiple items can be stored with setMultipleWithExpire().
|
// Verify that multiple items can be stored with setMultipleWithExpire().
|
||||||
$values = [
|
$values = [
|
||||||
|
@ -67,11 +67,11 @@ class DatabaseStorageExpirableTest extends StorageTestBase {
|
||||||
$stores[0]->setMultipleWithExpire($values, rand(500, 100000));
|
$stores[0]->setMultipleWithExpire($values, rand(500, 100000));
|
||||||
$result = $stores[0]->getMultiple(['foo', 'bar']);
|
$result = $stores[0]->getMultiple(['foo', 'bar']);
|
||||||
foreach ($values as $j => $value) {
|
foreach ($values as $j => $value) {
|
||||||
$this->assertIdenticalObject($value, $result[$j]);
|
$this->assertEquals($value, $result[$j]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify that the other collection was not affected.
|
// Verify that the other collection was not affected.
|
||||||
$this->assertIdenticalObject($stores[1]->get('foo'), $this->objects[2]);
|
$this->assertEquals($this->objects[2], $stores[1]->get('foo'));
|
||||||
$this->assertNull($stores[1]->get('bar'));
|
$this->assertNull($stores[1]->get('bar'));
|
||||||
|
|
||||||
// Verify that all items in a collection can be retrieved.
|
// Verify that all items in a collection can be retrieved.
|
||||||
|
@ -93,7 +93,7 @@ class DatabaseStorageExpirableTest extends StorageTestBase {
|
||||||
$this->assertNull($stores[0]->get('bar'));
|
$this->assertNull($stores[0]->get('bar'));
|
||||||
$this->assertEmpty($stores[0]->getMultiple(['foo', 'bar']));
|
$this->assertEmpty($stores[0]->getMultiple(['foo', 'bar']));
|
||||||
// Verify that the item in the other collection still exists.
|
// Verify that the item in the other collection still exists.
|
||||||
$this->assertIdenticalObject($this->objects[5], $stores[1]->get('foo'));
|
$this->assertEquals($this->objects[5], $stores[1]->get('foo'));
|
||||||
|
|
||||||
// Test that setWithExpireIfNotExists() succeeds only the first time.
|
// Test that setWithExpireIfNotExists() succeeds only the first time.
|
||||||
$key = $this->randomMachineName();
|
$key = $this->randomMachineName();
|
||||||
|
@ -101,7 +101,7 @@ class DatabaseStorageExpirableTest extends StorageTestBase {
|
||||||
// setWithExpireIfNotExists() should be TRUE the first time (when $i is
|
// setWithExpireIfNotExists() should be TRUE the first time (when $i is
|
||||||
// 0) and FALSE the second time (when $i is 1).
|
// 0) and FALSE the second time (when $i is 1).
|
||||||
$this->assertEqual(!$i, $stores[0]->setWithExpireIfNotExists($key, $this->objects[$i], rand(500, 100000)));
|
$this->assertEqual(!$i, $stores[0]->setWithExpireIfNotExists($key, $this->objects[$i], rand(500, 100000)));
|
||||||
$this->assertIdenticalObject($this->objects[0], $stores[0]->get($key));
|
$this->assertEquals($this->objects[0], $stores[0]->get($key));
|
||||||
// Verify that the other collection is not affected.
|
// Verify that the other collection is not affected.
|
||||||
$this->assertNull($stores[1]->get($key));
|
$this->assertNull($stores[1]->get($key));
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ class DatabaseStorageExpirableTest extends StorageTestBase {
|
||||||
$stores[0]->delete($key);
|
$stores[0]->delete($key);
|
||||||
$stores[0]->setWithExpireIfNotExists($key, $this->objects[1], rand(500, 100000));
|
$stores[0]->setWithExpireIfNotExists($key, $this->objects[1], rand(500, 100000));
|
||||||
// This time it should succeed.
|
// This time it should succeed.
|
||||||
$this->assertIdenticalObject($this->objects[1], $stores[0]->get($key));
|
$this->assertEquals($this->objects[1], $stores[0]->get($key));
|
||||||
// Verify that the other collection is still not affected.
|
// Verify that the other collection is still not affected.
|
||||||
$this->assertNull($stores[1]->get($key));
|
$this->assertNull($stores[1]->get($key));
|
||||||
|
|
||||||
|
|
|
@ -54,21 +54,21 @@ abstract class StorageTestBase extends KernelTestBase {
|
||||||
// Verify that an item can be stored.
|
// Verify that an item can be stored.
|
||||||
$stores[0]->set('foo', $this->objects[0]);
|
$stores[0]->set('foo', $this->objects[0]);
|
||||||
$this->assertTrue($stores[0]->has('foo'));
|
$this->assertTrue($stores[0]->has('foo'));
|
||||||
$this->assertIdenticalObject($this->objects[0], $stores[0]->get('foo'));
|
$this->assertEquals($this->objects[0], $stores[0]->get('foo'));
|
||||||
// Verify that the other collection is not affected.
|
// Verify that the other collection is not affected.
|
||||||
$this->assertFalse($stores[1]->has('foo'));
|
$this->assertFalse($stores[1]->has('foo'));
|
||||||
$this->assertNull($stores[1]->get('foo'));
|
$this->assertNull($stores[1]->get('foo'));
|
||||||
|
|
||||||
// Verify that an item can be updated.
|
// Verify that an item can be updated.
|
||||||
$stores[0]->set('foo', $this->objects[1]);
|
$stores[0]->set('foo', $this->objects[1]);
|
||||||
$this->assertIdenticalObject($this->objects[1], $stores[0]->get('foo'));
|
$this->assertEquals($this->objects[1], $stores[0]->get('foo'));
|
||||||
// Verify that the other collection is still not affected.
|
// Verify that the other collection is still not affected.
|
||||||
$this->assertNull($stores[1]->get('foo'));
|
$this->assertNull($stores[1]->get('foo'));
|
||||||
|
|
||||||
// Verify that a collection/name pair is unique.
|
// Verify that a collection/name pair is unique.
|
||||||
$stores[1]->set('foo', $this->objects[2]);
|
$stores[1]->set('foo', $this->objects[2]);
|
||||||
$this->assertIdenticalObject($this->objects[1], $stores[0]->get('foo'));
|
$this->assertEquals($this->objects[1], $stores[0]->get('foo'));
|
||||||
$this->assertIdenticalObject($this->objects[2], $stores[1]->get('foo'));
|
$this->assertEquals($this->objects[2], $stores[1]->get('foo'));
|
||||||
|
|
||||||
// Verify that an item can be deleted.
|
// Verify that an item can be deleted.
|
||||||
$stores[0]->delete('foo');
|
$stores[0]->delete('foo');
|
||||||
|
@ -77,7 +77,7 @@ abstract class StorageTestBase extends KernelTestBase {
|
||||||
|
|
||||||
// Verify that the other collection is not affected.
|
// Verify that the other collection is not affected.
|
||||||
$this->assertTrue($stores[1]->has('foo'));
|
$this->assertTrue($stores[1]->has('foo'));
|
||||||
$this->assertIdenticalObject($this->objects[2], $stores[1]->get('foo'));
|
$this->assertEquals($this->objects[2], $stores[1]->get('foo'));
|
||||||
$stores[1]->delete('foo');
|
$stores[1]->delete('foo');
|
||||||
$this->assertNull($stores[1]->get('foo'));
|
$this->assertNull($stores[1]->get('foo'));
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ abstract class StorageTestBase extends KernelTestBase {
|
||||||
// Verify that multiple items can be retrieved.
|
// Verify that multiple items can be retrieved.
|
||||||
$result = $stores[0]->getMultiple(['foo', 'bar']);
|
$result = $stores[0]->getMultiple(['foo', 'bar']);
|
||||||
foreach ($values as $j => $value) {
|
foreach ($values as $j => $value) {
|
||||||
$this->assertIdenticalObject($value, $result[$j]);
|
$this->assertEquals($value, $result[$j]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify that the other collection was not affected.
|
// Verify that the other collection was not affected.
|
||||||
|
@ -119,7 +119,7 @@ abstract class StorageTestBase extends KernelTestBase {
|
||||||
// Verify that deleting no items does not cause an error.
|
// Verify that deleting no items does not cause an error.
|
||||||
$stores[0]->deleteMultiple([]);
|
$stores[0]->deleteMultiple([]);
|
||||||
// Verify that the item in the other collection still exists.
|
// Verify that the item in the other collection still exists.
|
||||||
$this->assertIdenticalObject($this->objects[5], $stores[1]->get('foo'));
|
$this->assertEquals($this->objects[5], $stores[1]->get('foo'));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,7 +163,7 @@ abstract class StorageTestBase extends KernelTestBase {
|
||||||
// setIfNotExists() should be TRUE the first time (when $i is 0) and
|
// setIfNotExists() should be TRUE the first time (when $i is 0) and
|
||||||
// FALSE the second time (when $i is 1).
|
// FALSE the second time (when $i is 1).
|
||||||
$this->assertEqual(!$i, $stores[0]->setIfNotExists($key, $this->objects[$i]));
|
$this->assertEqual(!$i, $stores[0]->setIfNotExists($key, $this->objects[$i]));
|
||||||
$this->assertIdenticalObject($this->objects[0], $stores[0]->get($key));
|
$this->assertEquals($this->objects[0], $stores[0]->get($key));
|
||||||
// Verify that the other collection is not affected.
|
// Verify that the other collection is not affected.
|
||||||
$this->assertNull($stores[1]->get($key));
|
$this->assertNull($stores[1]->get($key));
|
||||||
}
|
}
|
||||||
|
@ -172,7 +172,7 @@ abstract class StorageTestBase extends KernelTestBase {
|
||||||
$stores[0]->delete($key);
|
$stores[0]->delete($key);
|
||||||
$stores[0]->setIfNotExists($key, $this->objects[1]);
|
$stores[0]->setIfNotExists($key, $this->objects[1]);
|
||||||
// This time it should succeed.
|
// This time it should succeed.
|
||||||
$this->assertIdenticalObject($this->objects[1], $stores[0]->get($key));
|
$this->assertEquals($this->objects[1], $stores[0]->get($key));
|
||||||
// Verify that the other collection is still not affected.
|
// Verify that the other collection is still not affected.
|
||||||
$this->assertNull($stores[1]->get($key));
|
$this->assertNull($stores[1]->get($key));
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,24 +87,24 @@ class TempStoreDatabaseTest extends KernelTestBase {
|
||||||
$this->assertEqual(!$i, $stores[0]->setIfNotExists($key, $this->objects[$i]));
|
$this->assertEqual(!$i, $stores[0]->setIfNotExists($key, $this->objects[$i]));
|
||||||
$metadata = $stores[0]->getMetadata($key);
|
$metadata = $stores[0]->getMetadata($key);
|
||||||
$this->assertEqual($users[0], $metadata->getOwnerId());
|
$this->assertEqual($users[0], $metadata->getOwnerId());
|
||||||
$this->assertIdenticalObject($this->objects[0], $stores[0]->get($key));
|
$this->assertEquals($this->objects[0], $stores[0]->get($key));
|
||||||
// Another user should get the same result.
|
// Another user should get the same result.
|
||||||
$metadata = $stores[1]->getMetadata($key);
|
$metadata = $stores[1]->getMetadata($key);
|
||||||
$this->assertEqual($users[0], $metadata->getOwnerId());
|
$this->assertEqual($users[0], $metadata->getOwnerId());
|
||||||
$this->assertIdenticalObject($this->objects[0], $stores[1]->get($key));
|
$this->assertEquals($this->objects[0], $stores[1]->get($key));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the item and try to set it again.
|
// Remove the item and try to set it again.
|
||||||
$stores[0]->delete($key);
|
$stores[0]->delete($key);
|
||||||
$stores[0]->setIfNotExists($key, $this->objects[1]);
|
$stores[0]->setIfNotExists($key, $this->objects[1]);
|
||||||
// This time it should succeed.
|
// This time it should succeed.
|
||||||
$this->assertIdenticalObject($this->objects[1], $stores[0]->get($key));
|
$this->assertEquals($this->objects[1], $stores[0]->get($key));
|
||||||
|
|
||||||
// This user can update the object.
|
// This user can update the object.
|
||||||
$stores[0]->set($key, $this->objects[2]);
|
$stores[0]->set($key, $this->objects[2]);
|
||||||
$this->assertIdenticalObject($this->objects[2], $stores[0]->get($key));
|
$this->assertEquals($this->objects[2], $stores[0]->get($key));
|
||||||
// The object is the same when another user loads it.
|
// The object is the same when another user loads it.
|
||||||
$this->assertIdenticalObject($this->objects[2], $stores[1]->get($key));
|
$this->assertEquals($this->objects[2], $stores[1]->get($key));
|
||||||
|
|
||||||
// This user should be allowed to get, update, delete.
|
// This user should be allowed to get, update, delete.
|
||||||
$this->assertInstanceOf(\stdClass::class, $stores[0]->getIfOwner($key));
|
$this->assertInstanceOf(\stdClass::class, $stores[0]->getIfOwner($key));
|
||||||
|
@ -113,8 +113,8 @@ class TempStoreDatabaseTest extends KernelTestBase {
|
||||||
|
|
||||||
// Another user can update the object and become the owner.
|
// Another user can update the object and become the owner.
|
||||||
$stores[1]->set($key, $this->objects[3]);
|
$stores[1]->set($key, $this->objects[3]);
|
||||||
$this->assertIdenticalObject($this->objects[3], $stores[0]->get($key));
|
$this->assertEquals($this->objects[3], $stores[0]->get($key));
|
||||||
$this->assertIdenticalObject($this->objects[3], $stores[1]->get($key));
|
$this->assertEquals($this->objects[3], $stores[1]->get($key));
|
||||||
$metadata = $stores[1]->getMetadata($key);
|
$metadata = $stores[1]->getMetadata($key);
|
||||||
$this->assertEqual($users[1], $metadata->getOwnerId());
|
$this->assertEqual($users[1], $metadata->getOwnerId());
|
||||||
|
|
||||||
|
|
|
@ -318,4 +318,14 @@ class KernelTestBaseTest extends KernelTestBase {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the deprecation of AssertLegacyTrait::assertIdenticalObject.
|
||||||
|
*
|
||||||
|
* @group legacy
|
||||||
|
* @expectedDeprecation AssertLegacyTrait::assertIdenticalObject() 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
|
||||||
|
*/
|
||||||
|
public function testAssertIdenticalObject() {
|
||||||
|
$this->assertIdenticalObject((object) ['foo' => 'bar'], (object) ['foo' => 'bar']);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,7 +172,6 @@ trait DeprecationListenerTrait {
|
||||||
'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::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::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::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::assertIdenticalObject() 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::pass() is deprecated in drupal:8.0.0 and is removed from drupal:10.0.0. PHPUnit interrupts a test as soon as a test assertion fails, so there is usually no need to call this method. If a test\'s logic relies on this method, refactor the test. See https://www.drupal.org/node/3129738',
|
'AssertLegacyTrait::pass() is deprecated in drupal:8.0.0 and is removed from drupal:10.0.0. PHPUnit interrupts a test as soon as a test assertion fails, so there is usually no need to call this method. If a test\'s logic relies on this method, refactor the test. See https://www.drupal.org/node/3129738',
|
||||||
'AssertLegacyTrait::assertElementPresent() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->elementExists() instead. See https://www.drupal.org/node/3129738',
|
'AssertLegacyTrait::assertElementPresent() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->elementExists() instead. See https://www.drupal.org/node/3129738',
|
||||||
'AssertLegacyTrait::assertElementNotPresent() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->elementNotExists() instead. See https://www.drupal.org/node/3129738',
|
'AssertLegacyTrait::assertElementNotPresent() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->elementNotExists() instead. See https://www.drupal.org/node/3129738',
|
||||||
|
|
Loading…
Reference in New Issue