Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply fixes from StyleCI #226

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 111 additions & 10 deletions tests/OpeningHoursTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use DateTimeZone;
use PHPUnit\Framework\TestCase;
use Spatie\OpeningHours\Exceptions\MaximumLimitExceeded;
use Spatie\OpeningHours\Exceptions\SearchLimitReached;
use Spatie\OpeningHours\OpeningHours;
use Spatie\OpeningHours\OpeningHoursForDay;
use Spatie\OpeningHours\Time;
Expand Down Expand Up @@ -1079,7 +1080,7 @@ public function it_can_set_the_timezone_on_construct_with_string()
}

/** @test */
public function it_throw_an_exception_on_invalid_timezone()
public function it_throws_an_exception_on_invalid_timezone()
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid Timezone');
Expand All @@ -1088,7 +1089,7 @@ public function it_throw_an_exception_on_invalid_timezone()
}

/** @test */
public function it_throw_an_exception_on_limit_exceeded_void_array_next_open()
public function it_throws_an_exception_on_limit_exceeded_void_array_next_open()
{
$this->expectException(MaximumLimitExceeded::class);
$this->expectExceptionMessage('No open date/time found in the next 8 days, use $openingHours->setDayLimit() to increase the limit.');
Expand All @@ -1097,7 +1098,7 @@ public function it_throw_an_exception_on_limit_exceeded_void_array_next_open()
}

/** @test */
public function it_throw_an_exception_on_limit_exceeded_void_array_previous_open()
public function it_throws_an_exception_on_limit_exceeded_void_array_previous_open()
{
$this->expectException(MaximumLimitExceeded::class);
$this->expectExceptionMessage('No open date/time found in the previous 8 days, use $openingHours->setDayLimit() to increase the limit.');
Expand All @@ -1106,7 +1107,7 @@ public function it_throw_an_exception_on_limit_exceeded_void_array_previous_open
}

/** @test */
public function it_throw_an_exception_on_limit_exceeded_full_array_next_open()
public function it_throws_an_exception_on_limit_exceeded_full_array_next_open()
{
$this->expectException(MaximumLimitExceeded::class);
$this->expectExceptionMessage('No open date/time found in the next 8 days, use $openingHours->setDayLimit() to increase the limit.');
Expand All @@ -1123,7 +1124,7 @@ public function it_throw_an_exception_on_limit_exceeded_full_array_next_open()
}

/** @test */
public function it_throw_an_exception_on_limit_exceeded_full_array_previous_open()
public function it_throws_an_exception_on_limit_exceeded_full_array_previous_open()
{
$this->expectException(MaximumLimitExceeded::class);
$this->expectExceptionMessage('No open date/time found in the previous 8 days, use $openingHours->setDayLimit() to increase the limit.');
Expand All @@ -1140,7 +1141,7 @@ public function it_throw_an_exception_on_limit_exceeded_full_array_previous_open
}

/** @test */
public function it_throw_an_exception_on_limit_exceeded_full_array_next_open_with_exceptions()
public function it_throws_an_exception_on_limit_exceeded_full_array_next_open_with_exceptions()
{
$this->expectException(MaximumLimitExceeded::class);
$this->expectExceptionMessage('No open date/time found in the next 366 days, use $openingHours->setDayLimit() to increase the limit.');
Expand All @@ -1160,7 +1161,107 @@ public function it_throw_an_exception_on_limit_exceeded_full_array_next_open_wit
}

/** @test */
public function it_throw_an_exception_on_limit_exceeded_void_array_next_close()
public function it_throws_an_exception_on_search_limit_exceeded_with_next_open()
{
$this->expectException(SearchLimitReached::class);
$this->expectExceptionMessage('Search reached the limit: 2019-06-13 19:02:00.000000 UTC');

OpeningHours::create([])->nextOpen(
new DateTime('2019-06-06 19:02:00'),
new DateTime('2019-06-13 19:02:00'),
);
}

/** @test */
public function it_throws_an_exception_on_search_limit_exceeded_with_next_close()
{
$this->expectException(SearchLimitReached::class);
$this->expectExceptionMessage('Search reached the limit: 2019-06-13 19:02:00.000000 UTC');

OpeningHours::create([])->nextClose(
new DateTime('2019-06-06 19:02:00'),
new DateTime('2019-06-13 19:02:00'),
);
}

/** @test */
public function it_throws_an_exception_on_search_limit_exceeded_with_previous_open()
{
$this->expectException(SearchLimitReached::class);
$this->expectExceptionMessage('Search reached the limit: 2019-06-03 19:02:00.000000 UTC');

OpeningHours::create([])->previousOpen(
new DateTime('2019-06-06 19:02:00'),
new DateTime('2019-06-03 19:02:00'),
);
}

/** @test */
public function it_throws_an_exception_on_search_limit_exceeded_with_previous_close()
{
$this->expectException(SearchLimitReached::class);
$this->expectExceptionMessage('Search reached the limit: 2019-06-03 19:02:00.000000 UTC');

OpeningHours::create([])->previousClose(
new DateTime('2019-06-06 19:02:00'),
new DateTime('2019-06-03 19:02:00'),
);
}

/** @test */
public function it_stops_at_cap_limit_with_next_open()
{
$this->assertSame(
'2019-06-13 19:02:00',
OpeningHours::create([])->nextOpen(
new DateTime('2019-06-06 19:02:00'),
null,
new DateTime('2019-06-13 19:02:00'),
)->format('Y-m-d H:i:s'),
);
}

/** @test */
public function it_stops_at_cap_limit_exceeded_with_next_close()
{
$this->assertSame(
'2019-06-13 19:02:00',
OpeningHours::create([])->nextClose(
new DateTime('2019-06-06 19:02:00'),
null,
new DateTime('2019-06-13 19:02:00'),
)->format('Y-m-d H:i:s'),
);
}

/** @test */
public function it_stops_at_cap_limit_with_previous_open()
{
$this->assertSame(
'2019-06-03 19:02:00',
OpeningHours::create([])->previousOpen(
new DateTime('2019-06-06 19:02:00'),
null,
new DateTime('2019-06-03 19:02:00'),
)->format('Y-m-d H:i:s'),
);
}

/** @test */
public function it_stops_at_cap_limit_exceeded_with_previous_close()
{
$this->assertSame(
'2019-06-03 19:02:00',
OpeningHours::create([])->previousClose(
new DateTime('2019-06-06 19:02:00'),
null,
new DateTime('2019-06-03 19:02:00'),
)->format('Y-m-d H:i:s'),
);
}

/** @test */
public function it_throws_an_exception_on_limit_exceeded_void_array_next_close()
{
$this->expectException(MaximumLimitExceeded::class);
$this->expectExceptionMessage('No close date/time found in the next 8 days, use $openingHours->setDayLimit() to increase the limit.');
Expand All @@ -1169,7 +1270,7 @@ public function it_throw_an_exception_on_limit_exceeded_void_array_next_close()
}

/** @test */
public function it_throw_an_exception_on_limit_exceeded_void_array_previous_close()
public function it_throws_an_exception_on_limit_exceeded_void_array_previous_close()
{
$this->expectException(MaximumLimitExceeded::class);
$this->expectExceptionMessage('No close date/time found in the previous 8 days, use $openingHours->setDayLimit() to increase the limit.');
Expand All @@ -1178,7 +1279,7 @@ public function it_throw_an_exception_on_limit_exceeded_void_array_previous_clos
}

/** @test */
public function it_throw_an_exception_on_limit_exceeded_full_array_next_close()
public function it_throws_an_exception_on_limit_exceeded_full_array_next_close()
{
$this->expectException(MaximumLimitExceeded::class);
$this->expectExceptionMessage('No close date/time found in the next 8 days, use $openingHours->setDayLimit() to increase the limit.');
Expand All @@ -1195,7 +1296,7 @@ public function it_throw_an_exception_on_limit_exceeded_full_array_next_close()
}

/** @test */
public function it_throw_an_exception_on_limit_exceeded_full_array_previous_close()
public function it_throws_an_exception_on_limit_exceeded_full_array_previous_close()
{
$this->expectException(MaximumLimitExceeded::class);
$this->expectExceptionMessage('No close date/time found in the previous 8 days, use $openingHours->setDayLimit() to increase the limit.');
Expand Down
Loading