You are here

NotifyTest.php in Drupal 7 to 8/9 Module Upgrader 8

File

tests/src/Unit/Plugin/DMU/Fixer/NotifyTest.php
View source
<?php

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

use Drupal\drupalmoduleupgrader\Plugin\DMU\Fixer\Notify;
use Drupal\Tests\drupalmoduleupgrader\Unit\TestBase;
use Pharborist\DocCommentNode;
use Pharborist\NodeCollection;
use Pharborist\Objects\ClassNode;

/**
 * @group DMU.Fixer
 *
 * @TODO Add a test of the 'where' configuration option.
 */
class NotifyTest extends TestBase {
  public function testDocComment() {
    $class = ClassNode::create('Wambooli');
    $class
      ->setDocComment(DocCommentNode::create('Double wambooli!'));
    $this
      ->assertInstanceOf('\\Pharborist\\DocCommentNode', $class
      ->getDocComment());
    $indexer = $this
      ->getMock('\\Drupal\\drupalmoduleupgrader\\IndexerInterface');
    $indexer
      ->method('get')
      ->with('Wambooli')
      ->willReturn(new NodeCollection([
      $class,
    ]));
    $this->container
      ->get('plugin.manager.drupalmoduleupgrader.indexer')
      ->method('createInstance')
      ->with('class')
      ->willReturn($indexer);
    $config = [
      'type' => 'class',
      'id' => 'Wambooli',
      'note' => 'You need to rewrite this thing because I said so!',
    ];
    $plugin = new Notify($config, uniqid(), []);
    $plugin
      ->setTarget($this->target);
    $plugin
      ->execute();
    $comment = $class
      ->getDocComment();
    $this
      ->assertInstanceOf('\\Pharborist\\DocCommentNode', $comment);
    $expected = <<<END
Double wambooli!

You need to rewrite this thing because I said so!
END;
    $this
      ->assertEquals($expected, $comment
      ->getCommentText());
  }

}

Classes

Namesort descending Description
NotifyTest @group DMU.Fixer