public function testGetQuote()
 {
     $stub = $this->getMock('App\\Service\\Randomizer');
     $stub->expects($this->any())->method('getNumber')->will($this->returnValue('0'));
     $service = new RandomQuote($stub);
     $quote = $service->getQuote();
     $this->assertRegExp('/There are only two ways to live your life./', $quote[0]);
 }
Exemple #2
0
    public function write_to_caching_db($db_handler, $table, $marker, $p)
    {
        if ($this->db_table_exists($db_handler, $table)) {
            $db_handler->exec("DELETE FROM " . $table . " WHERE 1;");
            $SQL = "INSERT INTO `" . $table . "` ";
            $SQL .= "VALUES(:adddate, :content);";
            $STH = $db_handler->prepare($SQL);
            $STH->bindValue(":adddate", $marker);
            /* $STH->bindValue(":content", str_replace(array("—", "–", "'"), array("—", "-", "'"), $this->conv_symbs_to_ents($p))); */
            $STH->bindValue(":content", $p);
            $STH->execute();
        }
    }
}
if (!isset($RandomQuote) || empty($RandomQuote)) {
    $RandomQuote = new RandomQuote();
}
$table_name = $dict_enen_quotations_table_name;
$cache_json_table_name = "cache_" . $dict_enen_quotations_table_name . "_json";
$cache_js_table_name = "cache_" . $dict_enen_quotations_table_name . "_js";
$SQLITE_CACHE->exec("CREATE TABLE IF NOT EXISTS `" . $cache_json_table_name . "` ( `adddate` INTEGER NOT NULL, `content` TEXT )");
$SQLITE_CACHE->exec("CREATE TABLE IF NOT EXISTS `" . $cache_js_table_name . "` ( `adddate` INTEGER NOT NULL, `content` TEXT )");
$type = $RandomQuote->get_post('type');
$code = $RandomQuote->get_post('code');
if ($code == "JSON") {
    header('Cache-Control: no-cache, must-revalidate');
    header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
    header('Content-type: application/json');
} else {
    header('Cache-Control: no-cache, must-revalidate');
    header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');