Days::in should use in_mask; tests coverage #1180 (#1193)

This commit is contained in:
Nabeel S
2021-05-19 11:20:50 -04:00
committed by GitHub
parent dff4273c72
commit 352f1ee9f8
2 changed files with 10 additions and 1 deletions

View File

@@ -77,7 +77,7 @@ class Days extends Enum
*/
public static function in($mask, $day): bool
{
return ($mask & $day) === $day;
return in_mask($mask, $day);
}
/**

View File

@@ -279,6 +279,7 @@ class FlightTest extends TestCase
*/
public function testDayOfWeekActive(): void
{
/** @var User user */
$this->user = factory(User::class)->create();
// Set it to Monday or Tuesday, depending on what today is
@@ -289,6 +290,8 @@ class FlightTest extends TestCase
}
factory(Flight::class, 5)->create();
/** @var Flight $flight */
$flight = factory(Flight::class)->create([
'days' => $days,
]);
@@ -323,6 +326,12 @@ class FlightTest extends TestCase
$this->assertTrue(Days::in($mask, Days::$isoDayMap[5]));
$this->assertTrue(Days::in($mask, Days::$isoDayMap[6]));
$this->assertTrue(Days::in($mask, Days::$isoDayMap[7]));
$mask = [];
$this->assertFalse(Days::in($mask, Days::$isoDayMap[1]));
$mask = 0;
$this->assertFalse(Days::in($mask, Days::$isoDayMap[1]));
}
public function testStartEndDate(): void