3 namespace Drupal\Tests\drupalmoduleupgrader\Unit\Plugin\DMU\Converter\Functions;
8 * @group DMU.Converter.Functions
9 * @covers \Drupal\drupalmoduleupgrader\Plugin\DMU\Converter\Functions\Watchdog
11 class WatchdogTest extends FunctionCallModifierTestBase {
13 public function testRewriteNoVariablesDefaultSeverity() {
14 $function_call = Parser::parseExpression('watchdog("foo", "Hi!")');
15 $rewritten = $this->plugin->rewrite($function_call, $this->target);
16 $this->assertInstanceOf('\Pharborist\Objects\ObjectMethodCallNode', $rewritten);
17 $this->assertEquals('\Drupal::logger("foo")->notice("Hi!", [])', $rewritten->getText());
20 public function testRewriteVariablesDefaultSeverity() {
21 $function_call = Parser::parseExpression('watchdog("foo", "Hej", array("baz"))');
22 $rewritten = $this->plugin->rewrite($function_call, $this->target);
23 $this->assertInstanceOf('\Pharborist\Objects\ObjectMethodCallNode', $rewritten);
24 $this->assertEquals('\Drupal::logger("foo")->notice("Hej", array("baz"))', $rewritten->getText());
27 public function testRewriteNoVariablesSeverity() {
28 $function_call = Parser::parseExpression('watchdog("foo", "Harrr", NULL, WATCHDOG_WARNING)');
29 $rewritten = $this->plugin->rewrite($function_call, $this->target);
30 $this->assertInstanceOf('\Pharborist\Objects\ObjectMethodCallNode', $rewritten);
31 $this->assertEquals('\Drupal::logger("foo")->warning("Harrr", [])', $rewritten->getText());
34 public function testRewriteVariablesSeverity() {
35 $function_call = Parser::parseExpression('watchdog("foo", "Hurrr", array("baz"), WATCHDOG_ERROR)');
36 $rewritten = $this->plugin->rewrite($function_call, $this->target);
37 $this->assertInstanceOf('\Pharborist\Objects\ObjectMethodCallNode', $rewritten);
38 $this->assertEquals('\Drupal::logger("foo")->error("Hurrr", array("baz"))', $rewritten->getText());
41 public function testRewriteNoVariablesDynamicSeverity() {
42 $function_call = Parser::parseExpression('watchdog("foo", "Barrr", NULL, get_severity())');
43 $rewritten = $this->plugin->rewrite($function_call, $this->target);
44 $this->assertInstanceOf('\Pharborist\Objects\ObjectMethodCallNode', $rewritten);
45 $this->assertEquals('\Drupal::logger("foo")->notice("Barrr", [])', $rewritten->getText());
48 public function testRewriteVariablesTernarySeverity() {
49 $function_call = Parser::parseExpression('watchdog("foo", "Yarrr", array(0), $bipolar ? WATCHDOG_NOTICE : WATCHDOG_CRITICAL)');
50 $rewritten = $this->plugin->rewrite($function_call, $this->target);
51 $this->assertInstanceOf('\Pharborist\Objects\ObjectMethodCallNode', $rewritten);
52 $this->assertEquals('\Drupal::logger("foo")->notice("Yarrr", array(0))', $rewritten->getText());
55 public function testRewriteNoVariablesUnknownSeverity() {
56 $function_call = Parser::parseExpression('watchdog("foo", "Ba-zing!", NULL, WATCHDOG_FOO)');
57 $rewritten = $this->plugin->rewrite($function_call, $this->target);
58 $this->assertInstanceOf('\Pharborist\Objects\ObjectMethodCallNode', $rewritten);
59 $this->assertEquals('\Drupal::logger("foo")->notice("Ba-zing!", [])', $rewritten->getText());