3 namespace Drupal\Tests\drupalmoduleupgrader\Unit\Plugin\DMU\Converter\Functions;
9 * @group DMU.Converter.Functions
10 * @covers \Drupal\drupalmoduleupgrader\Plugin\DMU\Converter\Functions\VariableDel
12 class VariableDelTest extends FunctionCallModifierTestBase {
14 public function testNonStringKey() {
17 variable_del($my_var);
22 // The correct configuration object could not be determined. You'll need to
23 // rewrite this call manually.
24 variable_del($my_var);
27 $snippet = Parser::parseSource($original);
28 $function_call = $snippet->find(Filter::isFunctionCall('variable_del'))->get(0);
29 $rewritten = $this->plugin->rewrite($function_call, $this->target);
30 $this->assertNull($rewritten);
31 $this->assertSame($expected, $snippet->getText());
34 public function testForeignStringKey() {
37 variable_del('bar_wambooli');
42 // This looks like another module's variable. You'll need to rewrite this call
43 // to ensure that it uses the correct configuration object.
44 variable_del('bar_wambooli');
47 $snippet = Parser::parseSource($original);
48 $function_call = $snippet->find(Filter::isFunctionCall('variable_del'))->get(0);
49 $rewritten = $this->plugin->rewrite($function_call, $this->target);
50 $this->assertNull($rewritten);
51 $this->assertSame($expected, $snippet->getText());
54 public function testStringKey() {
55 $function_call = Parser::parseExpression('variable_del("foo_wambooli")');
56 $rewritten = $this->plugin->rewrite($function_call, $this->target);
57 $this->assertInstanceOf('\Pharborist\Objects\ObjectMethodCallNode', $rewritten);
58 $this->assertEquals('\Drupal::config(\'foo.settings\')->clear("foo_wambooli")->save()', $rewritten->getText());