public function DeleteTest::test in Drupal 7 to 8/9 Module Upgrader 8
File
- tests/
src/ Unit/ Plugin/ DMU/ Fixer/ DeleteTest.php, line 17
Class
- DeleteTest
- @group DMU.Fixer
Namespace
Drupal\Tests\drupalmoduleupgrader\Unit\Plugin\DMU\FixerCode
public function test() {
$code = <<<'END'
<?php
function foo_permission() {
return array(
'bazify' => array(
'title' => 'Do snazzy bazzy things',
),
);
}
END;
$this->dir
->getChild('foo.module')
->setContent($code);
$indexer = new Functions([], 'function', [], $this->db, $this->target);
$indexer
->build();
$this->container
->get('plugin.manager.drupalmoduleupgrader.indexer')
->method('createInstance')
->with('function')
->willReturn($indexer);
$config = [
'type' => 'function',
'id' => 'hook_permission',
];
$plugin = new Delete($config, uniqid(), []);
$plugin
->setTarget($this->target);
$plugin
->execute();
$this
->assertFalse($indexer
->has('permission'));
$this
->assertEquals("<?php\n\n", $this->dir
->getChild('foo.module')
->getContent());
}