Skip to content

Commit

Permalink
Add tests for custom assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
jigarius committed Dec 28, 2024
1 parent 760b814 commit 2aade27
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions test/Unit/TestCaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,32 @@ public function testCreateTempFile() {
}

public function testAssertOutputEquals() {
$expected = <<<EOF
foo
bar
baz
// For some reason, drush's output ($actual) has spaces before EOL.
// This assertion respects leading spaces and ignores trailing spaces.
$this->assertOutputEquals(<<<EOT
[notice] Hakuna matata.
- bunny
- wabbit
EOT, "[notice] Hakuna matata. \n - bunny \n - wabbit \n");
}

EOF;
// For some reason, drush's output has spaces before EOL.
$actual = "foo \nbar \nbaz \n";
public function testAssertOutputStartsWith() {
// For some reason, drush's output ($actual) has spaces before EOL.
// This assertion respects leading spaces and ignores trailing spaces.
$this->assertOutputStartsWith(
'[notice] Hakuna matata.' . PHP_EOL,
"[notice] Hakuna matata. \n - bunny \n - wabbit \n",
);
}

$this->assertOutputEquals($expected, $actual);
public function testAssertOutputContainsString() {
// For some reason, drush's output ($actual) has spaces before EOL.
// This assertion respects leading spaces and ignores trailing spaces.
$this->assertOutputContainsString(
' - bunny' . PHP_EOL,
"[notice] Hakuna matata. \n - bunny \n - wabbit \n",
);
}

}

0 comments on commit 2aade27

Please sign in to comment.