Skip to content
Snippets Groups Projects
Commit 809cfa14 authored by Jess's avatar Jess
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()
parent 07dd3e2c
Branches
Tags
8 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!1012Issue #3226887: Hreflang on non-canonical content pages,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10,!596Issue #3046532: deleting an entity reference field, used in a contextual view, makes the whole site unrecoverable,!496Issue #2463967: Use .user.ini file for PHP settings,!144Issue #2666286: Clean up menu_ui to conform to Drupal coding standards,!16Draft: Resolve #2081585 "History storage",!13Resolve #2903456
......@@ -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());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment