You are here

public function HookFormAlterTest::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/HookFormAlterTest.php, line 13

Class

HookFormAlterTest
@group DMU.Analyzer @covers \Drupal\drupalmoduleupgrader\Plugin\DMU\Analyzer\HookFormAlter

Namespace

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

Code

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

/**
 * Implements hook_form_alter().
 */
function foo_form_alter(array &$form, array &$form_state, $form_id) {
}

/**
 * Implements hook_form_FORM_ID_alter().
 */
function foo_form_blarg_alter(array &$form, array &$form_state) {
}
END;
  $this->dir
    ->getChild('foo.module')
    ->setContent($code);
  $function_indexer = new Functions([], 'function', [], $this->db, $this->target);
  $function_indexer
    ->build();
  $this->container
    ->get('plugin.manager.drupalmoduleupgrader.indexer')
    ->method('createInstance')
    ->with('function')
    ->willReturn($function_indexer);
  $this->analyzer = $this
    ->getPlugin();
}