Issue #3131474 by jungle, mondrake: Replace assertions involving calls to array_search() with assertContains()/assertNotContains()
parent
629abc963b
commit
6cf25ba266
|
@ -119,7 +119,7 @@ class EntityReferenceSelectionReferenceableTest extends KernelTestBase {
|
|||
// 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 @@ class UserRolesAssignmentTest extends BrowserTestBase {
|
|||
$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 @@ class TagTest extends ViewsKernelTestBase {
|
|||
$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 @@ class DrupalKernelTest extends KernelTestBase {
|
|||
// 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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue