a tiny mvc framework for php using php-activerecord
1<?php
2use ActiveRecord\Column;
3
4include 'helpers/config.php';
5require_once __DIR__ . '/../lib/adapters/PgsqlAdapter.php';
6
7class PgsqlAdapterTest extends AdapterTest
8{
9 public function set_up($connection_name=null)
10 {
11 parent::set_up('pgsql');
12 }
13
14 public function test_insert_id()
15 {
16 $this->conn->query("INSERT INTO authors(author_id,name) VALUES(nextval('authors_author_id_seq'),'name')");
17 $this->assert_true($this->conn->insert_id('authors_author_id_seq') > 0);
18 }
19
20 public function test_insert_id_with_params()
21 {
22 $x = array('name');
23 $this->conn->query("INSERT INTO authors(author_id,name) VALUES(nextval('authors_author_id_seq'),?)",$x);
24 $this->assert_true($this->conn->insert_id('authors_author_id_seq') > 0);
25 }
26
27 public function test_insert_id_should_return_explicitly_inserted_id()
28 {
29 $this->conn->query('INSERT INTO authors(author_id,name) VALUES(99,\'name\')');
30 $this->assert_true($this->conn->insert_id('authors_author_id_seq') > 0);
31 }
32
33 public function test_set_charset()
34 {
35 $connection_string = ActiveRecord\Config::instance()->get_connection($this->connection_name);
36 $conn = ActiveRecord\Connection::instance($connection_string . '?charset=utf8');
37 $this->assert_equals("SET NAMES 'utf8'",$conn->last_query);
38 }
39}
40?>