3 namespace Drupal\Tests\drupalmoduleupgrader\Unit\Plugin\DMU\Converter\Functions;
9 * @group DMU.Converter.Functions
10 * @covers \Drupal\drupalmoduleupgrader\Plugin\DMU\Converter\Functions\CommentLoad
12 class CommentLoadTest extends FunctionCallModifierTestBase {
14 public function testRewriteWithoutCacheReset() {
15 $function_call = Parser::parseExpression('comment_load(30)');
16 $rewritten = $this->plugin->rewrite($function_call, $this->target);
17 $this->assertInstanceOf('\Pharborist\Objects\ObjectMethodCallNode', $rewritten);
18 $this->assertEquals('\Drupal::entityManager()->getStorage(\'comment\')->load(30)', $rewritten->getText());
21 public function testRewriteWithCacheReset() {
23 comment_load(30, TRUE);
27 // To reset the comment cache, use EntityStorageInterface::resetCache().
28 \Drupal::entityManager()->getStorage('comment')->load(30);
30 $snippet = Parser::parseSnippet($original);
31 $function_call = $snippet->children(Filter::isFunctionCall('comment_load'))->get(0);
32 $rewritten = $this->plugin->rewrite($function_call, $this->target);
33 $function_call->replaceWith($rewritten);
34 $this->assertEquals($expected, $snippet->getText());