a tiny mvc framework for php using php-activerecord
1<?php
2include 'helpers/config.php';
3
4use ActiveRecord\Config;
5use ActiveRecord\ConnectionManager;
6
7class ConnectionManagerTest extends DatabaseTest
8{
9 public function test_get_connection_with_null_connection()
10 {
11 $this->assert_not_null(ConnectionManager::get_connection(null));
12 $this->assert_not_null(ConnectionManager::get_connection());
13 }
14
15 public function test_get_connection()
16 {
17 $this->assert_not_null(ConnectionManager::get_connection('mysql'));
18 }
19
20 public function test_get_connection_uses_existing_object()
21 {
22 $a = ConnectionManager::get_connection('mysql');
23 $a->harro = 'harro there';
24
25 $this->assert_same($a,ConnectionManager::get_connection('mysql'));
26 }
27
28 public function test_gh_91_get_connection_with_null_connection_is_always_default()
29 {
30 $conn_one = ConnectionManager::get_connection('mysql');
31 $conn_two = ConnectionManager::get_connection();
32 $conn_three = ConnectionManager::get_connection('mysql');
33 $conn_four = ConnectionManager::get_connection();
34
35 $this->assert_same($conn_one, $conn_three);
36 $this->assert_same($conn_two, $conn_three);
37 $this->assert_same($conn_four, $conn_three);
38 }
39}
40?>