|
19 | 19 |
|
20 | 20 | namespace OrangeHRM\Tests\Dashboard\Service;
|
21 | 21 |
|
| 22 | +use OrangeHRM\Admin\Service\CompanyStructureService; |
| 23 | +use OrangeHRM\Config\Config; |
22 | 24 | use OrangeHRM\Dashboard\Dao\ChartDao;
|
23 | 25 | use OrangeHRM\Dashboard\Service\ChartService;
|
24 |
| -use OrangeHRM\Tests\Util\TestCase; |
| 26 | +use OrangeHRM\Framework\Services; |
| 27 | +use OrangeHRM\Tests\Util\KernelTestCase; |
| 28 | +use OrangeHRM\Tests\Util\TestDataService; |
25 | 29 |
|
26 | 30 | /**
|
27 | 31 | * @group Dashboard
|
28 | 32 | * @group Service
|
29 | 33 | */
|
30 |
| -class ChartServiceTest extends TestCase |
| 34 | +class ChartServiceTest extends KernelTestCase |
31 | 35 | {
|
| 36 | + protected string $fixture; |
32 | 37 | private ChartService $chartService;
|
33 | 38 |
|
| 39 | + /** |
| 40 | + * Set up method |
| 41 | + */ |
34 | 42 | protected function setUp(): void
|
35 | 43 | {
|
36 | 44 | $this->chartService = new ChartService();
|
| 45 | + $this->fixture = Config::get( |
| 46 | + Config::PLUGINS_DIR |
| 47 | + ) . '/orangehrmDashboardPlugin/test/fixtures/ChartDao.yml'; |
| 48 | + TestDataService::populate($this->fixture); |
| 49 | + $this->createKernelWithMockServices([ |
| 50 | + Services::COMPANY_STRUCTURE_SERVICE => new CompanyStructureService(), |
| 51 | + ]); |
37 | 52 | }
|
38 | 53 |
|
39 | 54 | public function testGetChartDao(): void
|
40 | 55 | {
|
41 | 56 | $this->assertTrue($this->chartService->getChartDao() instanceof ChartDao);
|
42 | 57 | }
|
| 58 | + |
| 59 | + public function testGetEmployeeDistributionBySubunit(): void |
| 60 | + { |
| 61 | + $distributionBySubunit = $this->chartService->getEmployeeDistributionBySubunit(); |
| 62 | + $subunitCountPairs = $distributionBySubunit->getSubunitCountPairs(); |
| 63 | + $this->assertEquals('0', $distributionBySubunit->getOtherEmployeeCount()); |
| 64 | + $this->assertEquals('9', $distributionBySubunit->getTotalSubunitCount()); |
| 65 | + $this->assertEquals('3', $distributionBySubunit->getUnassignedEmployeeCount()); |
| 66 | + $this->assertEquals('8', $distributionBySubunit->getLimit()); |
| 67 | + $this->assertEquals($distributionBySubunit->getTotalSubunitCount(), sizeof($subunitCountPairs)); |
| 68 | + } |
43 | 69 | }
|
0 commit comments