Skip to content

Commit

Permalink
#11 chor: add test for database and employee class
Browse files Browse the repository at this point in the history
  • Loading branch information
stanislaw-ch committed Jan 23, 2023
1 parent 0e3c70f commit 15b5203
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<testsuites>
<testsuite name="DB">
<directory suffix="test.php">tests/DB</directory>
<directory>tests</directory>
</testsuite>
</testsuites>

Expand Down
23 changes: 23 additions & 0 deletions tests/DB/DatabaseTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
use PHPUnit\Framework\TestCase;
require_once "service/DBApi.php";
require_once "classes/Employee.php";

class DatabaseTest extends TestCase
{
private DBConfig $db;

protected function setUp(): void
{
$this->db = new DBConfig;
}

/**
* @throws Exception
*/
public function testGetConnection(): void
{
$result = $this->db::connect();
$this->assertInstanceOf(mysqli::class, $result);
}
}
16 changes: 16 additions & 0 deletions tests/DB/EmployeeTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
use PHPUnit\Framework\TestCase;
require_once "service/DBApi.php";
require_once "classes/Employee.php";

class StackTest extends TestCase
{
public function getEmployees()
{
$api = new DBApi();
$employee = new Employee($api);

$employees = $employee->getAllEmployees();
$this->assertSame(12, count($employees));
}
}

0 comments on commit 15b5203

Please sign in to comment.