DisableTest.php in Drupal 7 to 8/9 Module Upgrader 8
File
tests/src/Unit/Plugin/DMU/Fixer/DisableTest.php
View source
<?php
namespace Drupal\Tests\drupalmoduleupgrader\Unit\Plugin\DMU\Fixer;
use Drupal\drupalmoduleupgrader\Plugin\DMU\Fixer\Disable;
use Drupal\drupalmoduleupgrader\Plugin\DMU\Indexer\FunctionCalls;
use Drupal\Tests\drupalmoduleupgrader\Unit\TestBase;
class DisableTest extends TestBase {
public function test() {
$code = <<<'END'
<?php
variable_get('foo');
END;
$this->dir
->getChild('foo.module')
->setContent(rtrim($code));
$indexer = new FunctionCalls([], 'function', [
'exclude' => [],
], $this->db, $this->target);
$indexer
->build();
$this->container
->get('plugin.manager.drupalmoduleupgrader.indexer')
->method('createInstance')
->with('function_call')
->willReturn($indexer);
$config = [
'type' => 'function_call',
'id' => 'variable_get',
'note' => 'This is no longer kosher!',
];
$plugin = new Disable($config, uniqid(), []);
$plugin
->setTarget($this->target);
$plugin
->execute();
$expected = <<<END
<?php
// This is no longer kosher!
// variable_get('foo');
END;
$this
->assertEquals($expected, trim($this->dir
->getChild('foo.module')
->getContent()));
}
}