mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-11-30 20:27:07 +09:00
* Update rector config to include tests * Run Rector against the tests * Delete test-results * Update .gitignore * Correctly set the PHP min to 8.1, split the configs * Corrected PHPDoc * Deleted tests we can't really get to pass PHPunit is hard-coded to fail when a class has a return type of `never`, which is the correct return type of our redirect function (and rightfully so). No way to disable the exception as far as we can tell
47 lines
1.5 KiB
PHP
47 lines
1.5 KiB
PHP
<?php
|
|
|
|
#[\PHPUnit\Framework\Attributes\Group('Core')]
|
|
class Box_PeriodTest extends PHPUnit\Framework\TestCase
|
|
{
|
|
|
|
public function testException()
|
|
{
|
|
$this->expectException(\FOSSBilling\Exception::class);
|
|
$this->expectExceptionMessage('Invalid period code. Period definition must be 2 chars length');
|
|
$p = new Box_Period('1');
|
|
}
|
|
|
|
public function testException2()
|
|
{
|
|
$this->expectException(\FOSSBilling\Exception::class);
|
|
$this->expectExceptionMessage('Period Error. Unit Z is not defined');
|
|
$p = new Box_Period('1Z');
|
|
}
|
|
|
|
public function testOneMonth()
|
|
{
|
|
$p = new Box_Period('1M');
|
|
|
|
$this->assertEquals('M', $p->getUnit());
|
|
$this->assertEquals(1, $p->getQty());
|
|
$this->assertEquals('1M', $p->getCode());
|
|
$this->assertEquals('Every 1 month', $p->getTitle());
|
|
$this->assertEquals(30, $p->getDays());
|
|
$this->assertEquals(1, $p->getMonths());
|
|
$this->assertEquals(strtotime('+1 month'), $p->getExpirationTime());
|
|
}
|
|
|
|
public function testTwoMonths()
|
|
{
|
|
$p = new Box_Period('2M');
|
|
|
|
$this->assertEquals('M', $p->getUnit());
|
|
$this->assertEquals(2, $p->getQty());
|
|
$this->assertEquals('2M', $p->getCode());
|
|
$this->assertEquals('Every 2 months', $p->getTitle());
|
|
$this->assertEquals(60, $p->getDays());
|
|
$this->assertEquals(2, $p->getMonths());
|
|
$this->assertEquals(strtotime('+2 month'), $p->getExpirationTime());
|
|
}
|
|
}
|