You are here

public function PSR4Test::test in Drupal 7 to 8/9 Module Upgrader 8

Same name in this branch
  1. 8 tests/src/Unit/Plugin/DMU/Analyzer/PSR4Test.php \Drupal\Tests\drupalmoduleupgrader\Unit\Plugin\DMU\Analyzer\PSR4Test::test()
  2. 8 tests/src/Unit/Plugin/DMU/Fixer/PSR4Test.php \Drupal\Tests\drupalmoduleupgrader\Unit\Plugin\DMU\Fixer\PSR4Test::test()

File

tests/src/Unit/Plugin/DMU/Fixer/PSR4Test.php, line 14

Class

PSR4Test
@group DMU.Fixer

Namespace

Drupal\Tests\drupalmoduleupgrader\Unit\Plugin\DMU\Fixer

Code

public function test() {
  $class = ClassNode::create('Wambooli');
  $indexer = $this
    ->createMock('\\Drupal\\drupalmoduleupgrader\\IndexerInterface');

  //$indexer->method('get')->with('Wambooli')->willReturn(new NodeCollection([$class]));
  $indexer
    ->method('get')
    ->with('Wambooli')
    ->willReturn($class);
  $this->container
    ->get('plugin.manager.drupalmoduleupgrader.indexer')
    ->method('createInstance')
    ->with('class')
    ->willReturn($indexer);
  $config = [
    'source' => 'Wambooli',
    'destination' => 'Drupal\\foo\\Wambooli',
  ];
  $plugin = new PSR4($config, uniqid(), []);
  $plugin
    ->setTarget($this->target);
  $plugin
    ->execute();
  $url = $this->target
    ->getPath('src/Wambooli.php');
  $this
    ->assertFileExists($url);
}