Esempio n. 1
0
 public function testTransactionWrapperFail()
 {
     $this->db->query("INSERT INTO test (id, code, price) VALUES (3004, '1', 1)");
     $res = $this->db->transaction(function () {
         $this->db->query("INSERT INTO test (id, code, price) VALUES (3004, '1', 1)");
     });
     $this->assertEquals(false, $res);
 }
Esempio n. 2
0
 public function testExceptionData()
 {
     $query = '';
     try {
         $this->db->query("SELECTT 1");
     } catch (Exception $e) {
         $code = $e->getCode();
         $message = $e->getMessage();
         $query = $e->getQuery();
     }
     $this->assertEquals(1064, $code);
     $this->assertEquals('Error 1064: "You have an error in your SQL syntax; check the manual that corresponds ' . 'to your MySQL server version for the right syntax to use near ' . '\'SELECTT 1\' at line 1"; Query = "SELECTT 1"', $message);
     $this->assertEquals('SELECTT 1', $query);
 }
Esempio n. 3
0
 public function testFetchRow()
 {
     $res = $this->db->query('SELECT code, name FROM test WHERE id = 1')->fetchRow();
     $expect = ['001', 'Cup'];
     $this->assertEquals($expect, $res);
 }
Esempio n. 4
0
 public function tearDown()
 {
     $this->db->query('DROP TABLE IF EXISTS `test`');
     $this->db->query('DROP TABLE IF EXISTS `test_no_ai`');
     $this->db->query('DROP TABLE IF EXISTS `test``_ident`');
 }