FieldViewValueTest.php in Drupal 7 to 8/9 Module Upgrader 8
File
tests/src/Unit/Plugin/DMU/Converter/Functions/FieldViewValueTest.php
View source
<?php
namespace Drupal\Tests\drupalmoduleupgrader\Unit\Plugin\DMU\Converter\Functions;
use Pharborist\Parser;
class FieldViewValueTest extends FunctionCallModifierTestBase {
public function testRewriteViewMode() {
$function_call = Parser::parseExpression('field_view_value("node", $node, "field_foo", $item, $view_mode, $langcode)');
$rewritten = $this->plugin
->rewrite($function_call, $this->target);
$this
->assertInstanceOf('\\Pharborist\\Objects\\ObjectMethodCallNode', $rewritten);
$this
->assertEquals('$item->view($view_mode)', $rewritten
->getText());
}
public function testRewriteDisplayOptions() {
$function_call = Parser::parseExpression('field_view_value("node", $node, "field_foo", $item, array("type" => "some_formatter"), $langcode)');
$rewritten = $this->plugin
->rewrite($function_call, $this->target);
$this
->assertInstanceOf('\\Pharborist\\Objects\\ObjectMethodCallNode', $rewritten);
$this
->assertEquals('$item->view(array("type" => "some_formatter"))', $rewritten
->getText());
}
}