Commit c6bc8011 authored by xjm's avatar xjm
Browse files

Issue #3131819 by jungle, mondrake, xjm, dww: Replace assertions involving...

Issue #3131819 by jungle, mondrake, xjm, dww: Replace assertions involving calls to is_resource() with assertIsResource()

(cherry picked from commit 809cfa14)
parent 5d0d3ed0
......@@ -302,6 +302,8 @@ public function testManipulations() {
// been destroyed.
$new_res = $toolkit->getResource();
if ($new_res !== $old_res) {
// @todo In https://www.drupal.org/node/3133236 convert this to
// $this->assertIsNotResource($old_res).
$this->assertFalse(is_resource($old_res), new FormattableMarkup("'%operation' destroyed the original resource.", ['%operation' => $values['function']]));
}
......@@ -428,21 +430,25 @@ public function testResourceDestruction() {
// Test that an Image object going out of scope releases its GD resource.
$image = $this->imageFactory->get('core/tests/fixtures/files/image-test.png');
$res = $image->getToolkit()->getResource();
$this->assertTrue(is_resource($res), 'Successfully loaded image resource.');
$this->assertIsResource($res);
$image = NULL;
// @todo In https://www.drupal.org/node/3133236 convert this to
// $this->assertIsNotResource($res).
$this->assertFalse(is_resource($res), 'Image resource was destroyed after losing scope.');
// Test that 'create_new' operation does not leave orphaned GD resources.
$image = $this->imageFactory->get('core/tests/fixtures/files/image-test.png');
$old_res = $image->getToolkit()->getResource();
// Check if resource has been created successfully.
$this->assertTrue(is_resource($old_res));
$this->assertIsResource($old_res);
$image->createNew(20, 20);
$new_res = $image->getToolkit()->getResource();
// Check if the original resource has been destroyed.
// @todo In https://www.drupal.org/node/3133236 convert this to
// $this->assertIsNotResource($old_res).
$this->assertFalse(is_resource($old_res));
// Check if a new resource has been created successfully.
$this->assertTrue(is_resource($new_res));
$this->assertIsResource($new_res);
}
/**
......
......@@ -315,7 +315,7 @@ public function testGetAndSet() {
// Binary type.
$typed_data = $this->createTypedData(['type' => 'binary'], $files[0]->getFileUri());
$this->assertInstanceOf(BinaryInterface::class, $typed_data);
$this->assertTrue(is_resource($typed_data->getValue()), 'Binary value was fetched.');
$this->assertIsResource($typed_data->getValue());
$this->assertEqual($typed_data->validate()->count(), 0);
// Try setting by URI.
$typed_data->setValue($files[1]->getFileUri());
......
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