X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fdrupalmoduleupgrader%2Ftests%2Fsrc%2FUnit%2FPlugin%2FDMU%2FFixer%2FImplementHookTest.php;fp=web%2Fmodules%2Fcontrib%2Fdrupalmoduleupgrader%2Ftests%2Fsrc%2FUnit%2FPlugin%2FDMU%2FFixer%2FImplementHookTest.php;h=f91687a14685a9e85d1980f362d6a653d35b6bf5;hp=0000000000000000000000000000000000000000;hb=8acec36f19c470dfcda1ae2336826a782f41874c;hpb=e0411c4e83ba0d079034db83c3f7f55be24a0e35 diff --git a/web/modules/contrib/drupalmoduleupgrader/tests/src/Unit/Plugin/DMU/Fixer/ImplementHookTest.php b/web/modules/contrib/drupalmoduleupgrader/tests/src/Unit/Plugin/DMU/Fixer/ImplementHookTest.php new file mode 100644 index 000000000..f91687a14 --- /dev/null +++ b/web/modules/contrib/drupalmoduleupgrader/tests/src/Unit/Plugin/DMU/Fixer/ImplementHookTest.php @@ -0,0 +1,53 @@ + 'tokens', + 'module' => 'system', + ]; + $module_handler = $this->getMock('\Drupal\Core\Extension\ModuleHandlerInterface'); + $plugin = new ImplementHook($config, uniqID(), [], $module_handler); + $plugin->setTarget($this->target); + $plugin->execute(); + + $module = $this->target->getPath('.module'); + $function = $this->target->open($module)->children(Filter::isFunction('foo_tokens'))->get(0); + $this->assertInstanceOf('\Pharborist\Functions\FunctionDeclarationNode', $function); + $this->assertEquals('foo_tokens', $function->getName()->getText()); + + $parameters = $function->getParameters(); + $this->assertCount(4, $parameters); + + $this->assertNull($parameters[0]->getTypeHint()); + $this->assertEquals('type', $parameters[0]->getName()); + $this->assertNull($parameters[0]->getValue()); + + $this->assertNull($parameters[1]->getTypeHint()); + $this->assertEquals('tokens', $parameters[1]->getName()); + $this->assertNull($parameters[1]->getValue()); + + $this->assertInstanceOf('\Pharborist\TokenNode', $parameters[2]->getTypeHint()); + $this->assertSame(T_ARRAY, $parameters[2]->getTypeHint()->getType()); + $this->assertEquals('data', $parameters[2]->getName()); + $this->assertInstanceOf('\Pharborist\Types\ArrayNode', $parameters[2]->getValue()); + + $this->assertInstanceOf('\Pharborist\TokenNode', $parameters[3]->getTypeHint()); + $this->assertSame(T_ARRAY, $parameters[3]->getTypeHint()->getType()); + $this->assertEquals('options', $parameters[3]->getName()); + $this->assertInstanceOf('\Pharborist\Types\ArrayNode', $parameters[3]->getValue()); + } + +}