3 namespace Drupal\Tests\drupalmoduleupgrader\Unit\Plugin\DMU\Analyzer;
5 use Drupal\drupalmoduleupgrader\Plugin\DMU\Indexer\Functions;
9 * @covers \Drupal\drupalmoduleupgrader\Plugin\DMU\Analyzer\HookFormAlter
11 class HookFormAlterTest extends AnalyzerTestBase {
13 public function setUp() {
20 * Implements hook_form_alter().
22 function foo_form_alter(array &$form, array &$form_state, $form_id) {
26 * Implements hook_form_FORM_ID_alter().
28 function foo_form_blarg_alter(array &$form, array &$form_state) {
31 $this->dir->getChild('foo.module')->setContent($code);
33 $function_indexer = new Functions([], 'function', [], $this->db, $this->target);
34 $function_indexer->build();
37 ->get('plugin.manager.drupalmoduleupgrader.indexer')
38 ->method('createInstance')
40 ->willReturn($function_indexer);
42 $this->analyzer = $this->getPlugin();
45 public function testHookFormAlter() {
46 $issues = $this->analyzer->analyze($this->target);
47 $this->assertInternalType('array', $issues);
48 $this->assertNotEmpty($issues);
49 $this->assertIssueDefaults($issues[0]);
50 $this->assertCount(2, $issues[0]->getViolations());
53 public function testDerivedFormAlter() {
54 $issues = $this->analyzer->analyze($this->target);
55 $this->assertInternalType('array', $issues);
56 $this->assertNotEmpty($issues);
57 $this->assertIssueDefaults($issues[0]);
58 $this->assertCount(2, $issues[0]->getViolations());