Skip to content

Commit

Permalink
Merge pull request #66 from humanmade/unit-tests
Browse files Browse the repository at this point in the history
Some basic unit tests
  • Loading branch information
rmccue authored Dec 4, 2018
2 parents 907c2ec + f49824f commit a572fbf
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ install:
- bash tests/install-tests.sh wordpress_test root '' 127.0.0.1 latest
script:
- phpunit
- vendor/bin/phpcs --standard=phpcs.ruleset.xml .
notifications:
email: false
5 changes: 4 additions & 1 deletion inc/class-job.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ protected static function to_instance( $row ) {
$job->interval = $row->interval;
$job->status = $row->status;

if ( ! empty( $row->schedule ) ) {
if ( ! $row->interval ) {
// One off event.
$job->schedule = false;
} elseif ( ! empty( $row->schedule ) ) {
$job->schedule = $row->schedule;
} else {
$job->schedule = get_schedule_by_interval( $row->interval );
Expand Down
2 changes: 2 additions & 0 deletions inc/connector/namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ function get_cron_array( $value ) {
$crons[ $timestamp ][ $hook ][ $key ] = $value;
}

ksort( $crons, SORT_NUMERIC );

// Set the version too
$crons['version'] = 2;

Expand Down
9 changes: 9 additions & 0 deletions tests/install-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,15 @@ install_db() {
mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA
}

# Download and copy the WordPress Core Cron
# tests for Cavalcade to ensure the plugin does
# not change the behaviour.
install_core_cron_tests() {
download https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/tests/cron.php "$TRAVIS_BUILD_DIR"/tests/class-wp-core-cron.php
}


install_wp
install_test_suite
install_db
install_core_cron_tests
2 changes: 1 addition & 1 deletion tests/tests/class-rescheduling.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*
* @ticket 64
*/
class Tests_Core extends WP_UnitTestCase {
class Tests_Rescheduling extends WP_UnitTestCase {
function setUp() {
parent::setUp();
// make sure the schedule is clear
Expand Down

0 comments on commit a572fbf

Please sign in to comment.