Commit baab371f authored by catch's avatar catch
Browse files

Issue #3123120 by mondrake, mrinalini9, ridhimaabrol24, longwave, catch:...

Issue #3123120 by mondrake, mrinalini9, ridhimaabrol24, longwave, catch: [backport] Properly deprecate AssertLegacyTrait::pass
parent af58378a
Loading
Loading
Loading
Loading
+13 −13
Original line number Diff line number Diff line
@@ -186,7 +186,7 @@ public function testBigPipe() {

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

    $this->pass('Verifying BigPipe assets are present…', 'Debug');
    // Verifying BigPipe assets are present.
    $this->assertFalse(empty($this->getDrupalSettings()), 'drupalSettings present.');
    $this->assertContains('big_pipe/big_pipe', explode(',', $this->getDrupalSettings()['ajaxPageState']['libraries']), 'BigPipe asset library is present.');

@@ -205,7 +205,8 @@ public function testBigPipe() {
    $this->drupalGet(Url::fromUri('base:non-existing-path'));

    // Simulate development.
    $this->pass('Verifying BigPipe provides useful error output when an error occurs while rendering a placeholder if verbose error logging is enabled.', 'Debug');
    // Verifying BigPipe provides useful error output when an error occurs
    // while rendering a placeholder if verbose error logging is enabled.
    $this->config('system.logging')->set('error_level', ERROR_REPORTING_DISPLAY_VERBOSE)->save();
    $this->drupalGet(Url::fromRoute('big_pipe_test'));
    // The 'edge_case__html_exception' case throws an exception.
@@ -259,13 +260,13 @@ public function testBigPipeNoJs() {
      $cases['exception__embedded_response']->bigPipePlaceholderId        => NULL,
    ]);

    $this->pass('Verifying there are no BigPipe placeholders & replacements…', 'Debug');
    // Verifying there are no BigPipe placeholders & replacements.
    $this->assertEqual('<none>', $this->drupalGetHeader('BigPipe-Test-Placeholders'));
    $this->pass('Verifying BigPipe start/stop signals are absent…', 'Debug');
    // 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->pass('Verifying BigPipe assets are absent…', 'Debug');
    // 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.');

@@ -274,7 +275,8 @@ public function testBigPipeNoJs() {
    $this->drupalGet(Url::fromUri('base:non-existing-path'));

    // Simulate development.
    $this->pass('Verifying BigPipe provides useful error output when an error occurs while rendering a placeholder if verbose error logging is enabled.', 'Debug');
    // Verifying BigPipe provides useful error output when an error occurs
    // while rendering a placeholder if verbose error logging is enabled.
    $this->config('system.logging')->set('error_level', ERROR_REPORTING_DISPLAY_VERBOSE)->save();
    $this->drupalGet(Url::fromRoute('big_pipe_test'));
    // The 'edge_case__html_exception' case throws an exception.
@@ -322,7 +324,6 @@ public function testBigPipeMultiOccurrencePlaceholders() {
  }

  protected function assertBigPipeResponseHeadersPresent() {
    $this->pass('Verifying BigPipe response headers…', 'Debug');
    // Check that Cache-Control header set to "private".
    $this->assertSession()->responseHeaderContains('Cache-Control', 'private');
    $this->assertEqual('no-store, content="BigPipe/1.0"', $this->drupalGetHeader('Surrogate-Control'));
@@ -337,10 +338,10 @@ protected function assertBigPipeResponseHeadersPresent() {
   *   markup.
   */
  protected function assertBigPipeNoJsPlaceholders(array $expected_big_pipe_nojs_placeholders) {
    $this->pass('Verifying BigPipe no-JS placeholders & replacements…', 'Debug');
    $this->assertSetsEqual(array_keys($expected_big_pipe_nojs_placeholders), array_map('rawurldecode', explode(' ', $this->drupalGetHeader('BigPipe-Test-No-Js-Placeholders'))));
    foreach ($expected_big_pipe_nojs_placeholders as $big_pipe_nojs_placeholder => $expected_replacement) {
      $this->pass('Checking whether the replacement for the BigPipe no-JS placeholder "' . $big_pipe_nojs_placeholder . '" is present:');
      // Checking whether the replacement for the BigPipe no-JS placeholder
      // $big_pipe_nojs_placeholder is present.
      $this->assertNoRaw($big_pipe_nojs_placeholder);
      if ($expected_replacement !== NULL) {
        $this->assertRaw($expected_replacement);
@@ -358,12 +359,10 @@ protected function assertBigPipeNoJsPlaceholders(array $expected_big_pipe_nojs_p
   *   defined in the order that they are expected to be rendered & streamed.
   */
  protected function assertBigPipePlaceholders(array $expected_big_pipe_placeholders, array $expected_big_pipe_placeholder_stream_order) {
    $this->pass('Verifying BigPipe placeholders & replacements…', 'Debug');
    $this->assertSetsEqual(array_keys($expected_big_pipe_placeholders), explode(' ', $this->drupalGetHeader('BigPipe-Test-Placeholders')));
    $placeholder_positions = [];
    $placeholder_replacement_positions = [];
    foreach ($expected_big_pipe_placeholders as $big_pipe_placeholder_id => $expected_ajax_response) {
      $this->pass('BigPipe placeholder: ' . $big_pipe_placeholder_id, 'Debug');
      // 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.');
@@ -396,14 +395,15 @@ protected function assertBigPipePlaceholders(array $expected_big_pipe_placeholde
    $this->assertSetsEqual(array_keys($expected_big_pipe_placeholders_with_replacements), array_values($placeholder_replacement_positions));
    $this->assertEqual(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()));

    $this->pass('Verifying BigPipe start/stop signals…', 'Debug');
    // Verifying BigPipe start/stop signals.
    $this->assertRaw(BigPipe::START_SIGNAL, 'BigPipe start signal present.');
    $this->assertRaw(BigPipe::STOP_SIGNAL, 'BigPipe stop signal present.');
    $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.');

    $this->pass('Verifying BigPipe placeholder replacements and start/stop signals were streamed in the correct order…', 'Debug');
    // Verifying BigPipe placeholder replacements and start/stop signals were
    // streamed in the correct order.
    $expected_stream_order = array_keys($expected_big_pipe_placeholders_with_replacements);
    array_unshift($expected_stream_order, BigPipe::START_SIGNAL);
    array_push($expected_stream_order, BigPipe::STOP_SIGNAL);
+0 −3
Original line number Diff line number Diff line
@@ -292,7 +292,6 @@ protected function assertBlockRenderedWithExpectedCacheability(array $expected_k

    // Check that the expected cacheability metadata is present in:
    // - the built render array;
    $this->pass('Built render array');
    $build = $this->getBlockRenderArray();
    $this->assertIdentical($expected_keys, $build['#cache']['keys']);
    $this->assertIdentical($expected_contexts, $build['#cache']['contexts']);
@@ -300,10 +299,8 @@ protected function assertBlockRenderedWithExpectedCacheability(array $expected_k
    $this->assertIdentical($expected_max_age, $build['#cache']['max-age']);
    $this->assertFalse(isset($build['#create_placeholder']));
    // - the rendered render array;
    $this->pass('Rendered render array');
    $this->renderer->renderRoot($build);
    // - the render cache item.
    $this->pass('Render cache item');
    $final_cache_contexts = Cache::mergeContexts($expected_contexts, $required_cache_contexts);
    $cid = implode(':', $expected_keys) . ':' . implode(':', \Drupal::service('cache_contexts_manager')->convertTokensToKeys($final_cache_contexts)->getKeys());
    $cache_item = $this->container->get('cache.render')->get($cid);
+1 −1
Original line number Diff line number Diff line
@@ -204,7 +204,7 @@ public function testFailedBlockCreation() {
      $this->fail('Expected exception has not been thrown.');
    }
    catch (\Exception $e) {
      $this->pass('Expected exception has been thrown.');
      // Expected exception; just continue testing.
    }

    $connection = Database::getConnection();
+1 −3
Original line number Diff line number Diff line
@@ -145,12 +145,10 @@ protected function doTestBasicTranslation() {
    $entity->addTranslation('it', $values);

    try {
      $message = 'Blocks can have translations with the same "info" value.';
      $entity->save();
      $this->pass($message);
    }
    catch (\Exception $e) {
      $this->fail($message);
      $this->fail('Blocks can have translations with the same "info" value.');
    }

    // Check that the translate operation link is shown.
+4 −9
Original line number Diff line number Diff line
@@ -33,15 +33,10 @@ protected function setUp() {
   * Tests creation of block content stubs with no block_content_type available.
   */
  public function testStubFailure() {
    $message = 'Expected MigrateException thrown when no bundles exist.';
    try {
    // Expected MigrateException thrown when no bundles exist.
    $this->expectException(MigrateException::class);
    $this->expectExceptionMessage('Stubbing failed, no bundles available for entity type: block_content');
    $this->createEntityStub('block_content');
      $this->fail($message);
    }
    catch (MigrateException $e) {
      $this->pass($message);
      $this->assertEqual('Stubbing failed, no bundles available for entity type: block_content', $e->getMessage());
    }
  }

  /**
Loading