<?phpdefine ('ID_TM', 798);class MyUnitTestCase extends UnitTestCase { /** Validates the viability of a Template_Screenshot */ function assertValidScreenshot($sshot, $message = '') { $this->assertValidScreenshotProperties($sshot, $message); } /** Check if a Template_Screenshot is not viable */ function assertInvalidScreenshot($sshot, $message = '') { $this->assertInvalidScreenshotProperties($sshot, $message); } /** Validates the properties of a Template_Screenshot */ function assertValidScreenshotProperties ($sshot, $message = '') { foreach (Template_Factory::$screenshot_fields as $k => $pcre) { $this->assertPattern($pcre, $sshot->$k, $message); } } /** Verifies if the properties of a Template_Screenshot are not viable */ function assertInvalidScreenshotProperties ($sshot, $message = '') { $b = true; foreach (Template_Factory::$screenshot_fields as $k => $pcre) { $match = $sshot->$k; if (!preg_match($pcre, (string)$match)) { $b = false; } } $this->assertFalse($b, $message); } /** Validates a Template_Page */ function assertValidPage ($page) { $this->assertValidPageProperties ($page); } /** Verifies that a Template_Page is not viable */ function assertInvalidPage ($page) { $this->assertInvalidPageProperties ($page); } /** Validates the properties of a Template_Page */ function assertValidPageProperties ($page) { $this->assertTrue(is_int($page->id)); $this->assertTrue(is_int($page->id_tm)); $this->assertTrue(is_string($page->label) && strlen($page->label)>3); } /** Verifies if the properties of a Template_Screenshot are not viable */ function assertInvalidPageProperties ($sshot) { $this->assertFalse(is_int($page->id)); $this->assertFalse(is_int($page->id_tm)); $this->assertFalse(is_string($page->label) && strlen($page->label)>3); } /** Validates the properties of a CuteDB_Query */ function assertValidQueryProperties ($q) { $this->assertTrue( ( is_string($q->sql_template) && $q->sql_template ) || ( is_string($q->sql) && $q->sql ), 'Query->sql_template not string'); $this->assertTrue(is_array($q->abilities), 'Query->abilities not array'); $this->assertTrue(is_string($q->name), 'Query->name not string'); } public function query($sql) { $odb = CuteDB::getInstance(); $find = array('($prefix)', '($id_tm)'); $replace = array($odb->prefix, ID_TM); $sql = str_ireplace($find, $replace, $sql); $return = $odb->query($sql) or die(print_r($odb->error())); return $return; }}?>