3 namespace Drupal\Tests\drupalmoduleupgrader\Unit\Plugin\DMU\Fixer;
5 use Drupal\drupalmoduleupgrader\Plugin\DMU\Fixer\ImplementHook;
6 use Drupal\Tests\drupalmoduleupgrader\Unit\TestBase;
12 class ImplementHookTest extends TestBase {
14 public function test() {
15 eval('function hook_tokens($type, $tokens, array $data = array(), array $options = array()) {}');
21 $module_handler = $this->getMock('\Drupal\Core\Extension\ModuleHandlerInterface');
22 $plugin = new ImplementHook($config, uniqID(), [], $module_handler);
23 $plugin->setTarget($this->target);
26 $module = $this->target->getPath('.module');
27 $function = $this->target->open($module)->children(Filter::isFunction('foo_tokens'))->get(0);
28 $this->assertInstanceOf('\Pharborist\Functions\FunctionDeclarationNode', $function);
29 $this->assertEquals('foo_tokens', $function->getName()->getText());
31 $parameters = $function->getParameters();
32 $this->assertCount(4, $parameters);
34 $this->assertNull($parameters[0]->getTypeHint());
35 $this->assertEquals('type', $parameters[0]->getName());
36 $this->assertNull($parameters[0]->getValue());
38 $this->assertNull($parameters[1]->getTypeHint());
39 $this->assertEquals('tokens', $parameters[1]->getName());
40 $this->assertNull($parameters[1]->getValue());
42 $this->assertInstanceOf('\Pharborist\TokenNode', $parameters[2]->getTypeHint());
43 $this->assertSame(T_ARRAY, $parameters[2]->getTypeHint()->getType());
44 $this->assertEquals('data', $parameters[2]->getName());
45 $this->assertInstanceOf('\Pharborist\Types\ArrayNode', $parameters[2]->getValue());
47 $this->assertInstanceOf('\Pharborist\TokenNode', $parameters[3]->getTypeHint());
48 $this->assertSame(T_ARRAY, $parameters[3]->getTypeHint()->getType());
49 $this->assertEquals('options', $parameters[3]->getName());
50 $this->assertInstanceOf('\Pharborist\Types\ArrayNode', $parameters[3]->getValue());