public function NodeLoadTest::_testRewriteWithCacheReset in Drupal 7 to 8/9 Module Upgrader 8
This test is failing at the moment because for whatever reason, $snippet->children() is only fetching the first call to node_load().
File
- tests/
src/ Unit/ Plugin/ DMU/ Converter/ Functions/ NodeLoadTest.php, line 32
Class
- NodeLoadTest
- @group DMU.Converter.Functions @covers \Drupal\drupalmoduleupgrader\Plugin\DMU\Converter\Functions\NodeLoad
Namespace
Drupal\Tests\drupalmoduleupgrader\Unit\Plugin\DMU\Converter\FunctionsCode
public function _testRewriteWithCacheReset() {
$original = <<<'END'
node_load(30);
node_load(30, TRUE);
node_load(30, 32);
node_load(30, 32, TRUE);
END;
$expected = <<<'END'
\Drupal::entityTypeManager()->getStorage('user')->load(30);
// FIXME: To reset the node cache, use EntityStorageInterface::resetCache().
\Drupal::entityTypeManager()->getStorage('user')->load(30);
\Drupal::entityTypeManager()->getStorage('user')->loadRevision(32);
// FIXME: To reset the node cache, use EntityStorageInterface::resetCache().
\Drupal::entityTypeManager()->getStorage('user')->loadRevision(32);
END;
$snippet = Parser::parseSnippet($original);
$function_calls = $snippet
->children(Filter::isFunctionCall('node_load'));
foreach ($function_calls as $function_call) {
$rewritten = $this->plugin
->rewrite($function_call, $this->target);
$function_call
->replaceWith($rewritten);
}
$this
->assertEquals($expected, $snippet
->getText());
}