Skip to content

Commit

Permalink
Add getter "getDbName" on the Database class
Browse files Browse the repository at this point in the history
  • Loading branch information
williamdes committed May 10, 2022
1 parent bf16b71 commit 1a30cdc
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* You can obtain one at https://mozilla.org/MPL/2.0/.
* @license MPL-2.0 https://mozilla.org/MPL/2.0/
* @source https://github.com/wdes/simple-php-model-system
* @version 1.2.0
* @version 1.2.1
*/

/**
Expand Down Expand Up @@ -154,6 +154,14 @@ public function getConnection(): PDO
return $this->connection;
}

/**
* @since 1.2.1
*/
public function getDbName(): string
{
return $this->dbConfig['name'];
}

/**
* Access the database instance
*
Expand Down
18 changes: 18 additions & 0 deletions tests/DatabaseTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types = 1);

namespace SimplePhpModelSystem\Test\Models;

use SimplePhpModelSystem\Database;
use SimplePhpModelSystem\Tests\DatabaseAbstractTestCase;

class DatabaseTest extends DatabaseAbstractTestCase
{

public function testGetDbName(): void
{
$this->assertNotEmpty(Database::getInstance()->getDbName());
}

}

0 comments on commit 1a30cdc

Please sign in to comment.