From 809cfa14a6578cd2016cb406b57cde4ea6928622 Mon Sep 17 00:00:00 2001
From: xjm <xjm@65776.no-reply.drupal.org>
Date: Mon, 4 May 2020 12:36:46 -0500
Subject: [PATCH] Issue #3131819 by jungle, mondrake, xjm, dww: Replace
 assertions involving calls to is_resource() with assertIsResource()

---
 .../Drupal/KernelTests/Core/Image/ToolkitGdTest.php  | 12 +++++++++---
 .../KernelTests/Core/TypedData/TypedDataTest.php     |  2 +-
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php b/core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php
index 08b4d91e813e..771f7779dfc3 100644
--- a/core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php
@@ -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);
   }
 
   /**
diff --git a/core/tests/Drupal/KernelTests/Core/TypedData/TypedDataTest.php b/core/tests/Drupal/KernelTests/Core/TypedData/TypedDataTest.php
index f017aafe74ba..9792a8917930 100644
--- a/core/tests/Drupal/KernelTests/Core/TypedData/TypedDataTest.php
+++ b/core/tests/Drupal/KernelTests/Core/TypedData/TypedDataTest.php
@@ -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());
-- 
GitLab