Increase Mutation Score Indicator (MSI) by removing "src/Type/DatePeriod.php:131 [M] LogicalOr" mutant

This commit is contained in:
Meritoo
2019-08-11 13:25:28 +02:00
parent ec1e95a086
commit bc20645cba
2 changed files with 43 additions and 1 deletions

View File

@@ -114,7 +114,8 @@ class DatePeriod extends BaseType
* Returns formatted one of the period's date: start date or end 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
*/
public function getFormattedDate(string $format, bool $startDate = true): string

View File

@@ -77,6 +77,18 @@ class DatePeriodTest extends BaseTypeTestCase
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 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
*