X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fdrupalmoduleupgrader%2Ftests%2Fsrc%2FUnit%2FPlugin%2FDMU%2FConverter%2FFunctions%2FWatchdogTest.php;fp=web%2Fmodules%2Fcontrib%2Fdrupalmoduleupgrader%2Ftests%2Fsrc%2FUnit%2FPlugin%2FDMU%2FConverter%2FFunctions%2FWatchdogTest.php;h=1e7c89e6065c733682e65aa67b5a5a83d344d7f4;hp=0000000000000000000000000000000000000000;hb=8acec36f19c470dfcda1ae2336826a782f41874c;hpb=e0411c4e83ba0d079034db83c3f7f55be24a0e35 diff --git a/web/modules/contrib/drupalmoduleupgrader/tests/src/Unit/Plugin/DMU/Converter/Functions/WatchdogTest.php b/web/modules/contrib/drupalmoduleupgrader/tests/src/Unit/Plugin/DMU/Converter/Functions/WatchdogTest.php new file mode 100644 index 000000000..1e7c89e60 --- /dev/null +++ b/web/modules/contrib/drupalmoduleupgrader/tests/src/Unit/Plugin/DMU/Converter/Functions/WatchdogTest.php @@ -0,0 +1,62 @@ +plugin->rewrite($function_call, $this->target); + $this->assertInstanceOf('\Pharborist\Objects\ObjectMethodCallNode', $rewritten); + $this->assertEquals('\Drupal::logger("foo")->notice("Hi!", [])', $rewritten->getText()); + } + + public function testRewriteVariablesDefaultSeverity() { + $function_call = Parser::parseExpression('watchdog("foo", "Hej", array("baz"))'); + $rewritten = $this->plugin->rewrite($function_call, $this->target); + $this->assertInstanceOf('\Pharborist\Objects\ObjectMethodCallNode', $rewritten); + $this->assertEquals('\Drupal::logger("foo")->notice("Hej", array("baz"))', $rewritten->getText()); + } + + public function testRewriteNoVariablesSeverity() { + $function_call = Parser::parseExpression('watchdog("foo", "Harrr", NULL, WATCHDOG_WARNING)'); + $rewritten = $this->plugin->rewrite($function_call, $this->target); + $this->assertInstanceOf('\Pharborist\Objects\ObjectMethodCallNode', $rewritten); + $this->assertEquals('\Drupal::logger("foo")->warning("Harrr", [])', $rewritten->getText()); + } + + public function testRewriteVariablesSeverity() { + $function_call = Parser::parseExpression('watchdog("foo", "Hurrr", array("baz"), WATCHDOG_ERROR)'); + $rewritten = $this->plugin->rewrite($function_call, $this->target); + $this->assertInstanceOf('\Pharborist\Objects\ObjectMethodCallNode', $rewritten); + $this->assertEquals('\Drupal::logger("foo")->error("Hurrr", array("baz"))', $rewritten->getText()); + } + + public function testRewriteNoVariablesDynamicSeverity() { + $function_call = Parser::parseExpression('watchdog("foo", "Barrr", NULL, get_severity())'); + $rewritten = $this->plugin->rewrite($function_call, $this->target); + $this->assertInstanceOf('\Pharborist\Objects\ObjectMethodCallNode', $rewritten); + $this->assertEquals('\Drupal::logger("foo")->notice("Barrr", [])', $rewritten->getText()); + } + + public function testRewriteVariablesTernarySeverity() { + $function_call = Parser::parseExpression('watchdog("foo", "Yarrr", array(0), $bipolar ? WATCHDOG_NOTICE : WATCHDOG_CRITICAL)'); + $rewritten = $this->plugin->rewrite($function_call, $this->target); + $this->assertInstanceOf('\Pharborist\Objects\ObjectMethodCallNode', $rewritten); + $this->assertEquals('\Drupal::logger("foo")->notice("Yarrr", array(0))', $rewritten->getText()); + } + + public function testRewriteNoVariablesUnknownSeverity() { + $function_call = Parser::parseExpression('watchdog("foo", "Ba-zing!", NULL, WATCHDOG_FOO)'); + $rewritten = $this->plugin->rewrite($function_call, $this->target); + $this->assertInstanceOf('\Pharborist\Objects\ObjectMethodCallNode', $rewritten); + $this->assertEquals('\Drupal::logger("foo")->notice("Ba-zing!", [])', $rewritten->getText()); + } + +}