Commit d8348473 authored by catch's avatar catch
Browse files

Issue #3166450 by mondrake, longwave, snehalgaikwad: Split assertTrue using &&...

Issue #3166450 by mondrake, longwave, snehalgaikwad: Split assertTrue using && into multiple assertions

(cherry picked from commit 7dbdbcb1)
parent a5dac865
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -57,12 +57,15 @@ protected function getMails(array $filter = []) {
   *   this default.
   *
   * @return bool
   *   TRUE on pass, FALSE on fail.
   *   TRUE on pass.
   */
  protected function assertMail($name, $value = '', $message = '', $group = 'Email') {
    $captured_emails = $this->container->get('state')->get('system.test_mail_collector') ?: [];
    $email = end($captured_emails);
    return $this->assertTrue($email && isset($email[$name]) && $email[$name] == $value, $message, $group);
    $this->assertIsArray($email, $message);
    $this->assertArrayHasKey($name, $email, $message);
    $this->assertEquals($value, $email[$name], $message);
    return TRUE;
  }

  /**
+2 −1
Original line number Diff line number Diff line
@@ -269,7 +269,8 @@ public function testBigPipeNoJs() {
    $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->assertArrayNotHasKey('bigPipePlaceholderIds', $this->getDrupalSettings());
    $this->assertArrayNotHasKey('ajaxPageState', $this->getDrupalSettings());
    $this->assertRaw('</body>');

    // Verify that 4xx responses work fine. (4xx responses are handled by
+3 −1
Original line number Diff line number Diff line
@@ -207,7 +207,9 @@ public function testBlockViewBuilderViewAlter() {
    $build = $this->getBlockRenderArray();
    $this->assertFalse(isset($build['#prefix']), 'The appended #pre_render callback has not yet run before rendering.');
    $this->assertIdentical((string) $this->renderer->renderRoot($build), 'Hiya!<br>');
    $this->assertTrue(isset($build['#prefix']) && $build['#prefix'] === 'Hiya!<br>', 'A cached block without content is altered.');
    // Check that a cached block without content is altered.
    $this->assertArrayHasKey('#prefix', $build);
    $this->assertSame('Hiya!<br>', $build['#prefix']);
  }

  /**
+4 −2
Original line number Diff line number Diff line
@@ -40,14 +40,16 @@ public function testBlockMigration() {
    /** @var \Drupal\block_content\Entity\BlockContent $block */
    $block = BlockContent::load(1);
    $this->assertIdentical('My block 1', $block->label());
    $this->assertTrue(REQUEST_TIME <= $block->getChangedTime() && $block->getChangedTime() <= time());
    $this->assertGreaterThanOrEqual(REQUEST_TIME, $block->getChangedTime());
    $this->assertLessThanOrEqual(time(), $block->getChangedTime());
    $this->assertIdentical('en', $block->language()->getId());
    $this->assertIdentical('<h3>My first custom block body</h3>', $block->body->value);
    $this->assertIdentical('full_html', $block->body->format);

    $block = BlockContent::load(2);
    $this->assertIdentical('My block 2', $block->label());
    $this->assertTrue(REQUEST_TIME <= $block->getChangedTime() && $block->getChangedTime() <= time());
    $this->assertGreaterThanOrEqual(REQUEST_TIME, $block->getChangedTime());
    $this->assertLessThanOrEqual(time(), $block->getChangedTime());
    $this->assertIdentical('en', $block->language()->getId());
    $this->assertIdentical('<h3>My second custom block body</h3>', $block->body->value);
    $this->assertIdentical('full_html', $block->body->format);
+4 −3
Original line number Diff line number Diff line
@@ -101,8 +101,8 @@ public function testCommentInterface() {

    // Test changing the comment author to "Anonymous".
    $comment = $this->postComment(NULL, $comment->comment_body->value, $comment->getSubject(), ['uid' => '']);
    $this->assertTrue($comment->getAuthorName() == 'Anonymous', 'Comment author successfully changed to anonymous.');
    $this->assertTrue($comment->getOwnerId() == 0, 'Comment author successfully changed to anonymous.');
    $this->assertSame('Anonymous', $comment->getAuthorName());
    $this->assertEquals(0, $comment->getOwnerId());

    // Test changing the comment author to an unverified user.
    $random_name = $this->randomMachineName();
@@ -114,7 +114,8 @@ public function testCommentInterface() {
    // Test changing the comment author to a verified user.
    $this->drupalGet('comment/' . $comment->id() . '/edit');
    $comment = $this->postComment(NULL, $comment->comment_body->value, $comment->getSubject(), ['uid' => $this->webUser->getAccountName() . ' (' . $this->webUser->id() . ')']);
    $this->assertTrue($comment->getAuthorName() == $this->webUser->getAccountName() && $comment->getOwnerId() == $this->webUser->id(), 'Comment author successfully changed to a registered user.');
    $this->assertSame($this->webUser->getAccountName(), $comment->getAuthorName());
    $this->assertSame($this->webUser->id(), $comment->getOwnerId());

    $this->drupalLogout();

Loading