public function setUp() { parent::setUp(); $code = <<<'END' <?php function foo_blorf() { $data = array(); drupal_write_record($data, 'id'); } END; $this->dir->getChild('foo.module')->setContent($code); $indexer = new FunctionCalls([], 'function', [], $this->db, $this->target); $indexer->build(); $this->container->get('plugin.manager.drupalmoduleupgrader.indexer')->method('createInstance')->with('function_call')->willReturn($indexer); $this->analyzer = $this->getPlugin([], ['function' => 'drupal_write_record']); }
public function setUp() { parent::setUp(); $code = <<<'END' <?php /** * Implements hook_uninstall(). */ function foo_uninstall() { db_delete('variable')->condition('name', 'foo_baz')->execute(); } END; $this->dir->getChild('foo.install')->setContent($code); $indexer = new FunctionCalls([], 'function', [], $this->db, $this->target); $indexer->build(); $this->container->get('plugin.manager.drupalmoduleupgrader.indexer')->method('createInstance')->with('function_call')->willReturn($indexer); $this->analyzer = $this->getPlugin([], ['function' => 'db_delete']); }
public function test() { $code = <<<'END' <?php variable_get('foo'); END; $this->dir->getChild('foo.module')->setContent(rtrim($code)); $indexer = new FunctionCalls([], 'function', ['exclude' => []], $this->db, $this->target); $indexer->build(); $this->container->get('plugin.manager.drupalmoduleupgrader.indexer')->method('createInstance')->with('function_call')->willReturn($indexer); $config = ['type' => 'function_call', 'id' => 'variable_get', 'note' => 'This is no longer kosher!']; $plugin = new Disable($config, uniqID(), []); $plugin->setTarget($this->target); $plugin->execute(); $expected = <<<END <?php // This is no longer kosher! // variable_get('foo'); END; // trim() makes the test pass. Go figure. $this->assertEquals($expected, trim($this->dir->getChild('foo.module')->getContent())); }