All pastes #569244 Raw Edit

Something

public php v1 · immutable
·published 2007-06-16 02:14 UTC
rendered paste body
<?phpdefine ('ID_TM', 798);class MyUnitTestCase extends UnitTestCase {  public $basic_screenshot = array('id'          => 1953,'id_screenshot_description' => 11,'id_tm'       => 798,'id_page'     => 5,'scr_type_id' => 62,'width'       => 800,'height'      => 600,'uri'         => '700/798-b.jpg','href'        => '/screenshots/700/798.html','label'       => 'Mainpage (screenshot description)',);    public $possible_db_pages = array(    array('id_page'          => 1953,'id_tm'            => 798,'page_description' => 'Mainpage (page description)',    ),    array('id'               => 1953,'id_tm'            => 798,'page_description' => 'Header (page description)',    ),    array('id_page'          => 1953,'id_tm'            => 798,'label'            => 'Footer (page description)',    ),    array('id_page'          => 1953,'id_tm'            => 798,'label_en'         => 'Dealer (page description)',    ),  );    /** 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;  }  }?>