Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
wp-cli-cron-control-offload
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
WP Plugins
wp-cli-cron-control-offload
Commits
5a3878e7
Commit
5a3878e7
authored
7 years ago
by
Erick Hitter
Browse files
Options
Downloads
Patches
Plain Diff
Add scheduling tests
parent
f16eee49
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/tests/class-plugin-functions.php
+36
-2
36 additions, 2 deletions
tests/tests/class-plugin-functions.php
with
36 additions
and
2 deletions
tests/tests/class-plugin-functions.php
+
36
−
2
View file @
5a3878e7
...
@@ -10,9 +10,29 @@ use Automattic\WP\WP_CLI_Cron_Control_Offload;
...
@@ -10,9 +10,29 @@ use Automattic\WP\WP_CLI_Cron_Control_Offload;
use
WP_UnitTestCase
;
use
WP_UnitTestCase
;
/**
/**
*
Sample test case.
*
Core function tests
*/
*/
class
SampleTest
extends
WP_UnitTestCase
{
class
Plugin_Functions
extends
WP_UnitTestCase
{
/**
* Prepare test environment
*/
function
setUp
()
{
parent
::
setUp
();
// make sure the schedule is clear.
_set_cron_array
(
array
()
);
}
/**
* Clean up after our tests
*/
function
tearDown
()
{
// make sure the schedule is clear.
_set_cron_array
(
array
()
);
parent
::
tearDown
();
}
/**
/**
* Test whitelisted commands
* Test whitelisted commands
*/
*/
...
@@ -42,4 +62,18 @@ class SampleTest extends WP_UnitTestCase {
...
@@ -42,4 +62,18 @@ class SampleTest extends WP_UnitTestCase {
$this
->
assertTrue
(
is_wp_error
(
WP_CLI_Cron_Control_Offload\validate_command
(
'wp cli info'
)
)
);
$this
->
assertTrue
(
is_wp_error
(
WP_CLI_Cron_Control_Offload\validate_command
(
'wp cli info'
)
)
);
$this
->
assertTrue
(
is_wp_error
(
WP_CLI_Cron_Control_Offload\validate_command
(
'cli info'
)
)
);
$this
->
assertTrue
(
is_wp_error
(
WP_CLI_Cron_Control_Offload\validate_command
(
'cli info'
)
)
);
}
}
/**
* Test event scheduling
*/
function
test_event_scheduling
()
{
// Should succeed, returning a timestamp.
$this
->
assertTrue
(
is_int
(
WP_CLI_Cron_Control_Offload\schedule_cli_command
(
'wp cli info'
)
)
);
// Should be blocked as a duplicate, thanks to Core's 10-minute lookahead.
$this
->
assertTrue
(
is_wp_error
(
WP_CLI_Cron_Control_Offload\schedule_cli_command
(
'wp cli info'
)
)
);
// Should also fail as normalization makes it a duplicate.
$this
->
assertTrue
(
is_wp_error
(
WP_CLI_Cron_Control_Offload\schedule_cli_command
(
'cli info'
)
)
);
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment