Further modules included.
[yaffs-website] / web / modules / contrib / drupalmoduleupgrader / tests / src / Unit / Plugin / DMU / Fixer / NotifyTest.php
1 <?php
2
3 namespace Drupal\Tests\drupalmoduleupgrader\Unit\Plugin\DMU\Fixer;
4
5 use Drupal\drupalmoduleupgrader\Plugin\DMU\Fixer\Notify;
6 use Drupal\Tests\drupalmoduleupgrader\Unit\TestBase;
7 use Pharborist\DocCommentNode;
8 use Pharborist\NodeCollection;
9 use Pharborist\Objects\ClassNode;
10
11 /**
12  * @group DMU.Fixer
13  *
14  * @TODO Add a test of the 'where' configuration option.
15  */
16 class NotifyTest extends TestBase {
17
18   public function testDocComment() {
19     $class = ClassNode::create('Wambooli');
20     $class->setDocComment(DocCommentNode::create('Double wambooli!'));
21     $this->assertInstanceOf('\Pharborist\DocCommentNode', $class->getDocComment());
22     $indexer = $this->getMock('\Drupal\drupalmoduleupgrader\IndexerInterface');
23     $indexer->method('get')->with('Wambooli')->willReturn(new NodeCollection([ $class ]));
24
25     $this
26       ->container
27       ->get('plugin.manager.drupalmoduleupgrader.indexer')
28       ->method('createInstance')
29       ->with('class')
30       ->willReturn($indexer);
31
32     $config = [
33       'type' => 'class',
34       'id' => 'Wambooli',
35       'note' => 'You need to rewrite this thing because I said so!',
36     ];
37     $plugin = new Notify($config, uniqID(), []);
38     $plugin->setTarget($this->target);
39     $plugin->execute();
40
41     $comment = $class->getDocComment();
42     $this->assertInstanceOf('\Pharborist\DocCommentNode', $comment);
43     $expected = <<<END
44 Double wambooli!
45
46 You need to rewrite this thing because I said so!
47 END;
48     $this->assertEquals($expected, $comment->getCommentText());
49   }
50
51 }