Skip to content

Commit

Permalink
Days::in should use in_mask; tests coverage #1180
Browse files Browse the repository at this point in the history
  • Loading branch information
nabeelio committed May 19, 2021
1 parent dff4273 commit 20b7965
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/Models/Enums/Days.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public static function getDaysMask(array $days)
*/
public static function in($mask, $day): bool
{
return ($mask & $day) === $day;
return in_mask($mask, $day);
}

/**
Expand Down
9 changes: 9 additions & 0 deletions tests/FlightTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ public function testFindDaysOfWeek(): void
*/
public function testDayOfWeekActive(): void
{
/** @var User user */
$this->user = factory(User::class)->create();

// Set it to Monday or Tuesday, depending on what today is
Expand All @@ -289,6 +290,8 @@ public function testDayOfWeekActive(): void
}

factory(Flight::class, 5)->create();

/** @var Flight $flight */
$flight = factory(Flight::class)->create([
'days' => $days,
]);
Expand Down Expand Up @@ -323,6 +326,12 @@ public function testDayOfWeekTests(): void
$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
Expand Down

0 comments on commit 20b7965

Please sign in to comment.