Commit b22c720b authored by catch's avatar catch
Browse files

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

Issue #3131343 by mondrake, jungle, dww, catch: Replace assertions involving calls to in_array() with assertContains()/assertNotContains()
parent 4732d9f4
Loading
Loading
Loading
Loading
+8 −8
Changes for core/modules/aggregator/tests/src/Functional/AggregatorRenderingTest.php: 8 added lines, 8 removed lines.
Original line number Diff line number Diff line
@@ -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);
  }

}
+1 −1
Changes for core/modules/big_pipe/tests/src/Functional/BigPipeTest.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -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.');
+2 −2
Changes for core/modules/ckeditor/tests/src/Functional/CKEditorLoadingTest.php: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -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.
+6 −6
Changes for core/modules/ckeditor/tests/src/Unit/Plugin/CKEditorPlugin/LanguageTest.php: 6 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -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']));
  }

+1 −1
Changes for core/modules/comment/tests/src/Functional/CommentTokenReplaceTest.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -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();
Loading