Skip to content

Commit

Permalink
Add more errors in tests config databases
Browse files Browse the repository at this point in the history
  • Loading branch information
joanhey committed Apr 3, 2020
1 parent 67d928b commit 5c38c32
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
6 changes: 3 additions & 3 deletions tests/ActiveRecord/DbTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
15 changes: 14 additions & 1 deletion tests/config/databases.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'
]


Expand Down

0 comments on commit 5c38c32

Please sign in to comment.