From 5c38c32b430272468cc4b9cc9de9c9a6d9e5a625 Mon Sep 17 00:00:00 2001 From: Joanhey Date: Fri, 3 Apr 2020 15:42:10 +0200 Subject: [PATCH] Add more errors in tests config databases --- tests/ActiveRecord/DbTest.php | 6 +++--- tests/config/databases.php | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/tests/ActiveRecord/DbTest.php b/tests/ActiveRecord/DbTest.php index 44e2297..cfaeee7 100644 --- a/tests/ActiveRecord/DbTest.php +++ b/tests/ActiveRecord/DbTest.php @@ -36,12 +36,12 @@ public function testGetThatDontExistInConfig() $instance = Db::get('no_exist'); } - public function testGetWithBadCredentialsInConfig() + public function testGetConfigWithoutPassword() { $this->expectException(RuntimeException::class); - //$this->expectExceptionMessageRegExp('/No existen datos de conexión para la bd$/'); + $this->expectExceptionMessageRegExp('/No se pudo realizar la conexión con/'); - $instance = Db::get('bad_credentials'); + $instance = Db::get('no_password'); } public function testSetConfig() diff --git a/tests/config/databases.php b/tests/config/databases.php index 6ab82ce..6f1e8d9 100644 --- a/tests/config/databases.php +++ b/tests/config/databases.php @@ -15,16 +15,29 @@ 'pgsql' => [ 'dsn' => 'pgsql:dbname=kumbia_test;host=localhost', 'username' => 'postgres', - 'password' => '', + 'password' => '414141', 'params' => [ \PDO::ATTR_PERSISTENT => \true, //conexión persistente \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION ] ], + //Sqlite 'sqlite' => [ 'dsn' => 'sqlite::memory:', 'username' => '', 'password' => '', + ], + + // bad connections to tests errors + 'no_dsn' => [ + 'dsn' => '' + ], + 'no_password' => [ + 'dsn' => 'pgsql:dbname=no_exist;host=localhost' + ], + 'bad_credentials' => [ + 'dsn' => 'pgsql:dbname=no_exist;host=localhost', + 'password' => 'as' ]