4 * This file is part of Psy Shell.
6 * (c) 2012-2017 Justin Hileman
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Psy\Test\Formatter;
14 use Psy\Formatter\CodeFormatter;
16 class CodeFormatterTest extends \PHPUnit\Framework\TestCase
18 private function ignoreThisMethod($arg)
23 public function testFormat()
26 > 18| private function ignoreThisMethod($arg)
32 $formatted = CodeFormatter::format(new \ReflectionMethod($this, 'ignoreThisMethod'));
33 $formattedWithoutColors = preg_replace('#' . chr(27) . '\[\d\d?m#', '', $formatted);
35 $this->assertEquals($expected, rtrim($formattedWithoutColors));
36 $this->assertNotEquals($expected, rtrim($formatted));
40 * @dataProvider filenames
41 * @expectedException \Psy\Exception\RuntimeException
43 public function testCodeFormatterThrowsException($filename)
45 $reflector = $this->getMockBuilder('ReflectionClass')
46 ->disableOriginalConstructor()
50 ->expects($this->once())
51 ->method('getFileName')
52 ->will($this->returnValue($filename));
54 CodeFormatter::format($reflector);
57 public function filenames()
59 if (defined('HHVM_VERSION')) {
60 $this->markTestSkipped('We have issues with PHPUnit mocks on HHVM.');
63 return array(array(null), array('not a file'));