Commit 280c02e7 authored by catch's avatar catch
Browse files

Issue #3131474 by jungle, mondrake: Replace assertions involving calls to...

Issue #3131474 by jungle, mondrake: Replace assertions involving calls to array_search() with assertContains()/assertNotContains()

(cherry picked from commit 6cf25ba2)
parent 94577161
......@@ -119,7 +119,7 @@ public function testReferenceablesWithNoLabelKey($match, $match_operator, $limit
// entity labels.
// @see \Drupal\Core\Entity\EntityReferenceSelection\SelectionInterface::getReferenceableEntities()
$item = is_string($item) ? Html::escape($item) : $item;
$this->assertTrue(array_search($item, $referenceables[$this->bundle]) !== FALSE);
$this->assertContains($item, $referenceables[$this->bundle]);
}
// Test ::countReferenceableEntities().
......
......@@ -89,10 +89,10 @@ private function userLoadAndCheckRoleAssigned($account, $rid, $is_assigned = TRU
$user_storage->resetCache([$account->id()]);
$account = $user_storage->load($account->id());
if ($is_assigned) {
$this->assertFalse(array_search($rid, $account->getRoles()) === FALSE, 'The role is present in the user object.');
$this->assertContains($rid, $account->getRoles());
}
else {
$this->assertTrue(array_search($rid, $account->getRoles()) === FALSE, 'The role is not present in the user object.');
$this->assertNotContains($rid, $account->getRoles());
}
}
......
......@@ -2,7 +2,6 @@
namespace Drupal\Tests\views_ui\Kernel;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
use Drupal\views_ui\Controller\ViewsUIController;
use Drupal\Component\Utility\Html;
......@@ -59,7 +58,7 @@ public function testViewsUiAutocompleteTag() {
$matches = (array) json_decode($result->getContent(), TRUE);
$this->assertEqual(count($matches), 8, 'Make sure that only a subset is returned.');
foreach ($matches as $tag) {
$this->assertTrue(array_search($tag['value'], $tags) !== FALSE, new FormattableMarkup('Make sure the returned tag @tag actually exists.', ['@tag' => $tag['value']]));
$this->assertContains($tag['value'], $tags);
}
// Make sure an invalid result doesn't return anything.
......
......@@ -139,7 +139,7 @@ public function testCompileDIC() {
// Check that the container itself is not among the persist IDs because it
// does not make sense to persist the container itself.
$persist_ids = $container->getParameter('persist_ids');
$this->assertFalse(array_search('service_container', $persist_ids));
$this->assertNotContains('service_container', $persist_ids);
}
/**
......
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