You are here

public function HookUninstalltest::setUp in Drupal 7 to 8/9 Module Upgrader 8

Mocks an entire module, called foo, in a virtual file system.

Overrides TestBase::setUp

File

tests/src/Unit/Plugin/DMU/Analyzer/HookUninstallTest.php, line 13

Class

HookUninstalltest
@group DMU.Analyzer @covers \Drupal\drupalmoduleupgrader\Plugin\DMU\Analyzer\HookUninstall

Namespace

Drupal\Tests\drupalmoduleupgrader\Unit\Plugin\DMU\Analyzer

Code

public function setUp() {
  parent::setUp();
  $code = <<<'END'
<?php

/**
 * Implements hook_uninstall().
 */
function foo_uninstall() {
  variable_del('foo_baz');
}
END;
  $this->dir
    ->getChild('foo.install')
    ->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);
  $this->analyzer = $this
    ->getPlugin();
}