public function testWhenOutputAndHeadersDifferent() { $requestFailure = new RequestFailure($this->createMock(RequestInterface::class), 'Expected Output', 'Actual Output', ['header1' => 'some-value'], ['header2' => 'some-value']); $this->assertTrue($requestFailure->headersDifferent()); $this->assertTrue($requestFailure->bodyDifferent()); $this->assertTrue($requestFailure->headersAndBodyDifferent()); $this->assertEquals(['header1' => 'some-value'], $requestFailure->getExpectedHeaders()); $this->assertEquals(['header2' => 'some-value'], $requestFailure->getActualHeaders()); $this->assertNotEquals($requestFailure->getExpectedHeaders(), $requestFailure->getActualHeaders()); $this->assertEquals('Expected Output', $requestFailure->getExpectedOutput()); $this->assertEquals('Actual Output', $requestFailure->getActualOutput()); $this->assertNotEquals($requestFailure->getExpectedOutput(), $requestFailure->getActualOutput()); }
/** * Print the actual and expected output. * * @param ResultsRenderer $renderer * @return string */ public function render(ResultsRenderer $renderer) { $output = ''; if ($this->result->headersDifferent()) { $output .= sprintf("%s %s\n%s %s", $renderer->style('YOUR HEADERS:', ['bold', 'yellow']), $this->headers($this->result->getActualHeaders(), $renderer), $renderer->style('EXPECTED HEADERS:', ['bold', 'yellow']), $this->headers($this->result->getExpectedHeaders(), $renderer, false)); } if ($this->result->bodyDifferent()) { if ($this->result->headersAndBodyDifferent()) { $output .= "\n" . $renderer->style('- - - - - - - - -', ['default', 'bold']) . "\n\n"; } $output .= sprintf("%s %s\n\n%s %s\n", $renderer->style('YOUR OUTPUT:', ['bold', 'yellow']), $renderer->style(sprintf('"%s"', $this->result->getActualOutput()), 'red'), $renderer->style('EXPECTED OUTPUT:', ['bold', 'yellow']), $renderer->style(sprintf('"%s"', $this->result->getExpectedOutput()), 'green')); } return $output; }