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%2FImplementTest.php;fp=web%2Fmodules%2Fcontrib%2Fdrupalmoduleupgrader%2Ftests%2Fsrc%2FUnit%2FPlugin%2FDMU%2FFixer%2FImplementTest.php;h=6e04517f18a11c930a846add430a88fbf0e03edf;hp=0000000000000000000000000000000000000000;hb=8acec36f19c470dfcda1ae2336826a782f41874c;hpb=e0411c4e83ba0d079034db83c3f7f55be24a0e35 diff --git a/web/modules/contrib/drupalmoduleupgrader/tests/src/Unit/Plugin/DMU/Fixer/ImplementTest.php b/web/modules/contrib/drupalmoduleupgrader/tests/src/Unit/Plugin/DMU/Fixer/ImplementTest.php new file mode 100644 index 000000000..6e04517f1 --- /dev/null +++ b/web/modules/contrib/drupalmoduleupgrader/tests/src/Unit/Plugin/DMU/Fixer/ImplementTest.php @@ -0,0 +1,55 @@ +getMock('\Drupal\drupalmoduleupgrader\IndexerInterface'); + $indexer->method('get')->with('Foobaz')->willReturn(new NodeCollection([$class])); + + $this + ->container + ->get('plugin.manager.drupalmoduleupgrader.indexer') + ->method('createInstance') + ->with('class') + ->willReturn($indexer); + + $config = [ + 'definition' => '\Drupal\Core\Block\BlockPluginInterface::blockForm', + 'target' => 'Foobaz', + ]; + $plugin = new Implement($config, uniqID(), []); + $plugin->setTarget($this->target); + try { + // We expect a CodeManagerIOException because we're implementing the + // method on a class that is not officially part of the target's code. + // That's OK, though. + $plugin->execute(); + } + catch (IOException $e) {} + + $this->assertTrue($class->hasMethod('blockForm')); + $method = $class->getMethod('blockForm'); + $this->assertInstanceOf('\Pharborist\Objects\ClassMethodNode', $method); + $parameters = $method->getParameters(); + $this->assertCount(2, $parameters); + $this->assertEquals($parameters[0]->getName(), 'form'); + $this->assertNull($parameters[0]->getTypeHint()); + $this->assertEquals($parameters[1]->getName(), 'form_state'); + $type = $parameters[1]->getTypeHint(); + $this->assertInstanceOf('\Pharborist\Namespaces\NameNode', $type); + $this->assertEquals('Drupal\Core\Form\FormStateInterface', $type->getText()); + } + +}