Commit 421c588c authored by catch's avatar catch

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

Issue #3131343 by mondrake, dww, jungle: Replace assertions involving calls to in_array() with assertContains()/assertNotContains()
parent 6685ea27
......@@ -70,16 +70,16 @@ public function testBlockLinks() {
$this->assert(isset($links[0]), new FormattableMarkup('Link to href %href found.', ['%href' => $href]));
$cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags');
$cache_tags = explode(' ', $cache_tags_header);
$this->assertTrue(in_array('aggregator_feed:' . $feed->id(), $cache_tags));
$this->assertContains('aggregator_feed:' . $feed->id(), $cache_tags);
// Visit that page.
$this->drupalGet($feed->toUrl()->getInternalPath());
$correct_titles = $this->xpath('//h1[normalize-space(text())=:title]', [':title' => $feed->label()]);
$this->assertFalse(empty($correct_titles), 'Aggregator feed page is available and has the correct title.');
$cache_tags = explode(' ', $this->drupalGetHeader('X-Drupal-Cache-Tags'));
$this->assertTrue(in_array('aggregator_feed:' . $feed->id(), $cache_tags));
$this->assertTrue(in_array('aggregator_feed_view', $cache_tags));
$this->assertTrue(in_array('aggregator_item_view', $cache_tags));
$this->assertContains('aggregator_feed:' . $feed->id(), $cache_tags);
$this->assertContains('aggregator_feed_view', $cache_tags);
$this->assertContains('aggregator_item_view', $cache_tags);
// Set the number of news items to 0 to test that the block does not show
// up.
......@@ -122,7 +122,7 @@ public function testFeedPage() {
$this->assertTrue(isset($links[0]), new FormattableMarkup('Link to href %href found.', ['%href' => $href]));
$cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags');
$cache_tags = explode(' ', $cache_tags_header);
$this->assertTrue(in_array('aggregator_feed:' . $feed->id(), $cache_tags));
$this->assertContains('aggregator_feed:' . $feed->id(), $cache_tags);
// Check the rss aggregator page as anonymous user.
$this->drupalLogout();
......@@ -151,9 +151,9 @@ public function testFeedPage() {
$elements = $this->xpath("//ul[contains(@class, :class)]", [':class' => 'pager__items']);
$this->assertTrue(!empty($elements), 'Individual source page contains a pager.');
$cache_tags = explode(' ', $this->drupalGetHeader('X-Drupal-Cache-Tags'));
$this->assertTrue(in_array('aggregator_feed:' . $feed->id(), $cache_tags));
$this->assertTrue(in_array('aggregator_feed_view', $cache_tags));
$this->assertTrue(in_array('aggregator_item_view', $cache_tags));
$this->assertContains('aggregator_feed:' . $feed->id(), $cache_tags);
$this->assertContains('aggregator_feed_view', $cache_tags);
$this->assertContains('aggregator_item_view', $cache_tags);
}
}
......@@ -188,7 +188,7 @@ public function testBigPipe() {
$this->pass('Verifying BigPipe assets are present…', 'Debug');
$this->assertFalse(empty($this->getDrupalSettings()), 'drupalSettings present.');
$this->assertTrue(in_array('big_pipe/big_pipe', explode(',', $this->getDrupalSettings()['ajaxPageState']['libraries'])), 'BigPipe asset library is present.');
$this->assertContains('big_pipe/big_pipe', explode(',', $this->getDrupalSettings()['ajaxPageState']['libraries']), 'BigPipe asset library is present.');
// Verify that the two expected exceptions are logged as errors.
$this->assertEqual($log_count + 2, $connection->query('SELECT COUNT(*) FROM {watchdog}')->fetchField(), 'Two new watchdog entries.');
......
......@@ -124,7 +124,7 @@ public function testLoading() {
$this->assertCount(1, $format_selector, 'A single text format selector exists on the page.');
$specific_format_selector = $this->xpath('//select[contains(@class, "filter-list") and @data-editor-for="edit-body-0-value"]');
$this->assertCount(1, $specific_format_selector, 'A single text format selector exists on the page and has a "data-editor-for" attribute with the correct value.');
$this->assertTrue(in_array('ckeditor/drupal.ckeditor', explode(',', $settings['ajaxPageState']['libraries'])), 'CKEditor glue library is present.');
$this->assertContains('ckeditor/drupal.ckeditor', explode(',', $settings['ajaxPageState']['libraries']), 'CKEditor glue library is present.');
// Enable the ckeditor_test module, customize configuration. In this case,
// there is additional CSS and JS to be loaded.
......@@ -153,7 +153,7 @@ public function testLoading() {
$this->assertTrue($editor_settings_present, "Text Editor module's JavaScript settings are on the page.");
$this->assertIdentical($expected, $this->castSafeStrings($settings['editor']), "Text Editor module's JavaScript settings on the page are correct.");
$this->assertTrue($editor_js_present, 'Text Editor JavaScript is present.');
$this->assertTrue(in_array('ckeditor/drupal.ckeditor', explode(',', $settings['ajaxPageState']['libraries'])), 'CKEditor glue library is present.');
$this->assertContains('ckeditor/drupal.ckeditor', explode(',', $settings['ajaxPageState']['libraries']), 'CKEditor glue library is present.');
// Assert that CKEditor uses Drupal's cache-busting query string by
// comparing the setting sent with the page with the current query string.
......
......@@ -53,12 +53,12 @@ public function testGetConfig($language_list, $expected_number) {
$config = $this->plugin->getConfig($editor);
$this->assertIsArray($config);
$this->assertTrue(in_array('ar:Arabic:rtl', $config['language_list']));
$this->assertTrue(in_array('zh-hans:Chinese, Simplified', $config['language_list']));
$this->assertTrue(in_array('en:English', $config['language_list']));
$this->assertTrue(in_array('fr:French', $config['language_list']));
$this->assertTrue(in_array('ru:Russian', $config['language_list']));
$this->assertTrue(in_array('ar:Arabic:rtl', $config['language_list']));
$this->assertContains('ar:Arabic:rtl', $config['language_list']);
$this->assertContains('zh-hans:Chinese, Simplified', $config['language_list']);
$this->assertContains('en:English', $config['language_list']);
$this->assertContains('fr:French', $config['language_list']);
$this->assertContains('ru:Russian', $config['language_list']);
$this->assertContains('ar:Arabic:rtl', $config['language_list']);
$this->assertEquals($expected_number, count($config['language_list']));
}
......
......@@ -134,7 +134,7 @@ public function testCommentTokenReplacement() {
$metadata_tests['[comment:author:name]'] = $bubbleable_metadata;
// Test to make sure that we generated something for each token.
$this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.');
$this->assertNotContains(0, array_map('strlen', $tests), 'No empty tokens generated.');
foreach ($tests as $input => $expected) {
$bubbleable_metadata = new BubbleableMetadata();
......
......@@ -56,11 +56,11 @@ public function testCommentItem() {
$entity = EntityTest::create();
$entity->comment->generateSampleItems();
$this->entityValidateAndSave($entity);
$this->assertTrue(in_array($entity->get('comment')->status, [
$this->assertContains($entity->get('comment')->status, [
CommentItemInterface::HIDDEN,
CommentItemInterface::CLOSED,
CommentItemInterface::OPEN,
]), 'Comment status value in defined range');
], 'Comment status value in defined range');
$mainProperty = $entity->comment[0]->mainPropertyName();
$this->assertEqual('status', $mainProperty);
......
......@@ -268,12 +268,12 @@ public function testExportImportCollections() {
foreach ($content_list as $file) {
$files[] = $file['filename'];
}
$this->assertTrue(in_array('collection/test1/config_test.create.yml', $files), 'Config export contains collection/test1/config_test.create.yml.');
$this->assertTrue(in_array('collection/test2/config_test.another_create.yml', $files), 'Config export contains collection/test2/config_test.another_create.yml.');
$this->assertTrue(in_array('collection/test1/config_test.update.yml', $files), 'Config export contains collection/test1/config_test.update.yml.');
$this->assertTrue(in_array('collection/test2/config_test.another_update.yml', $files), 'Config export contains collection/test2/config_test.another_update.yml.');
$this->assertFalse(in_array('collection/test1/config_test.delete.yml', $files), 'Config export does not contain collection/test1/config_test.delete.yml.');
$this->assertFalse(in_array('collection/test2/config_test.another_delete.yml', $files), 'Config export does not contain collection/test2/config_test.another_delete.yml.');
$this->assertContains('collection/test1/config_test.create.yml', $files, 'Config export contains collection/test1/config_test.create.yml.');
$this->assertContains('collection/test2/config_test.another_create.yml', $files, 'Config export contains collection/test2/config_test.another_create.yml.');
$this->assertContains('collection/test1/config_test.update.yml', $files, 'Config export contains collection/test1/config_test.update.yml.');
$this->assertContains('collection/test2/config_test.another_update.yml', $files, 'Config export contains collection/test2/config_test.another_update.yml.');
$this->assertNotContains('collection/test1/config_test.delete.yml', $files, 'Config export does not contain collection/test1/config_test.delete.yml.');
$this->assertNotContains('collection/test2/config_test.another_delete.yml', $files, 'Config export does not contain collection/test2/config_test.another_delete.yml.');
$this->drupalPostForm('admin/config/development/configuration/full/import', ['files[import_tarball]' => $filename], 'Upload');
// Verify that there are configuration differences to import.
......
......@@ -135,7 +135,7 @@ public function testEntityGetterAndSetter() {
// Ensure that the configuration name was added to the mapper.
$plugin_definition = $this->configEntityMapper->getPluginDefinition();
$this->assertTrue(in_array('config_prefix.entity_id', $plugin_definition['names']));
$this->assertContains('config_prefix.entity_id', $plugin_definition['names']);
// Make sure setEntity() returns FALSE when called a second time.
$result = $this->configEntityMapper->setEntity($this->entity);
......
......@@ -111,7 +111,7 @@ public function testSetEntity() {
// Ensure that the configuration name was added to the mapper.
$plugin_definition = $this->configFieldMapper->getPluginDefinition();
$this->assertTrue(in_array('config_prefix.field_storage_id', $plugin_definition['names']));
$this->assertContains('config_prefix.field_storage_id', $plugin_definition['names']);
// Make sure setEntity() returns FALSE when called a second time.
$result = $this->configFieldMapper->setEntity($this->entity);
......
......@@ -602,7 +602,7 @@ public function testWorkflowDependencies() {
$node_type->delete();
$workflow = Workflow::load('editorial');
$entity_types = $workflow->getTypePlugin()->getEntityTypes();
$this->assertFalse(in_array('node', $entity_types));
$this->assertNotContains('node', $entity_types);
// Uninstall entity test and ensure it's removed from the workflow.
$this->container->get('config.manager')->uninstall('module', 'entity_test');
......
......@@ -112,9 +112,9 @@ public function testLanguageChange() {
// Check that the translation languages are correct.
$node = $this->getNodeByTitle('english_title');
$translation_languages = array_keys($node->getTranslationLanguages());
$this->assertTrue(in_array('fr', $translation_languages));
$this->assertTrue(in_array('de', $translation_languages));
$translation_languages = $node->getTranslationLanguages();
$this->assertArrayHasKey('fr', $translation_languages);
$this->assertArrayHasKey('de', $translation_languages);
}
/**
......@@ -159,9 +159,9 @@ public function testTitleDoesNotChangesOnChangingLanguageWidgetAndTriggeringAjax
// Check that the translation languages are correct.
$node = $this->getNodeByTitle('english_title');
$translation_languages = array_keys($node->getTranslationLanguages());
$this->assertTrue(in_array('fr', $translation_languages));
$this->assertTrue(!in_array('de', $translation_languages));
$translation_languages = $node->getTranslationLanguages();
$this->assertArrayHasKey('fr', $translation_languages);
$this->assertArrayNotHasKey('de', $translation_languages);
}
}
......@@ -93,10 +93,10 @@ public function testRelationship() {
$view = Views::getView('dblog_integration_test');
$view->setDisplay('page_1');
// The uid relationship should now join to the {users_field_data} table.
$tables = array_keys($view->getBaseTables());
$this->assertTrue(in_array('users_field_data', $tables));
$this->assertFalse(in_array('users', $tables));
$this->assertTrue(in_array('watchdog', $tables));
$base_tables = $view->getBaseTables();
$this->assertArrayHasKey('users_field_data', $base_tables);
$this->assertArrayNotHasKey('users', $base_tables);
$this->assertArrayHasKey('watchdog', $base_tables);
}
/**
......
......@@ -148,15 +148,15 @@ public function testEntityReferenceDefaultConfigValue() {
// Check that the field has a dependency on the default value.
$config_entity = $this->config('field.field.node.reference_content.' . $field_name)->get();
$this->assertTrue(in_array($referenced_node_type->getConfigDependencyName(), $config_entity['dependencies']['config'], TRUE), 'The node type referenced_config_to_delete is a dependency of the field.');
$this->assertTrue(in_array($referenced_node_type2->getConfigDependencyName(), $config_entity['dependencies']['config'], TRUE), 'The node type referenced_config_to_preserve is a dependency of the field.');
$this->assertContains($referenced_node_type->getConfigDependencyName(), $config_entity['dependencies']['config'], 'The node type referenced_config_to_delete is a dependency of the field.');
$this->assertContains($referenced_node_type2->getConfigDependencyName(), $config_entity['dependencies']['config'], 'The node type referenced_config_to_preserve is a dependency of the field.');
// Check that the field does not have a dependency on the default value
// after deleting the node type.
$referenced_node_type->delete();
$config_entity = $this->config('field.field.node.reference_content.' . $field_name)->get();
$this->assertFalse(in_array($referenced_node_type->getConfigDependencyName(), $config_entity['dependencies']['config'], TRUE), 'The node type referenced_config_to_delete not a dependency of the field.');
$this->assertTrue(in_array($referenced_node_type2->getConfigDependencyName(), $config_entity['dependencies']['config'], TRUE), 'The node type referenced_config_to_preserve is a dependency of the field.');
$this->assertNotContains($referenced_node_type->getConfigDependencyName(), $config_entity['dependencies']['config'], 'The node type referenced_config_to_delete not a dependency of the field.');
$this->assertContains($referenced_node_type2->getConfigDependencyName(), $config_entity['dependencies']['config'], 'The node type referenced_config_to_preserve is a dependency of the field.');
}
}
......@@ -163,7 +163,7 @@ public function testSupportedEntityTypesAndWidgets() {
// Ensure the configuration has the expected dependency on the entity that
// is being used a default value.
$field = FieldConfig::loadByName($this->entityType, $this->bundle, $this->fieldName);
$this->assertTrue(in_array($referenced_entities[0]->getConfigDependencyName(), $field->getDependencies()[$key]), new FormattableMarkup('Expected @type dependency @name found', ['@type' => $key, '@name' => $referenced_entities[0]->getConfigDependencyName()]));
$this->assertContains($referenced_entities[0]->getConfigDependencyName(), $field->getDependencies()[$key], new FormattableMarkup('Expected @type dependency @name found', ['@type' => $key, '@name' => $referenced_entities[0]->getConfigDependencyName()]));
// Ensure that the field can be imported without change even after the
// default value deleted.
$referenced_entities[0]->delete();
......
......@@ -178,7 +178,7 @@ public function testCustomCacheTagFormatter() {
$build = $this->buildRenderArray([$this->referencedEntity], $formatter);
$renderer->renderRoot($build);
$this->assertTrue(in_array('custom_cache_tag', $build['#cache']['tags']));
$this->assertContains('custom_cache_tag', $build['#cache']['tags']);
}
/**
......
......@@ -18,7 +18,7 @@ public function testWidgetDefinitionAlter() {
$widget_definition = \Drupal::service('plugin.manager.field.widget')->getDefinition('test_field_widget_multiple');
// Test if hook_field_widget_info_alter is being called.
$this->assertTrue(in_array('test_field', $widget_definition['field_types']), "The 'test_field_widget_multiple' widget is enabled for the 'test_field' field type in field_test_field_widget_info_alter().");
$this->assertContains('test_field', $widget_definition['field_types'], "The 'test_field_widget_multiple' widget is enabled for the 'test_field' field type in field_test_field_widget_info_alter().");
}
/**
......
......@@ -92,7 +92,7 @@ public function testDeleteField() {
$this->assertTrue($view->status());
// Test that the View depends on the field.
$dependencies = $view->getDependencies() + ['config' => []];
$this->assertTrue(in_array("field.storage.node.$field_name", $dependencies['config']));
$this->assertContains("field.storage.node.$field_name", $dependencies['config']);
// Check the config dependencies of the first field, the field storage must
// not be shown as being deleted yet.
......@@ -133,7 +133,7 @@ public function testDeleteField() {
$this->assertFalse($view->status());
// Test that the View no longer depends on the deleted field.
$dependencies = $view->getDependencies() + ['config' => []];
$this->assertFalse(in_array("field.storage.node.$field_name", $dependencies['config']));
$this->assertNotContains("field.storage.node.$field_name", $dependencies['config']);
}
}
......@@ -173,7 +173,7 @@ public function testFormatterUI() {
/** @var \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display */
$display = $display_storage->loadUnchanged($id);
$this->assertEquals($display->getRenderer('field_test')->getThirdPartySetting('field_third_party_test', 'field_test_field_formatter_third_party_settings_form'), 'foo');
$this->assertTrue(in_array('field_third_party_test', $display->calculateDependencies()->getDependencies()['module']), 'The display has a dependency on field_third_party_test module.');
$this->assertContains('field_third_party_test', $display->calculateDependencies()->getDependencies()['module'], 'The display has a dependency on field_third_party_test module.');
// Change the formatter to an empty setting and validate it's initialized
// correctly.
......@@ -320,7 +320,7 @@ public function testWidgetUI() {
/** @var \Drupal\Core\Entity\Display\EntityFormDisplayInterface $display */
$display = $form_storage->loadUnchanged('node.' . $this->type . '.default');
$this->assertEquals($display->getRenderer('field_test')->getThirdPartySetting('field_third_party_test', 'field_test_widget_third_party_settings_form'), 'foo');
$this->assertTrue(in_array('field_third_party_test', $display->calculateDependencies()->getDependencies()['module']), 'Form display does not have a dependency on field_third_party_test module.');
$this->assertContains('field_third_party_test', $display->calculateDependencies()->getDependencies()['module'], 'Form display does not have a dependency on field_third_party_test module.');
// Creates a new field that can not be used with the multiple formatter.
// Reference: Drupal\field_test\Plugin\Field\FieldWidget\TestFieldWidgetMultiple::isApplicable().
......
......@@ -82,7 +82,7 @@ public function testFileTokenReplacement() {
$metadata_tests['[file:owner:uid]'] = $bubbleable_metadata;
// Test to make sure that we generated something for each token.
$this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.');
$this->assertNotContains(0, array_map('strlen', $tests), 'No empty tokens generated.');
foreach ($tests as $input => $expected) {
$bubbleable_metadata = new BubbleableMetadata();
......
......@@ -136,9 +136,9 @@ public function testFormatPermissions() {
// Perform similar checks as above, but now against the entire list of
// available formats for this user.
$this->assertTrue(in_array($this->allowedFormat->id(), array_keys(filter_formats($this->webUser))), 'The allowed format appears in the list of available formats for a regular user.');
$this->assertFalse(in_array($this->disallowedFormat->id(), array_keys(filter_formats($this->webUser))), 'The disallowed format does not appear in the list of available formats for a regular user.');
$this->assertTrue(in_array(filter_fallback_format(), array_keys(filter_formats($this->webUser))), 'The fallback format appears in the list of available formats for a regular user.');
$this->assertContains($this->allowedFormat->id(), array_keys(filter_formats($this->webUser)), 'The allowed format appears in the list of available formats for a regular user.');
$this->assertNotContains($this->disallowedFormat->id(), array_keys(filter_formats($this->webUser)), 'The disallowed format does not appear in the list of available formats for a regular user.');
$this->assertContains(filter_fallback_format(), array_keys(filter_formats($this->webUser)), 'The fallback format appears in the list of available formats for a regular user.');
// Make sure that a regular user only has permission to use the format
// they were granted access to.
......@@ -194,17 +194,17 @@ public function testFormatRoles() {
// Check that this role appears in the list of roles that have access to an
// allowed text format, but does not appear in the list of roles that have
// access to a disallowed text format.
$this->assertTrue(in_array($rid, array_keys(filter_get_roles_by_format($this->allowedFormat))), 'A role which has access to a text format appears in the list of roles that have access to that format.');
$this->assertFalse(in_array($rid, array_keys(filter_get_roles_by_format($this->disallowedFormat))), 'A role which does not have access to a text format does not appear in the list of roles that have access to that format.');
$this->assertContains($rid, array_keys(filter_get_roles_by_format($this->allowedFormat)), 'A role which has access to a text format appears in the list of roles that have access to that format.');
$this->assertNotContains($rid, array_keys(filter_get_roles_by_format($this->disallowedFormat)), 'A role which does not have access to a text format does not appear in the list of roles that have access to that format.');
// Check that the correct text format appears in the list of formats
// available to that role.
$this->assertTrue(in_array($this->allowedFormat->id(), array_keys(filter_get_formats_by_role($rid))), 'A text format which a role has access to appears in the list of formats available to that role.');
$this->assertFalse(in_array($this->disallowedFormat->id(), array_keys(filter_get_formats_by_role($rid))), 'A text format which a role does not have access to does not appear in the list of formats available to that role.');
$this->assertContains($this->allowedFormat->id(), array_keys(filter_get_formats_by_role($rid)), 'A text format which a role has access to appears in the list of formats available to that role.');
$this->assertNotContains($this->disallowedFormat->id(), array_keys(filter_get_formats_by_role($rid)), 'A text format which a role does not have access to does not appear in the list of formats available to that role.');
// Check that the fallback format is always allowed.
$this->assertEqual(filter_get_roles_by_format(FilterFormat::load(filter_fallback_format())), user_role_names(), 'All roles have access to the fallback format.');
$this->assertTrue(in_array(filter_fallback_format(), array_keys(filter_get_formats_by_role($rid))), 'The fallback format appears in the list of allowed formats for any role.');
$this->assertContains(filter_fallback_format(), array_keys(filter_get_formats_by_role($rid)), 'The fallback format appears in the list of allowed formats for any role.');
}
/**
......
......@@ -48,8 +48,8 @@ public function testConstructor() {
// and non-existent directories were omitted.
$paths = $this->helpLoader->getPaths(HelpTopicTwigLoader::MAIN_NAMESPACE);
$this->assertCount(2, $paths);
$this->assertTrue(in_array($this->directories['module']['test'] . '/help_topics', $paths));
$this->assertTrue(in_array($this->directories['theme']['test'] . '/help_topics', $paths));
$this->assertContains($this->directories['module']['test'] . '/help_topics', $paths);
$this->assertContains($this->directories['theme']['test'] . '/help_topics', $paths);
}
/**
......
......@@ -112,7 +112,7 @@ public function testHistory() {
// JavaScript present to record the node read.
$settings = $this->getDrupalSettings();
$libraries = explode(',', $settings['ajaxPageState']['libraries']);
$this->assertTrue(in_array('history/mark-as-read', $libraries), 'history/mark-as-read library is present.');
$this->assertContains('history/mark-as-read', $libraries, 'history/mark-as-read library is present.');
$this->assertEqual([$nid => TRUE], $settings['history']['nodesToMarkAsRead'], 'drupalSettings to mark node as read are present.');
// Simulate JavaScript: perform HTTP request to mark node as read.
......
......@@ -334,7 +334,7 @@ public function testGetNodeCollectionWithHookNodeGrantsImplementationsFromIssue2
],
]);
$this->assertSame(200, $response->getStatusCode());
$this->assertTrue(in_array('user.node_grants:view', explode(' ', $response->getHeader('X-Drupal-Cache-Contexts')[0]), TRUE));
$this->assertContains('user.node_grants:view', explode(' ', $response->getHeader('X-Drupal-Cache-Contexts')[0]));
}
/**
......
......@@ -508,7 +508,7 @@ public function testCollectionFilterAccess() {
node_access_rebuild();
$this->rebuildAll();
$response = $this->request('GET', $collection_filter_url, $request_options);
$this->assertTrue(in_array('user.node_grants:view', explode(' ', $response->getHeader('X-Drupal-Cache-Contexts')[0]), TRUE));
$this->assertContains('user.node_grants:view', explode(' ', $response->getHeader('X-Drupal-Cache-Contexts')[0]));
}
}
......@@ -85,7 +85,7 @@ public function testInfoAlterations() {
$type = LanguageInterface::TYPE_CONTENT;
$language_types = $this->languageManager()->getLanguageTypes();
$this->assertTrue(in_array($type, $language_types), 'Content language type is configurable.');
$this->assertContains($type, $language_types, 'Content language type is configurable.');
// Enable some core and custom language negotiation methods. The test
// language type is supposed to be configurable.
......
......@@ -554,8 +554,8 @@ public function testContentCustomization() {
// Check if configurability persisted.
$config = $this->config('language.types');
$this->assertTrue(in_array('language_interface', $config->get('configurable')), 'Interface language is configurable.');
$this->assertTrue(in_array('language_content', $config->get('configurable')), 'Content language is configurable.');
$this->assertContains('language_interface', $config->get('configurable'), 'Interface language is configurable.');
$this->assertContains('language_content', $config->get('configurable'), 'Content language is configurable.');
// Ensure configuration was saved.
$this->assertArrayNotHasKey('language-url', $config->get('negotiation.language_content.enabled'));
......
......@@ -291,7 +291,7 @@ protected function assertContextualLinkRetainsMouseup() {
* The element position.
*/
protected function getElementVerticalPosition($css_selector, $position_type) {
$this->assertTrue(in_array($position_type, ['top', 'bottom']), 'Expected position type.');
$this->assertContains($position_type, ['top', 'bottom'], 'Expected position type.');
return (int) $this->getSession()->evaluateScript("document.querySelector('$css_selector').getBoundingClientRect().$position_type + window.pageYOffset");
}
......
......@@ -41,7 +41,7 @@ public function testThemeProvidedLayout() {
$this->config('system.theme')->set('default', 'test_layout_theme')->save();
$theme_definitions = $this->container->get('theme.registry')->get();
$this->assertTrue(in_array('template_preprocess_layout', $theme_definitions['test_layout_theme']['preprocess functions']));
$this->assertContains('template_preprocess_layout', $theme_definitions['test_layout_theme']['preprocess functions']);
}
/**
......
......@@ -99,7 +99,7 @@ public function testNodeTokenReplacement() {
$metadata_tests['[node:changed:since]'] = $bubbleable_metadata;
// Test to make sure that we generated something for each token.
$this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.');
$this->assertNotContains(0, array_map('strlen', $tests), 'No empty tokens generated.');
foreach ($tests as $input => $expected) {
$bubbleable_metadata = new BubbleableMetadata();
......@@ -122,7 +122,7 @@ public function testNodeTokenReplacement() {
$tests['[node:summary]'] = $node->body->processed;
// Test to make sure that we generated something for each token.
$this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated for node without a summary.');
$this->assertNotContains(0, array_map('strlen', $tests), 'No empty tokens generated for node without a summary.');
foreach ($tests as $input => $expected) {
$output = $this->tokenService->replace($input, ['node' => $node], ['language' => $this->interfaceLanguage]);
......
......@@ -49,7 +49,7 @@ public function testMappingCreation() {
rdf_get_mapping($this->entityType, $this->bundle)->save();
// Test that config file was saved.
$mapping_config = \Drupal::configFactory()->listAll('rdf.mapping.');
$this->assertTrue(in_array($mapping_config_name, $mapping_config), 'Rdf mapping config saved.');
$this->assertContains($mapping_config_name, $mapping_config, 'Rdf mapping config saved.');
}
/**
......
......@@ -312,13 +312,13 @@ protected function doTestResponsiveImageFieldFormatters($scheme, $empty_styles =
}
$this->assertRaw('/styles/large/');
$cache_tags = explode(' ', $this->drupalGetHeader('X-Drupal-Cache-Tags'));
$this->assertTrue(in_array('config:responsive_image.styles.style_one', $cache_tags));
$this->assertContains('config:responsive_image.styles.style_one', $cache_tags);
if (!$empty_styles) {
$this->assertTrue(in_array('config:image.style.medium', $cache_tags));
$this->assertTrue(in_array('config:image.style.thumbnail', $cache_tags));
$this->assertContains('config:image.style.medium', $cache_tags);
$this->assertContains('config:image.style.thumbnail', $cache_tags);
$this->assertRaw('type="image/png"');
}
$this->assertTrue(in_array('config:image.style.large', $cache_tags));
$this->assertContains('config:image.style.large', $cache_tags);
// Test the fallback image style.
$image = \Drupal::service('image.factory')->get($image_uri);
......
......@@ -172,8 +172,8 @@ public function testMultilingualSearch() {
// Nodes are saved directly after each other and have the same created time
// so testing for the order is not possible.
$results = [$search_result[0]['title'], $search_result[1]['title']];
$this->assertTrue(in_array('Third node this is the Hungarian title', $results), 'The search finds the correct Hungarian title.');
$this->assertTrue(in_array('Second node this is the English title', $results), 'The search finds the correct English title.');
$this->assertContains('Third node this is the Hungarian title', $results, 'The search finds the correct Hungarian title.');
$this->assertContains('Second node this is the English title', $results, 'The search finds the correct English title.');
// Now filter for Hungarian results only.
$this->plugin->setSearch('English OR Hungarian', ['f' => ['language:hu']], []);
......
......@@ -84,7 +84,7 @@ public function testShortcutLinkAdd() {
$this->assertText(t('Added a shortcut for @title.', ['@title' => $title]));
$saved_set = ShortcutSet::load($set->id());
$paths = $this->getShortcutInformation($saved_set, 'link');
$this->assertTrue(in_array('internal:' . $test_path, $paths), 'Shortcut created: ' . $test_path);
$this->assertContains('internal:' . $test_path, $paths, 'Shortcut created: ' . $test_path);
if (in_array($test_path, $test_cases_non_access)) {
$this->assertNoLink($title, new FormattableMarkup('Shortcut link %url not accessible on the page.', ['%url' => $test_path]));
......@@ -239,7 +239,7 @@ public function testShortcutLinkRename() {
$this->drupalPostForm('admin/config/user-interface/shortcut/link/' . $shortcut->id(), ['title[0][value]' => $new_link_name], t('Save'));
$saved_set = ShortcutSet::load($set->id());
$titles = $this->getShortcutInformation($saved_set, 'title');
$this->assertTrue(in_array($new_link_name, $titles), 'Shortcut renamed: ' . $new_link_name);
$this->assertContains($new_link_name, $titles,