1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
<?php include 'helpers/config.php'; require_once __DIR__ . '/../lib/adapters/SqliteAdapter.php';
class SqliteAdapterTest extends AdapterTest { public function set_up($connection_name=null) { parent::set_up('sqlite'); }
public function tearDown() { parent::tearDown();
@unlink($this->db); @unlink(self::InvalidDb); }
public function testConnectToInvalidDatabaseShouldNotCreateDbFile() { try { ActiveRecord\Connection::instance("sqlite://" . self::InvalidDb); $this->assertFalse(true); } catch (ActiveRecord\DatabaseException $e) { $this->assertFalse(file_exists(__DIR__ . "/" . self::InvalidDb)); } }
public function test_limit_with_null_offset_does_not_contain_offset() { $ret = array(); $sql = 'SELECT * FROM authors ORDER BY name ASC'; $this->conn->query_and_fetch($this->conn->limit($sql,null,1),function($row) use (&$ret) { $ret[] = $row; });
$this->assert_true(strpos($this->conn->last_query, 'LIMIT 1') !== false); }
public function test_gh183_sqliteadapter_autoincrement() { // defined in lowercase: id integer not null primary key $columns = $this->conn->columns('awesome_people'); $this->assert_true($columns['id']->auto_increment);
// defined in uppercase: `amenity_id` INTEGER NOT NULL PRIMARY KEY $columns = $this->conn->columns('amenities'); $this->assert_true($columns['amenity_id']->auto_increment);
// defined using int: `rm-id` INT NOT NULL $columns = $this->conn->columns('`rm-bldg`'); $this->assert_false($columns['rm-id']->auto_increment);
// defined using int: id INT NOT NULL PRIMARY KEY $columns = $this->conn->columns('hosts'); $this->assert_true($columns['id']->auto_increment); }
// not supported public function test_connect_with_port() {} } ?>
|