getMock('\JakubOnderka\PhpConsoleColor\ConsoleColor'); $mock->expects($this->any()) ->method('apply') ->will($this->returnCallback(function ($style, $text) { return "<$style>$text"; })); $mock->expects($this->any()) ->method('hasTheme') ->will($this->returnValue(true)); return $mock; } protected function setUp() { $this->uut = new Highlighter($this->getConsoleColorMock()); } protected function compare($original, $expected) { $output = $this->uut->getWholeFile($original); $this->assertEquals($expected, $output); } public function testVariable() { $this->compare( << echo \$a; EOL ); } public function testInteger() { $this->compare( << echo 43; EOL ); } public function testFloat() { $this->compare( << echo 43.3; EOL ); } public function testHex() { $this->compare( << echo 0x43; EOL ); } public function testBasicFunction() { $this->compare( << function plus(\$a, \$b) { return \$a + \$b; } EOL ); } public function testStringNormal() { $this->compare( << echo 'Ahoj světe'; EOL ); } public function testStringDouble() { $this->compare( << echo "Ahoj světe"; EOL ); } public function testInstanceof() { $this->compare( << \$a instanceof stdClass; EOL ); } /* * Constants */ public function testConstant() { $constants = array( '__FILE__', '__LINE__', '__CLASS__', '__FUNCTION__', '__METHOD__', '__TRAIT__', '__DIR__', '__NAMESPACE__' ); foreach ($constants as $constant) { $this->compare( << $constant; EOL ); } } /* * Comments */ public function testComment() { $this->compare( << /* Ahoj */ EOL ); } public function testDocComment() { $this->compare( << /** Ahoj */ EOL ); } public function testInlineComment() { $this->compare( << // Ahoj EOL ); } public function testHashComment() { $this->compare( << # Ahoj EOL ); } }