Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,11 @@ include:
-
path: vendor/johnbillion/plugin-infrastructure/tests/docker-compose.yml
project_directory: .

services:
httpbin:
image: mccutchen/go-httpbin:latest
container_name: ${COMPOSE_PROJECT_NAME}-httpbin
restart: always
environment:
PORT: 80
3 changes: 3 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
<exclude name="Universal.Arrays.DisallowShortArraySyntax.Found"/>
<exclude name="WordPress.PHP.YodaConditions.NotYoda"/>
<exclude name="Universal.Operators.DisallowShortTernary.Found"/>

<!-- Exceptions in WP Crontrol are caught appropriately. -->
<exclude name="WordPress.Security.EscapeOutput.ExceptionNotEscaped"/>
</rule>

<!-- Ignore some rules for the tests -->
Expand Down
1 change: 1 addition & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
failOnRisky="true"
>
<testsuites>
<testsuite name="integration">
Expand Down
15 changes: 7 additions & 8 deletions src/Event/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Crontrol\Event\CoreCronEvent;
use Crontrol\Event\ActionSchedulerEvent;
use Crontrol\Event\StandardEvent;
use Crontrol\Exception\UnknownScheduleException;

/**
* Base class for cron events.
Expand Down Expand Up @@ -278,7 +279,7 @@ public function is_persistent_core_hook(): bool {
* Get the schedule name for this event.
*
* @return string The schedule display name.
* @throws \RuntimeException If schedule is unknown.
* @throws UnknownScheduleException If schedule is unknown.
*/
public function get_schedule_name(): string {
if ( ! $this->is_recurring() ) {
Expand All @@ -291,13 +292,11 @@ public function get_schedule_name(): string {
return isset( $schedules[ $this->schedule ]['display'] ) ? $schedules[ $this->schedule ]['display'] : $schedules[ $this->schedule ]['name'];
}

throw new \RuntimeException(
esc_html(
sprintf(
/* translators: %s: Schedule name */
__( 'Unknown (%s)', 'wp-crontrol' ),
$this->schedule
)
throw new UnknownScheduleException(
sprintf(
/* translators: %s: Schedule name */
__( 'Unknown (%s)', 'wp-crontrol' ),
$this->schedule
)
);
}
Expand Down
8 changes: 8 additions & 0 deletions src/Exception/CrontrolRuntimeException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace Crontrol\Exception;

/**
* Exception thrown for WP Crontrol runtime errors.
*/
class CrontrolRuntimeException extends \RuntimeException {}
8 changes: 8 additions & 0 deletions src/Exception/HTTPFailedException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace Crontrol\Exception;

/**
* Exception thrown when an HTTP request fails.
*/
class HTTPFailedException extends CrontrolRuntimeException {}
8 changes: 8 additions & 0 deletions src/Exception/InvalidHashException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace Crontrol\Exception;

/**
* Exception thrown when a hash is invalid for a cron event.
*/
class InvalidHashException extends CrontrolRuntimeException {}
8 changes: 8 additions & 0 deletions src/Exception/InvalidURLException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace Crontrol\Exception;

/**
* Exception thrown when a URL is invalid for a cron event.
*/
class InvalidURLException extends CrontrolRuntimeException {}
8 changes: 8 additions & 0 deletions src/Exception/MissingHashException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace Crontrol\Exception;

/**
* Exception thrown when a hash is missing for a cron event.
*/
class MissingHashException extends CrontrolRuntimeException {}
8 changes: 8 additions & 0 deletions src/Exception/MissingURLException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace Crontrol\Exception;

/**
* Exception thrown when a URL is missing for a cron event.
*/
class MissingURLException extends CrontrolRuntimeException {}
8 changes: 8 additions & 0 deletions src/Exception/UnexpectedHTTPCodeException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace Crontrol\Exception;

/**
* Exception thrown when an unexpected HTTP response code is received.
*/
class UnexpectedHTTPCodeException extends CrontrolRuntimeException {}
8 changes: 8 additions & 0 deletions src/Exception/UnknownScheduleException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace Crontrol\Exception;

/**
* Exception thrown when a schedule name is unknown.
*/
class UnknownScheduleException extends CrontrolRuntimeException {}
Loading