コード例 #1
0
ファイル: MySQLiteTest.php プロジェクト: FameBit/MySQLite
 /**
  * Test from unix time
  */
 public function testFromUnixTime()
 {
     $this->assertEquals('2016-02-05T19:33:57+0000', MySQLite::mysql_from_unixtime(1454700837));
     $this->assertEquals('2008-10-22T18:40:37+0000', MySQLite::mysql_from_unixtime(1224700837));
 }
コード例 #2
0
ファイル: MySQLiteTest.php プロジェクト: JMagashazi/MySQLite
 /**
  * Test the rand function
  */
 public function testRand()
 {
     $pdo = new PDO("sqlite::memory:", null, null, [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);
     MySQLite::createFunctions($pdo);
     $pdo->exec("CREATE TABLE testing(id INT PRIMARY KEY NOT NULL)");
     $stmt = $pdo->prepare("INSERT INTO testing (id) VALUES (?)");
     for ($x = 0; $x <= 10; $x++) {
         $stmt->execute([$x]);
     }
     $results = [];
     for ($x = 0; $x < 20; $x++) {
         $results[] = $pdo->query('SELECT id FROM testing ORDER BY RAND() LIMIT 1')->fetch(PDO::FETCH_COLUMN);
     }
     $this->assertNotEquals(array_slice($results, 0, 10), array_slice($results, 10, 10));
 }