-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPeriodHalfMonthTest.php
58 lines (47 loc) · 1.53 KB
/
PeriodHalfMonthTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
namespace utest;
use d3acc\components\PeriodHalfMonth;
use d3acc\models\AcPeriod;
class PeriodHalfMonthTest extends \PHPUnit_Framework_TestCase
{
const PERIOD_TYPE = 8;
public function setUp(): void
{
$this->deletePeriodType(self::PERIOD_TYPE);
}
public function tearDown(): void
{
$this->deletePeriodType(self::PERIOD_TYPE);
}
public function deletePeriodType($type)
{
foreach (AcPeriod::find()
->where([
'period_type' => $type,
'sys_company_id' => 1
])
->orderBy(['id'=> SORT_DESC])
->all()
as $period
) {
$period->delete();
}
}
public function testInit()
{
//INIT
$period = PeriodHalfMonth::init('2015-01-05', self::PERIOD_TYPE,1);
$this->assertInstanceOf('\d3acc\models\AcPeriod', $period);
//VALIDATE ACTIVE PERIOD
$activePeriod = AcPeriod::getActivePeriod(1,self::PERIOD_TYPE);
$this->assertEquals($activePeriod->id, $period->id);
//ADD NEXT
$period = PeriodHalfMonth::close(self::PERIOD_TYPE,1);
$this->assertInstanceOf('\d3acc\models\AcPeriod', $period);
//VALIDATE ACTIVE PERIOD
$activePeriod = AcPeriod::getActivePeriod(1,self::PERIOD_TYPE);
$this->assertEquals($activePeriod->id, $period->id);
$dates = $activePeriod->getDates();
$this->assertEquals(count($dates), 16);
}
}