Verified Commit a44a9b1c authored by Lee Rowlands's avatar Lee Rowlands
Browse files

Issue #3159230 by mondrake, sandeep_jangra, ravi.shankar, naresh_bavaskar,...

Issue #3159230 by mondrake, sandeep_jangra, ravi.shankar, naresh_bavaskar, larowlan, longwave: AssertLegacyTrait::assert(No)Raw() in functional tests still have a message passed in
parent 97cff664
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -83,7 +83,7 @@ public function testActionConfiguration() {
    $this->assertSession()->statusCodeEquals(200);

    // Make sure that the action was actually deleted.
    $this->assertRaw(t('The action %action has been deleted.', ['%action' => $new_action_label]), 'Make sure that we get a delete confirmation message.');
    $this->assertRaw(t('The action %action has been deleted.', ['%action' => $new_action_label]));
    $this->drupalGet('admin/config/system/actions');
    $this->assertSession()->statusCodeEquals(200);
    $this->assertNoText($new_action_label, "Make sure the action label does not appear on the overview page after we've deleted the action.");
+2 −2
Original line number Diff line number Diff line
@@ -93,7 +93,7 @@ public function createFeed($feed_url = NULL, array $edit = []) {
   */
  public function deleteFeed(FeedInterface $feed) {
    $this->drupalPostForm('aggregator/sources/' . $feed->id() . '/delete', [], t('Delete'));
    $this->assertRaw(t('The feed %title has been deleted.', ['%title' => $feed->label()]), 'Feed deleted successfully.');
    $this->assertRaw(t('The feed %title has been deleted.', ['%title' => $feed->label()]));
  }

  /**
@@ -213,7 +213,7 @@ public function updateFeedItems(FeedInterface $feed, $expected_count = NULL) {
   */
  public function deleteFeedItems(FeedInterface $feed) {
    $this->drupalPostForm('admin/config/services/aggregator/delete/' . $feed->id(), [], t('Delete items'));
    $this->assertRaw(t('The news items from %title have been deleted.', ['%title' => $feed->label()]), 'Feed items deleted.');
    $this->assertRaw(t('The news items from %title have been deleted.', ['%title' => $feed->label()]));
  }

  /**
+6 −4
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ public function validateImportFormFields() {

    $edit = [];
    $this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, t('Import'));
    $this->assertRaw(t('<em>Either</em> upload a file or enter a URL.'), 'Error if no fields are filled.');
    $this->assertRaw(t('<em>Either</em> upload a file or enter a URL.'));

    $path = $this->getEmptyOpml();
    $edit = [
@@ -70,7 +70,7 @@ public function validateImportFormFields() {
      'remote' => file_create_url($path),
    ];
    $this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, t('Import'));
    $this->assertRaw(t('<em>Either</em> upload a file or enter a URL.'), 'Error if both fields are filled.');
    $this->assertRaw(t('<em>Either</em> upload a file or enter a URL.'));

    $edit = ['remote' => 'invalidUrl://empty'];
    $this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, t('Import'));
@@ -110,8 +110,10 @@ protected function submitImportForm() {
      'refresh'       => '900',
    ];
    $this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, t('Import'));
    $this->assertRaw(t('A feed with the URL %url already exists.', ['%url' => $feeds[0]['url[0][value]']]), 'Verifying that a duplicate URL was identified');
    $this->assertRaw(t('A feed named %title already exists.', ['%title' => $feeds[1]['title[0][value]']]), 'Verifying that a duplicate title was identified');
    // Verify that a duplicate URL was identified.
    $this->assertRaw(t('A feed with the URL %url already exists.', ['%url' => $feeds[0]['url[0][value]']]));
    // Verify that a duplicate title was identified.
    $this->assertRaw(t('A feed named %title already exists.', ['%title' => $feeds[1]['title[0][value]']]));

    $after = $count_query->execute();
    $this->assertEqual($after, 2, 'Verifying that two distinct feeds were added.');
+2 −2
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@ public function testIPAddressValidation() {
    $this->drupalPostForm('admin/config/people/ban', $edit, t('Add'));
    $ip = $connection->select('ban_ip', 'bi')->fields('bi', ['iid'])->condition('ip', $edit['ip'])->execute()->fetchField();
    $this->assertNotEmpty($ip, 'IP address found in database.');
    $this->assertRaw(t('The IP address %ip has been banned.', ['%ip' => $edit['ip']]), 'IP address was banned.');
    $this->assertRaw(t('The IP address %ip has been banned.', ['%ip' => $edit['ip']]));

    // Try to block an IP address that's already blocked.
    $edit = [];
@@ -72,7 +72,7 @@ public function testIPAddressValidation() {
    $this->drupalPostForm('admin/config/people/ban/' . $submit_ip, [], t('Add'));
    $ip = $connection->select('ban_ip', 'bi')->fields('bi', ['iid'])->condition('ip', $submit_ip)->execute()->fetchField();
    $this->assertNotEmpty($ip, 'IP address found in database');
    $this->assertRaw(t('The IP address %ip has been banned.', ['%ip' => $submit_ip]), 'IP address was banned.');
    $this->assertRaw(t('The IP address %ip has been banned.', ['%ip' => $submit_ip]));

    // Submit your own IP address. This fails, although it works when testing
    // manually.
+13 −11
Original line number Diff line number Diff line
@@ -184,7 +184,7 @@ public function testBigPipe() {
      1 => $cases['html']->bigPipePlaceholderId,
    ]);

    $this->assertRaw('</body>', 'Closing body tag present.');
    $this->assertRaw('</body>');

    // Verifying BigPipe assets are present.
    $this->assertFalse(empty($this->getDrupalSettings()), 'drupalSettings present.');
@@ -213,8 +213,9 @@ public function testBigPipe() {
    // The 'edge_case__html_exception' case throws an exception.
    $this->assertRaw('The website encountered an unexpected error. Please try again later');
    $this->assertRaw('You are not allowed to say llamas are not cool!');
    $this->assertNoRaw(BigPipe::STOP_SIGNAL, 'BigPipe stop signal absent: error occurred before then.');
    $this->assertNoRaw('</body>', 'Closing body tag absent: error occurred before then.');
    // Check that stop signal and closing body tag are absent.
    $this->assertNoRaw(BigPipe::STOP_SIGNAL);
    $this->assertNoRaw('</body>');
    // The exception is expected. Do not interpret it as a test failure.
    unlink($this->root . '/' . $this->siteDirectory . '/error.log');
  }
@@ -264,12 +265,12 @@ public function testBigPipeNoJs() {
    // Verifying there are no BigPipe placeholders & replacements.
    $this->assertSession()->responseHeaderEquals('BigPipe-Test-Placeholders', '<none>');
    // Verifying BigPipe start/stop signals are absent.
    $this->assertNoRaw(BigPipe::START_SIGNAL, 'BigPipe start signal absent.');
    $this->assertNoRaw(BigPipe::STOP_SIGNAL, 'BigPipe stop signal absent.');
    $this->assertNoRaw(BigPipe::START_SIGNAL);
    $this->assertNoRaw(BigPipe::STOP_SIGNAL);

    // Verifying BigPipe assets are absent.
    $this->assertTrue(!isset($this->getDrupalSettings()['bigPipePlaceholderIds']) && empty($this->getDrupalSettings()['ajaxPageState']), 'BigPipe drupalSettings and BigPipe asset library absent.');
    $this->assertRaw('</body>', 'Closing body tag present.');
    $this->assertRaw('</body>');

    // Verify that 4xx responses work fine. (4xx responses are handled by
    // subrequests to a route pointing to a controller with the desired output.)
@@ -283,7 +284,7 @@ public function testBigPipeNoJs() {
    // The 'edge_case__html_exception' case throws an exception.
    $this->assertRaw('The website encountered an unexpected error. Please try again later');
    $this->assertRaw('You are not allowed to say llamas are not cool!');
    $this->assertNoRaw('</body>', 'Closing body tag absent: error occurred before then.');
    $this->assertNoRaw('</body>');
    // The exception is expected. Do not interpret it as a test failure.
    unlink($this->root . '/' . $this->siteDirectory . '/error.log');
  }
@@ -366,7 +367,7 @@ protected function assertBigPipePlaceholders(array $expected_big_pipe_placeholde
    foreach ($expected_big_pipe_placeholders as $big_pipe_placeholder_id => $expected_ajax_response) {
      // Verify expected placeholder.
      $expected_placeholder_html = '<span data-big-pipe-placeholder-id="' . $big_pipe_placeholder_id . '"></span>';
      $this->assertRaw($expected_placeholder_html, 'BigPipe placeholder for placeholder ID "' . $big_pipe_placeholder_id . '" found.');
      $this->assertRaw($expected_placeholder_html);
      $pos = strpos($this->getSession()->getPage()->getContent(), $expected_placeholder_html);
      $placeholder_positions[$pos] = $big_pipe_placeholder_id;
      // Verify expected placeholder replacement.
@@ -397,8 +398,8 @@ protected function assertBigPipePlaceholders(array $expected_big_pipe_placeholde
    $this->assertSame(count($expected_big_pipe_placeholders_with_replacements), preg_match_all('/' . preg_quote('<script type="application/vnd.drupal-ajax" data-big-pipe-replacement-for-placeholder-with-id="', '/') . '/', $this->getSession()->getPage()->getContent()));

    // Verifying BigPipe start/stop signals.
    $this->assertRaw(BigPipe::START_SIGNAL, 'BigPipe start signal present.');
    $this->assertRaw(BigPipe::STOP_SIGNAL, 'BigPipe stop signal present.');
    $this->assertRaw(BigPipe::START_SIGNAL);
    $this->assertRaw(BigPipe::STOP_SIGNAL);
    $start_signal_position = strpos($this->getSession()->getPage()->getContent(), BigPipe::START_SIGNAL);
    $stop_signal_position = strpos($this->getSession()->getPage()->getContent(), BigPipe::STOP_SIGNAL);
    $this->assertTrue($start_signal_position < $stop_signal_position, 'BigPipe start signal appears before stop signal.');
@@ -491,7 +492,8 @@ protected function assertBigPipeNoJsMetaRefreshRedirect() {
    $this->assertTrue(empty(array_diff(['cookies:big_pipe_nojs', 'session.exists'], explode(' ', $headers[0]['X-Drupal-Cache-Contexts'][0]))), 'The first response varies by the "cookies:big_pipe_nojs" and "session.exists" cache contexts.');
    $this->assertEqual('no-store, content="BigPipe/1.0"', $headers[1]['Surrogate-Control'][0], 'The second response has a "Surrogate-Control" header.');

    $this->assertNoRaw('<noscript><meta http-equiv="Refresh" content="0; URL=', 'Once the BigPipe no-JS cookie is set, the <meta> refresh is absent: only one redirect ever happens.');
    // Check that the <meta> refresh is absent, only one redirect ever happens.
    $this->assertNoRaw('<noscript><meta http-equiv="Refresh" content="0; URL=');
  }

}
Loading