00001 <?php
00002 require_once APP_SIMPLETEST_DIR . 'autorun.php';
00003
00004
00005
00006
00007
00008
00009
00010 class GyroUnitTestCase extends UnitTestCase {
00011 protected $is_console = false;
00012
00013 public function __construct() {
00014 $this->is_console = class_exists('Console') && Console::is_console_request();
00015 }
00016
00017
00018
00019
00020 protected function assertStatus($status, $message = '%s') {
00021 $this->assertIsA($status, 'Status', sprintf($message, 'Status type check'));
00022 }
00023
00024
00025
00026
00027 protected function assertStatusSuccess($status, $message = '%s') {
00028 $this->assertStatus($status, $message);
00029 if ($status instanceof Status) {
00030 $this->assertTrue($status->is_ok(), sprintf($message, 'Status success check'));
00031 }
00032 }
00033
00034
00035
00036
00037 protected function assertStatusError($status, $message = '%s') {
00038 $this->assertStatus($status, $message);
00039 if ($status instanceof Status) {
00040 $this->assertTrue($status->is_error(), sprintf($message, 'Status error check'));
00041 if ($status->is_error()) {
00042 $this->assertTrue(String::length($status->to_string()) > 0, sprintf($message, 'Status has error message'));
00043 }
00044 }
00045 }
00046
00047
00048
00049
00050 protected function assertEqualsPath($arg1, $arg2, $message = '%s') {
00051 if ($this->is_console) {
00052 $arg1_path = Url::create($arg1);
00053 $arg1 = $arg1_path->is_valid() ? '/' . $arg1_path->get_path() : $arg1;
00054 $arg2_path = Url::create($arg2);
00055 $arg2 = $arg2_path->is_valid() ? '/' . $arg2_path->get_path() : $arg2;
00056 }
00057 $this->assertEqual($arg1, $arg2, $message);
00058 }
00059
00060 }