Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
External Permalinks Redux
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Show more breadcrumbs
WP Plugins
External Permalinks Redux
Merge requests
!3
Introduce unit tests
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Introduce unit tests
add/unit-tests
into
master
Overview
0
Commits
5
Pipelines
4
Changes
4
Merged
Erick Hitter
requested to merge
add/unit-tests
into
master
6 years ago
Overview
0
Commits
5
Pipelines
4
Changes
4
Expand
Run unit tests in multisite mode as well
Add badge to readme
Abstract redirection functionality to make it testable
Edited
6 years ago
by
Erick Hitter
0
0
Merge request reports
Compare
master
version 3
747088e2
6 years ago
version 2
b2c73a34
6 years ago
version 1
f510dc14
6 years ago
master (base)
and
version 3
latest version
7652c793
5 commits,
6 years ago
version 3
747088e2
4 commits,
6 years ago
version 2
b2c73a34
3 commits,
6 years ago
version 1
f510dc14
2 commits,
6 years ago
4 files
+
158
−
21
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
4
Search (e.g. *.vue) (Ctrl+P)
tests/test-admin-callbacks.php
0 → 100755
+
88
−
0
Options
<?php
/**
* Class AdminCallbacks
*
* @package External_Permalinks_Redux
*/
/**
* Test admin callbacks
*/
class
AdminCallbacks
extends
WP_UnitTestCase
{
/**
* Redirect destination.
*/
const
DESTINATION
=
'https://w.org/'
;
/**
* Redirect type.
*/
const
TYPE
=
302
;
/**
* Test post ID.
*
* @var int
*/
protected
$post_id
;
/**
* Plugin instance.
*
* @var external_permalinks_redux
*/
protected
$plugin
;
/**
* Metabox nonce.
*
* @var string
*/
protected
$nonce
;
/**
* Create some objects with redirects.
*/
public
function
setUp
()
{
parent
::
setUp
();
$this
->
plugin
=
external_permalinks_redux
::
get_instance
();
$this
->
post_id
=
$this
->
factory
->
post
->
create
(
[
'post_type'
=>
'post'
,
]
);
$this
->
nonce
=
wp_create_nonce
(
'external-permalinks-redux'
);
}
/**
* Test metabox rendering.
*/
public
function
test_meta_box
()
{
ob_start
();
$this
->
plugin
->
meta_box
(
get_post
(
$this
->
post_id
)
);
$meta_box_contents
=
ob_get_clean
();
$this
->
assertContains
(
'value="'
.
$this
->
nonce
.
'"'
,
$meta_box_contents
);
foreach
(
array_keys
(
$this
->
plugin
->
status_codes
)
as
$code
)
{
$this
->
assertContains
(
'value="'
.
$code
.
'"'
,
$meta_box_contents
);
}
}
/**
* Test metabox save.
*/
public
function
test_save_callback
()
{
$_POST
[
$this
->
plugin
->
meta_key_target
.
'_nonce'
]
=
$this
->
nonce
;
$_POST
[
$this
->
plugin
->
meta_key_target
.
'_url'
]
=
static
::
DESTINATION
;
$_POST
[
$this
->
plugin
->
meta_key_target
.
'_type'
]
=
static
::
TYPE
;
$this
->
plugin
->
action_save_post
(
$this
->
post_id
);
$this
->
assertEquals
(
static
::
DESTINATION
,
get_post_meta
(
$this
->
post_id
,
$this
->
plugin
->
meta_key_target
,
true
)
);
$this
->
assertEquals
(
static
::
TYPE
,
get_post_meta
(
$this
->
post_id
,
$this
->
plugin
->
meta_key_type
,
true
)
);
}
}
Loading