mirror of
https://github.com/wiosna-dev/common-library.git
synced 2026-03-12 09:31:51 +01:00
Increase Mutation Score Indicator (MSI) by removing "src/Type/DatePeriod.php:131 [M] LogicalOr" mutant
This commit is contained in:
@@ -114,7 +114,8 @@ class DatePeriod extends BaseType
|
|||||||
* Returns formatted one of the period's date: start date or end date
|
* Returns formatted one of the period's date: start date or end date
|
||||||
*
|
*
|
||||||
* @param string $format Format used to format the date
|
* @param string $format Format used to format the date
|
||||||
* @param bool $startDate (optional) If is set to true, start date will be formatted. Otherwise - end date.
|
* @param bool $startDate (optional) If is set to true, start date will be formatted (default behaviour).
|
||||||
|
* Otherwise - end date.
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getFormattedDate(string $format, bool $startDate = true): string
|
public function getFormattedDate(string $format, bool $startDate = true): string
|
||||||
|
|||||||
@@ -77,6 +77,18 @@ class DatePeriodTest extends BaseTypeTestCase
|
|||||||
self::assertEquals('', $period->getFormattedDate($format));
|
self::assertEquals('', $period->getFormattedDate($format));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param DatePeriod $period The date period to verify
|
||||||
|
* @param string $format Format used to format the date
|
||||||
|
* @param bool $startDate If is set to true, start date is formatted. Otherwise - end date.
|
||||||
|
*
|
||||||
|
* @dataProvider provideDatePeriodAndUnknownDate
|
||||||
|
*/
|
||||||
|
public function testGetFormattedDateUsingUnknownDate(DatePeriod $period, $format, $startDate): void
|
||||||
|
{
|
||||||
|
self::assertEquals('', $period->getFormattedDate($format, $startDate));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param DatePeriod $period The date period to verify
|
* @param DatePeriod $period The date period to verify
|
||||||
* @param string $format Format used to format the date
|
* @param string $format Format used to format the date
|
||||||
@@ -156,6 +168,35 @@ class DatePeriodTest extends BaseTypeTestCase
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function provideDatePeriodAndUnknownDate(): ?Generator
|
||||||
|
{
|
||||||
|
$date = new DateTime('2001-01-01');
|
||||||
|
|
||||||
|
yield[
|
||||||
|
new DatePeriod(),
|
||||||
|
'Y-m-d',
|
||||||
|
false,
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
new DatePeriod(),
|
||||||
|
'Y-m-d',
|
||||||
|
true,
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
new DatePeriod($date),
|
||||||
|
'Y-m-d',
|
||||||
|
false,
|
||||||
|
];
|
||||||
|
|
||||||
|
yield[
|
||||||
|
new DatePeriod(null, $date),
|
||||||
|
'Y-m-d',
|
||||||
|
true,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides period and format of date to verify using the start date
|
* Provides period and format of date to verify using the start date
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user