You are here

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

Same name in this branch
  1. 8 tests/src/Unit/Plugin/DMU/Analyzer/DBTest.php \Drupal\Tests\drupalmoduleupgrader\Unit\Plugin\DMU\Analyzer\DBTest::setUp()
  2. 8 tests/src/Unit/Plugin/DMU/Converter/Functions/DBTest.php \Drupal\Tests\drupalmoduleupgrader\Unit\Plugin\DMU\Converter\Functions\DBTest::setUp()

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

Overrides TestBase::setUp

File

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

Class

DBTest
@group DMU.Analyzer @covers \Drupal\drupalmoduleupgrader\Plugin\DMU\Analyzer\DB

Namespace

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

Code

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);
  $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' => 'db_delete',
  ]);
}