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%2FConverter%2FFunctions%2FCommentLoadTest.php;fp=web%2Fmodules%2Fcontrib%2Fdrupalmoduleupgrader%2Ftests%2Fsrc%2FUnit%2FPlugin%2FDMU%2FConverter%2FFunctions%2FCommentLoadTest.php;h=9ff350301abdfb07f93e9474fc67b46c64fe02f0;hp=0000000000000000000000000000000000000000;hb=8acec36f19c470dfcda1ae2336826a782f41874c;hpb=e0411c4e83ba0d079034db83c3f7f55be24a0e35 diff --git a/web/modules/contrib/drupalmoduleupgrader/tests/src/Unit/Plugin/DMU/Converter/Functions/CommentLoadTest.php b/web/modules/contrib/drupalmoduleupgrader/tests/src/Unit/Plugin/DMU/Converter/Functions/CommentLoadTest.php new file mode 100644 index 000000000..9ff350301 --- /dev/null +++ b/web/modules/contrib/drupalmoduleupgrader/tests/src/Unit/Plugin/DMU/Converter/Functions/CommentLoadTest.php @@ -0,0 +1,37 @@ +plugin->rewrite($function_call, $this->target); + $this->assertInstanceOf('\Pharborist\Objects\ObjectMethodCallNode', $rewritten); + $this->assertEquals('\Drupal::entityManager()->getStorage(\'comment\')->load(30)', $rewritten->getText()); + } + + public function testRewriteWithCacheReset() { + $original = <<<'END' +comment_load(30, TRUE); +END; + $expected = <<<'END' +// @FIXME +// To reset the comment cache, use EntityStorageInterface::resetCache(). +\Drupal::entityManager()->getStorage('comment')->load(30); +END; + $snippet = Parser::parseSnippet($original); + $function_call = $snippet->children(Filter::isFunctionCall('comment_load'))->get(0); + $rewritten = $this->plugin->rewrite($function_call, $this->target); + $function_call->replaceWith($rewritten); + $this->assertEquals($expected, $snippet->getText()); + } + +}