Commit aacc8814 authored by xjm's avatar xjm
Browse files

Issue #3131818 by jungle, mero.S: Replace assertions involving calls to...

Issue #3131818 by jungle, mero.S: Replace assertions involving calls to is_object() with assertIsObject()/assertIsObject()

(cherry picked from commit 2718a80a)
parent 9a6a0595
......@@ -46,7 +46,7 @@ public function testSingleValues() {
$file = $this->createFile('druplicon.txt', NULL, 'public');
$by_fid_file = File::load($file->id());
$this->assertFileHookCalled('load');
$this->assertTrue(is_object($by_fid_file), '\Drupal\file\Entity\File::load() returned an object.');
$this->assertIsObject($by_fid_file);
$this->assertEqual($by_fid_file->id(), $file->id(), 'Loading by fid got the same fid.', 'File');
$this->assertEqual($by_fid_file->getFileUri(), $file->getFileUri(), 'Loading by fid got the correct filepath.', 'File');
$this->assertEqual($by_fid_file->getFilename(), $file->getFilename(), 'Loading by fid got the correct filename.', 'File');
......
......@@ -58,7 +58,7 @@ public function testNodeMultipleLoad() {
$this->assertTrue(isset($nodes[$node2->id()]), 'Node is correctly keyed in the array');
$this->assertTrue(isset($nodes[$node4->id()]), 'Node is correctly keyed in the array');
foreach ($nodes as $node) {
$this->assertTrue(is_object($node), 'Node is an object');
$this->assertIsObject($node);
}
}
......
......@@ -63,7 +63,7 @@ public function testRoleAdministration() {
$this->drupalPostForm('admin/people/roles/add', $edit, t('Save'));
$this->assertRaw(t('Role %label has been added.', ['%label' => 123]));
$role = Role::load($role_name);
$this->assertTrue(is_object($role), 'The role was successfully retrieved from the database.');
$this->assertIsObject($role);
// Check that the role was created in site default language.
$this->assertEqual($role->language()->getId(), $default_langcode);
......
......@@ -32,7 +32,7 @@ public function testGetAvailableToolkits() {
*/
public function testLoad() {
$image = $this->getImage();
$this->assertTrue(is_object($image), 'Returned an object.');
$this->assertIsObject($image);
$this->assertEqual($image->getToolkitId(), 'test', 'Image had toolkit set.');
$this->assertToolkitOperationsCalled(['parseFile']);
}
......
......@@ -134,7 +134,7 @@ public function testSetGet() {
$with_backslash = ['foo' => '\Drupal\foo\Bar'];
$backend->set('test1', $with_backslash);
$cached = $backend->get('test1');
$this->assert(is_object($cached), "Backend returned an object for cache id test1.");
$this->assertIsObject($cached);
$this->assertSame($with_backslash, $cached->data);
$this->assertTrue($cached->valid, 'Item is marked as valid.');
// We need to round because microtime may be rounded up in the backend.
......@@ -144,7 +144,7 @@ public function testSetGet() {
$this->assertFalse($backend->get('test2'), "Backend does not contain data for cache id test2.");
$backend->set('test2', ['value' => 3], REQUEST_TIME + 3);
$cached = $backend->get('test2');
$this->assert(is_object($cached), "Backend returned an object for cache id test2.");
$this->assertIsObject($cached);
$this->assertSame(['value' => 3], $cached->data);
$this->assertTrue($cached->valid, 'Item is marked as valid.');
$this->assertTrue($cached->created >= REQUEST_TIME && $cached->created <= round(microtime(TRUE), 3), 'Created time is correct.');
......@@ -153,7 +153,7 @@ public function testSetGet() {
$backend->set('test3', 'foobar', REQUEST_TIME - 3);
$this->assertFalse($backend->get('test3'), 'Invalid item not returned.');
$cached = $backend->get('test3', TRUE);
$this->assert(is_object($cached), 'Backend returned an object for cache id test3.');
$this->assertIsObject($cached);
$this->assertFalse($cached->valid, 'Item is marked as valid.');
$this->assertTrue($cached->created >= REQUEST_TIME && $cached->created <= round(microtime(TRUE), 3), 'Created time is correct.');
$this->assertEqual($cached->expire, REQUEST_TIME - 3, 'Expire time is correct.');
......@@ -162,7 +162,7 @@ public function testSetGet() {
$with_eof = ['foo' => "\nEOF\ndata"];
$backend->set('test4', $with_eof);
$cached = $backend->get('test4');
$this->assert(is_object($cached), "Backend returned an object for cache id test4.");
$this->assertIsObject($cached);
$this->assertSame($with_eof, $cached->data);
$this->assertTrue($cached->valid, 'Item is marked as valid.');
$this->assertTrue($cached->created >= REQUEST_TIME && $cached->created <= round(microtime(TRUE), 3), 'Created time is correct.');
......@@ -172,7 +172,7 @@ public function testSetGet() {
$with_eof_and_semicolon = ['foo' => "\nEOF;\ndata"];
$backend->set('test5', $with_eof_and_semicolon);
$cached = $backend->get('test5');
$this->assert(is_object($cached), "Backend returned an object for cache id test5.");
$this->assertIsObject($cached);
$this->assertSame($with_eof_and_semicolon, $cached->data);
$this->assertTrue($cached->valid, 'Item is marked as valid.');
$this->assertTrue($cached->created >= REQUEST_TIME && $cached->created <= round(microtime(TRUE), 3), 'Created time is correct.');
......@@ -181,7 +181,7 @@ public function testSetGet() {
$with_variable = ['foo' => '$bar'];
$backend->set('test6', $with_variable);
$cached = $backend->get('test6');
$this->assert(is_object($cached), "Backend returned an object for cache id test6.");
$this->assertIsObject($cached);
$this->assertSame($with_variable, $cached->data);
// Make sure that a cached object is not affected by changing the original.
......@@ -194,7 +194,7 @@ public function testSetGet() {
// Add a property to the original. It should not appear in the cached data.
$data->this_should_not_be_in_the_cache = TRUE;
$cached = $backend->get('test7');
$this->assert(is_object($cached), "Backend returned an object for cache id test7.");
$this->assertIsObject($cached);
$this->assertEqual($expected_data, $cached->data);
$this->assertFalse(isset($cached->data->this_should_not_be_in_the_cache));
// Add a property to the cache data. It should not appear when we fetch
......@@ -231,16 +231,16 @@ public function testDelete() {
$this->assertFalse($backend->get('test1'), "Backend does not contain data for cache id test1.");
$backend->set('test1', 7);
$this->assert(is_object($backend->get('test1')), "Backend returned an object for cache id test1.");
$this->assertIsObject($backend->get('test1'));
$this->assertFalse($backend->get('test2'), "Backend does not contain data for cache id test2.");
$backend->set('test2', 3);
$this->assert(is_object($backend->get('test2')), "Backend returned an object for cache id %cid.");
$this->assertIsObject($backend->get('test2'));
$backend->delete('test1');
$this->assertFalse($backend->get('test1'), "Backend does not contain data for cache id test1 after deletion.");
$this->assert(is_object($backend->get('test2')), "Backend still has an object for cache id test2.");
$this->assertIsObject($backend->get('test2'));
$backend->delete('test2');
$this->assertFalse($backend->get('test2'), "Backend does not contain data for cache id test2 after deletion.");
......@@ -274,7 +274,7 @@ public function testValueTypeIsKept() {
// Retrieve and test cache objects.
foreach ($variables as $cid => $value) {
$object = $backend->get($cid);
$this->assert(is_object($object), sprintf("Backend returned an object for cache id %s.", $cid));
$this->assertIsObject($object, sprintf("Backend returned an object for cache id %s.", $cid));
$this->assertSame($value, $object->data, sprintf("Data of cached id %s kept is identical in type and value", $cid));
}
}
......
......@@ -185,7 +185,7 @@ public function testGetControllerFromDefinitionNotCallable() {
*/
protected function assertCallableController($controller, $class, $output) {
if ($class) {
$this->assertTrue(is_object($controller[0]));
$this->assertIsObject($controller[0]);
$this->assertInstanceOf($class, $controller[0]);
}
$this->assertIsCallable($controller);
......
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