View source
<?php
use RocketChat\RocketChat;
class RocketChatTestUnitTest extends DrupalUnitTestCase {
public static function getInfo() {
return array(
'name' => 'Rocket.Chat unit tests',
'description' => 'Check if several different paths are process as ' . 'expected by the checkIfTargetIsRocketChatPath() ' . 'function.',
'group' => 'Rocket Chat',
);
}
public function setUp() {
drupal_load('module', 'rocket_chat');
module_load_include('class.inc', 'rocket_chat', 'RocketChat');
parent::setUp();
}
private function pathTest(&$paths, &$path) {
return RocketChat::checkIfTargetIsRocketChatPath($paths, $path);
}
private function pathTrueTest(&$paths, $path) {
return $this
->assertTrue($this
->pathTest($paths, $path), "Display Widget on [" . $path . "] ==> Yes", 'RocketChat');
}
private function pathFalseTest(&$paths, $path) {
return $this
->assertFalse($this
->pathTest($paths, $path), "Display Widget on [" . $path . "] ==> No", 'RocketChat');
}
public function testRocketChatUnitTestExampleFunction() {
$paths = [
"<front>",
"node/*",
"admin/chat/*/secret",
"",
];
$state = array();
$state[] = $this
->pathFalseTest($paths, "<front>");
$state[] = $this
->pathTrueTest($paths, "");
$state[] = $this
->pathFalseTest($paths, "<back>");
$state[] = $this
->pathTrueTest($paths, "node");
$state[] = $this
->pathTrueTest($paths, "node/");
$state[] = $this
->pathTrueTest($paths, "node/1");
$state[] = $this
->pathTrueTest($paths, "node/9");
$state[] = $this
->pathTrueTest($paths, "node/42/edit");
$state[] = $this
->pathTrueTest($paths, "admin/chat/superduper/secret");
$state[] = $this
->pathFalseTest($paths, "admin/chat/realyImportant/falseSecret");
$state[] = $this
->pathTrueTest($paths, "admin/chat/realyImportant/f/secret");
$state[] = $this
->pathTrueTest($paths, "admin/chat/realyImportant/f/r/secret");
}
}