You are here

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

Class

FunctionCallTest
@group DMU.Analyzer @covers \Drupal\drupalmoduleupgrader\Plugin\DMU\Analyzer\FunctionCall

Namespace

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

Code

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);
  $plugin_defination = [
    'exclude' => [
      't',
    ],
  ];
  $indexer = new FunctionCalls([], 'function', $plugin_defination, $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',
  ]);
}