Example #1
0
 public function renderAll()
 {
     $renderer = new SyntaxRenderer();
     $lines = array($renderer->render('? is null', array(null)), $renderer->render('? does not equal ?', array(true, false)), $renderer->render('? has key ? with value ?', array(array("foo" => 123), 'foo', 123)), $renderer->render('? is instance of ?', array(new DateTime(), 'DateTime')), $renderer->render('? equals ? within ?', array(1.57, 1.5, 0.5)), $renderer->render('? is instance of ?', array(function () {
     }, 'Closure')));
     return "Some assertion examples:\n\n" . implode("\n\n", $lines) . "\n\n";
 }
 protected function expectFailure($message)
 {
     $this->setExpectedException('Concise\\Core\\DidNotMatchException', $message);
     SyntaxRenderer::$color = false;
 }
 /**
  * @group #250
  */
 public function testResourceRendering()
 {
     $this->assertString($this->renderer->render('?', array(fopen('.', 'r'))))->matches('/Resource id #\\d+/');
 }
Example #4
0
 /**
  * @return void
  */
 public function tearDown()
 {
     AssertionBuilder::validateLastAssertion();
     $this->mockManager->validateMocks();
     if ($this->verifyFailures) {
         $count = count($this->verifyFailures);
         $message = "{$count} verify failure" . ($count === 1 ? '' : 's') . ":";
         $message .= "\n\n" . implode("\n\n", $this->verifyFailures);
         throw new PHPUnit_Framework_AssertionFailedError($message);
     }
     SyntaxRenderer::$color = true;
     parent::tearDown();
 }
Example #5
0
 /**
  * @param string $syntax
  * @param array  $data
  * @return string
  */
 public function renderFailureMessage($syntax, array $data = array())
 {
     $renderer = new SyntaxRenderer();
     return $renderer->render($syntax, $data);
 }
 public function testCustomMessageWithAssertionFailure()
 {
     SyntaxRenderer::$color = false;
     $this->assert('Something', true)->equals(false);
 }