public function testConstantNameConversion() { $parser = new Parser(new Lexer()); $class = file_get_contents(__DIR__ . '/mock/constants/class_with_constants.php'); $statement = $parser->parse($class); $event = new GetClassEvent($statement[0], '/tmp/'); $event->setCode('<?php echo "some code";'); $event->setUses('use Some\\Namespace;'); $event->setNamespace('namespace Current\\Namespace;'); $plugin = new ConstantNamesToUpper(); $plugin->onSetClassUpdateConstants($event); foreach ($event->getStatements()->stmts as $constant) { $this->assertEquals($constant->consts[0]->value->value, $constant->consts[0]->name); } }
public function testOnGetClassFixClass() { $pathToFile = __DIR__ . '/mock/fixer/original/GetSomeResponse.php'; $pathToFileFixed = __DIR__ . '/mock/fixer/fixed/GetSomeResponse.php'; $code = file_get_contents($pathToFile); $statement = new Class_($code); $event = new GetClassEvent($statement, $pathToFile); $event->setCode($code); $event->setUses('use DateTime;'); $event->setNamespace('namespace SomeNameSpace\\Category;'); $plugin = new PhpCsFixer(); $plugin->onGetClassFixClass($event); $code = file_get_contents($pathToFile); $fixedCode = file_get_contents($pathToFileFixed); $this->assertEquals($fixedCode, $code, 'Files are not equal and they should be.'); }