Further modules included.
[yaffs-website] / web / modules / contrib / drupalmoduleupgrader / tests / src / Unit / Plugin / DMU / Fixer / DeleteTest.php
1 <?php
2
3 namespace Drupal\Tests\drupalmoduleupgrader\Unit\Plugin\DMU\Fixer;
4
5 use Drupal\drupalmoduleupgrader\Plugin\DMU\Fixer\Delete;
6 use Drupal\drupalmoduleupgrader\Plugin\DMU\Indexer\Functions;
7 use Drupal\Tests\drupalmoduleupgrader\Unit\TestBase;
8
9 /**
10  * @group DMU.Fixer
11  *
12  * @TODO Add a test of the 'where' configuration option.
13  */
14 class
15 DeleteTest extends TestBase {
16
17   public function test() {
18     $code = <<<'END'
19 <?php
20
21 function foo_permission() {
22   return array(
23     'bazify' => array(
24       'title' => 'Do snazzy bazzy things',
25     ),
26   );
27 }
28 END;
29     $this->dir->getChild('foo.module')->setContent($code);
30
31     $indexer = new Functions([], 'function', [], $this->db, $this->target);
32     $indexer->build();
33
34     $this
35       ->container
36       ->get('plugin.manager.drupalmoduleupgrader.indexer')
37       ->method('createInstance')
38       ->with('function')
39       ->willReturn($indexer);
40
41     $config = [
42       'type' => 'function',
43       'id' => 'hook_permission',
44     ];
45     $plugin = new Delete($config, uniqid(), []);
46     $plugin->setTarget($this->target);
47     $plugin->execute();
48
49     $this->assertFalse($indexer->has('permission'));
50     $this->assertEquals("<?php\n\n", $this->dir->getChild('foo.module')->getContent());
51   }
52
53 }