public function GenericTest::testRewriteEmpty in Drupal 7 to 8/9 Module Upgrader 8
File
- tests/
src/ Unit/ Plugin/ DMU/ Rewriter/ GenericTest.php, line 100
Class
- GenericTest
- @group DMU.Rewriter @covers \Drupal\drupalmoduleupgrader\Plugin\DMU\Rewriter\Generic
Namespace
Drupal\Tests\drupalmoduleupgrader\Unit\Plugin\DMU\RewriterCode
public function testRewriteEmpty() {
$code = <<<'END'
function foo($baz) {
if (empty($baz->nid)) {
}
}
END;
/** @var \Pharborist\Functions\FunctionDeclarationNode $func */
$func = Parser::parseSnippet($code);
$this->plugin
->rewrite($func
->getParameterAtIndex(0));
$expected = <<<'END'
function foo($baz) {
if (!$baz->id()) {
}
}
END;
$this
->assertEquals($expected, $func
->getText());
}