8 use \Magento\Framework\View\Layout\Argument\Interpreter\HelperMethod;
29 $this->_objectManager = $this->createMock(\
Magento\Framework\ObjectManagerInterface::class);
30 $this->_interpreter = $this->createMock(\
Magento\Framework\
View\
Layout\Argument\Interpreter\NamedParams::class);
31 $this->_model =
new HelperMethod($this->_objectManager, $this->_interpreter);
36 $input = [
'value' =>
'some text',
'helper' => __CLASS__ .
'::help'];
38 $evaluatedValue = [
'value' =>
'some text (evaluated)'];
39 $this->_interpreter->expects(
46 $this->returnValue($evaluatedValue)
49 $this->_objectManager->expects($this->once())->method(
'get')->with(__CLASS__)->will($this->returnValue($this));
51 $expected =
'some text (evaluated) (updated)';
52 $actual = $this->_model->evaluate($input);
53 $this->assertSame($expected, $actual);
60 public function help($input)
62 $this->assertSame(
'some text (evaluated)', $input);
63 return $input .
' (updated)';
74 $this->expectException(
'\InvalidArgumentException');
75 $this->expectExceptionMessage($expectedExceptionMessage);
76 $input = [
'value' =>
'some text',
'helper' => $helperMethod];
77 $this->_model->evaluate($input);
85 $nonExistingHelper = __CLASS__ .
'::non_existing';
87 'wrong method format' => [
89 'Helper method name in format "\Class\Name::methodName" is expected',
91 'non-existing method' => [$nonExistingHelper,
"Helper method '{$nonExistingHelper}' does not exist"]
evaluateExceptionDataProvider()
testEvaluateException($helperMethod, $expectedExceptionMessage)