You are here

public function FormStateTest::testRewriteArbitraryKeyAsSetter in Drupal 7 to 8/9 Module Upgrader 8

File

tests/src/Unit/Plugin/DMU/Rewriter/FormStateTest.php, line 85

Class

FormStateTest
@group DMU.Rewriter @covers \Drupal\drupalmoduleupgrader\Plugin\DMU\Rewriter\FormState

Namespace

Drupal\Tests\drupalmoduleupgrader\Unit\Plugin\DMU\Rewriter

Code

public function testRewriteArbitraryKeyAsSetter() {

  /** @var \Pharborist\Operators\AssignNode $expr */
  $expr = Parser::parseExpression('$form_state["foo"]["baz"] = "bar"');
  $rewritten = $this->plugin
    ->rewriteAsSetter($expr
    ->getLeftOperand(), 'foo', $expr);
  $this
    ->assertInstanceOf('\\Pharborist\\Objects\\ObjectMethodCallNode', $rewritten);
  $this
    ->assertEquals('$form_state->set(["foo", "baz"], "bar")', $rewritten
    ->getText());
}