Beispiel #1
0
 /**
  * Dump Container
  *
  * @param \PHP\Manipulator\TokenContainer $container
  * @return string
  */
 public static function dumpContainer(TokenContainer $container)
 {
     $dump = '';
     $iterator = $container->getIterator();
     $dump .= str_pad('Token', 28, ' ', STR_PAD_RIGHT) . '| ' . str_pad('LEN', 4, ' ', STR_PAD_LEFT) . ' | ' . str_pad('LINE', 4, ' ', STR_PAD_LEFT) . ' | VALUE' . PHP_EOL . PHP_EOL;
     while ($iterator->valid()) {
         $token = $iterator->current();
         $dump .= Util::dumpToken($token) . PHP_EOL;
         $iterator->next();
     }
     return trim($dump);
 }
 /**
  * @covers \Tests\Constraint\ResultsMatch::failureDescription
  */
 public function testFailAndFailureDescription()
 {
     $expected = new Result();
     $other = Result::factory(array(new Token('Foo')));
     $resultsMatch = new ResultsMatch($expected);
     $message = 'Failed asserting that Results do not match: ' . PHP_EOL . 'Cause: length' . PHP_EOL . Util::compareResults($expected, $other) . '.';
     try {
         $resultsMatch->evaluate($other, '');
         $this->fail('no exception thrown');
     } catch (\PHPUnit_Framework_ExpectationFailedException $e) {
         $this->assertEquals($message, $e->getMessage());
     }
 }
 /**
  * @covers \Tests\Constraint\TokenContainerMatch::failureDescription
  */
 public function testFailAndFailureDescription()
 {
     $expected = new TokenContainer('<?php echo "foo"; ?>');
     $other = new TokenContainer('<?php echo "foo"; /* foo */ ?>');
     $containerMatch = new TokenContainerMatch($expected, false);
     $containerDiff = Util::compareContainers($expected, $other, false);
     $message = 'Failed asserting that Tokens are different:' . PHP_EOL . PHP_EOL . $containerDiff . '.';
     try {
         $containerMatch->evaluate($other);
         $this->fail('no exception thrown');
     } catch (\PHPUnit_Framework_ExpectationFailedException $e) {
         $this->assertEquals($message, $e->getMessage());
     }
 }
 /**
  * @param mixed   $other
  * @param string  $description
  * @param boolean $not
  */
 protected function failureDescription($other)
 {
     $containerDiff = Util::compareContainers($this->_expectedContainer, $other, $this->_strict);
     $message = 'Tokens are different:' . PHP_EOL . PHP_EOL . $containerDiff;
     return $message;
 }
Beispiel #5
0
 /**
  * @dataProvider resultsCompareProvider
  * @covers \Tests\Util::compareResults
  */
 public function testCompareResults($expectedResult, $actualResult, $compareString)
 {
     $this->assertSame($compareString, Util::compareResults($expectedResult, $actualResult));
 }
 /**
  * @param mixed   $other
  * @param string  $description
  * @param boolean $not
  * @return string
  */
 protected function failureDescription($other)
 {
     return 'Results do not match: ' . PHP_EOL . 'Cause: ' . $this->_cause . PHP_EOL . Util::compareResults($this->_expectedResult, $other);
 }