ConnectionManagerTest.php 1.2 KB

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