Browse Source

Fix up test suite constraint messages.

mscherer 2 years ago
parent
commit
02fd69eb1b

+ 1 - 1
src/Console/TestSuite/Constraint/ContentsContain.php

@@ -40,7 +40,7 @@ class ContentsContain extends ContentsBase
      */
     public function toString(): string
     {
-        return sprintf('is in %s,' . PHP_EOL . 'actual result:' . PHP_EOL, $this->output) . $this->contents;
+        return sprintf('is in %s,' . PHP_EOL . 'actual result:' . PHP_EOL . '`%s`', $this->output, $this->contents);
     }
 }
 

+ 6 - 1
src/Console/TestSuite/Constraint/ExitCode.php

@@ -57,7 +57,12 @@ class ExitCode extends Constraint
      */
     public function toString(): string
     {
-        return sprintf('matches exit code %s', $this->exitCode ?? 'null');
+        return sprintf('matches exit code `%s`', $this->exitCode ?? 'null');
+    }
+
+    public function failureDescription(mixed $other): string
+    {
+        return '`' . $other . '` ' . $this->toString();
     }
 }
 

+ 1 - 1
tests/TestCase/Console/TestSuite/ConsoleIntegrationTestTraitTest.php

@@ -228,7 +228,7 @@ class ConsoleIntegrationTestTraitTest extends TestCase
     public static function assertionFailureMessagesProvider(): array
     {
         return [
-            'assertExitCode' => ['assertExitCode', 'Failed asserting that 1 matches exit code 0', 'routes', CommandInterface::CODE_ERROR],
+            'assertExitCode' => ['assertExitCode', 'Failed asserting that `1` matches exit code `0`', 'routes', CommandInterface::CODE_ERROR],
             'assertOutputEmpty' => ['assertOutputEmpty', 'Failed asserting that output is empty', 'routes'],
             'assertOutputContains' => ['assertOutputContains', 'Failed asserting that \'missing\' is in output', 'routes', 'missing'],
             'assertOutputNotContains' => ['assertOutputNotContains', 'Failed asserting that \'controller\' is not in output', 'routes', 'controller'],