mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-10-06 23:58:03 +00:00
Code is Poetry.
WordPress' code just... wasn't. This is now dealt with. Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS. Fixes #41057. git-svn-id: https://develop.svn.wordpress.org/trunk@42343 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -27,18 +27,22 @@ class Tests_Admin_IncludesComment extends WP_UnitTestCase {
|
||||
public static function wpSetUpBeforeClass( $factory ) {
|
||||
self::$post_id = $factory->post->create();
|
||||
|
||||
self::$comment_ids[] = $factory->comment->create( array(
|
||||
'comment_author' => 1,
|
||||
'comment_date' => '2014-05-06 12:00:00',
|
||||
'comment_date_gmt' => '2014-05-06 07:00:00',
|
||||
'comment_post_ID' => self::$post_id,
|
||||
) );
|
||||
self::$comment_ids[] = $factory->comment->create(
|
||||
array(
|
||||
'comment_author' => 1,
|
||||
'comment_date' => '2014-05-06 12:00:00',
|
||||
'comment_date_gmt' => '2014-05-06 07:00:00',
|
||||
'comment_post_ID' => self::$post_id,
|
||||
)
|
||||
);
|
||||
|
||||
self::$comment_ids[] = $factory->comment->create( array(
|
||||
'comment_author' => 2,
|
||||
'comment_date' => '2004-01-02 12:00:00',
|
||||
'comment_post_ID' => self::$post_id,
|
||||
) );
|
||||
self::$comment_ids[] = $factory->comment->create(
|
||||
array(
|
||||
'comment_author' => 2,
|
||||
'comment_date' => '2004-01-02 12:00:00',
|
||||
'comment_post_ID' => self::$post_id,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -201,53 +201,55 @@ class Test_WP_Community_Events extends WP_UnitTestCase {
|
||||
public function _http_request_valid_response() {
|
||||
return array(
|
||||
'headers' => '',
|
||||
'body' => wp_json_encode( array(
|
||||
'location' => $this->get_user_location(),
|
||||
'events' => array(
|
||||
array(
|
||||
'type' => 'meetup',
|
||||
'title' => 'Flexbox + CSS Grid: Magic for Responsive Layouts',
|
||||
'url' => 'https://www.meetup.com/Eastbay-WordPress-Meetup/events/236031233/',
|
||||
'meetup' => 'The East Bay WordPress Meetup Group',
|
||||
'meetup_url' => 'https://www.meetup.com/Eastbay-WordPress-Meetup/',
|
||||
'date' => date( 'Y-m-d H:i:s', strtotime( 'next Sunday 1pm' ) ),
|
||||
'location' => array(
|
||||
'location' => 'Oakland, CA, USA',
|
||||
'country' => 'us',
|
||||
'latitude' => 37.808453,
|
||||
'longitude' => -122.26593,
|
||||
'body' => wp_json_encode(
|
||||
array(
|
||||
'location' => $this->get_user_location(),
|
||||
'events' => array(
|
||||
array(
|
||||
'type' => 'meetup',
|
||||
'title' => 'Flexbox + CSS Grid: Magic for Responsive Layouts',
|
||||
'url' => 'https://www.meetup.com/Eastbay-WordPress-Meetup/events/236031233/',
|
||||
'meetup' => 'The East Bay WordPress Meetup Group',
|
||||
'meetup_url' => 'https://www.meetup.com/Eastbay-WordPress-Meetup/',
|
||||
'date' => date( 'Y-m-d H:i:s', strtotime( 'next Sunday 1pm' ) ),
|
||||
'location' => array(
|
||||
'location' => 'Oakland, CA, USA',
|
||||
'country' => 'us',
|
||||
'latitude' => 37.808453,
|
||||
'longitude' => -122.26593,
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'meetup',
|
||||
'title' => 'Part 3- Site Maintenance - Tools to Make It Easy',
|
||||
'url' => 'https://www.meetup.com/Wordpress-Bay-Area-CA-Foothills/events/237706839/',
|
||||
'meetup' => 'WordPress Bay Area Foothills Group',
|
||||
'meetup_url' => 'https://www.meetup.com/Wordpress-Bay-Area-CA-Foothills/',
|
||||
'date' => date( 'Y-m-d H:i:s', strtotime( 'next Wednesday 1:30pm' ) ),
|
||||
'location' => array(
|
||||
'location' => 'Milpitas, CA, USA',
|
||||
'country' => 'us',
|
||||
'latitude' => 37.432813,
|
||||
'longitude' => -121.907095,
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'wordcamp',
|
||||
'title' => 'WordCamp Kansas City',
|
||||
'url' => 'https://2017.kansascity.wordcamp.org',
|
||||
'meetup' => null,
|
||||
'meetup_url' => null,
|
||||
'date' => date( 'Y-m-d H:i:s', strtotime( 'next Saturday' ) ),
|
||||
'location' => array(
|
||||
'location' => 'Kansas City, MO',
|
||||
'country' => 'US',
|
||||
'latitude' => 39.0392325,
|
||||
'longitude' => -94.577076,
|
||||
),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'meetup',
|
||||
'title' => 'Part 3- Site Maintenance - Tools to Make It Easy',
|
||||
'url' => 'https://www.meetup.com/Wordpress-Bay-Area-CA-Foothills/events/237706839/',
|
||||
'meetup' => 'WordPress Bay Area Foothills Group',
|
||||
'meetup_url' => 'https://www.meetup.com/Wordpress-Bay-Area-CA-Foothills/',
|
||||
'date' => date( 'Y-m-d H:i:s', strtotime( 'next Wednesday 1:30pm' ) ),
|
||||
'location' => array(
|
||||
'location' => 'Milpitas, CA, USA',
|
||||
'country' => 'us',
|
||||
'latitude' => 37.432813,
|
||||
'longitude' => -121.907095,
|
||||
),
|
||||
),
|
||||
array(
|
||||
'type' => 'wordcamp',
|
||||
'title' => 'WordCamp Kansas City',
|
||||
'url' => 'https://2017.kansascity.wordcamp.org',
|
||||
'meetup' => null,
|
||||
'meetup_url' => null,
|
||||
'date' => date( 'Y-m-d H:i:s', strtotime( 'next Saturday' ) ),
|
||||
'location' => array(
|
||||
'location' => 'Kansas City, MO',
|
||||
'country' => 'US',
|
||||
'latitude' => 39.0392325,
|
||||
'longitude' => -94.577076,
|
||||
),
|
||||
),
|
||||
),
|
||||
) ),
|
||||
)
|
||||
),
|
||||
'response' => array(
|
||||
'code' => 200,
|
||||
),
|
||||
|
||||
@@ -10,9 +10,9 @@ class Tests_Admin_includesFile extends WP_UnitTestCase {
|
||||
* @ticket 20449
|
||||
*/
|
||||
function test_get_home_path() {
|
||||
$home = get_option( 'home' );
|
||||
$home = get_option( 'home' );
|
||||
$siteurl = get_option( 'siteurl' );
|
||||
$sfn = $_SERVER['SCRIPT_FILENAME'];
|
||||
$sfn = $_SERVER['SCRIPT_FILENAME'];
|
||||
$this->assertEquals( str_replace( '\\', '/', ABSPATH ), get_home_path() );
|
||||
|
||||
update_option( 'home', 'http://localhost' );
|
||||
@@ -31,4 +31,4 @@ class Tests_Admin_includesFile extends WP_UnitTestCase {
|
||||
update_option( 'siteurl', $siteurl );
|
||||
$_SERVER['SCRIPT_FILENAME'] = $sfn;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
* @group admin
|
||||
*/
|
||||
class Tests_Admin_includesListTable extends WP_UnitTestCase {
|
||||
protected static $top = array();
|
||||
protected static $children = array();
|
||||
protected static $top = array();
|
||||
protected static $children = array();
|
||||
protected static $grandchildren = array();
|
||||
protected static $post_ids = array();
|
||||
protected static $post_ids = array();
|
||||
|
||||
/**
|
||||
* @var WP_Posts_List_Table
|
||||
@@ -25,12 +25,14 @@ class Tests_Admin_includesListTable extends WP_UnitTestCase {
|
||||
// create top level pages
|
||||
$num_posts = 5;
|
||||
foreach ( range( 1, $num_posts ) as $i ) {
|
||||
$p = $factory->post->create_and_get( array(
|
||||
'post_type' => 'page',
|
||||
'post_title' => sprintf( 'Top Level Page %d', $i ),
|
||||
) );
|
||||
$p = $factory->post->create_and_get(
|
||||
array(
|
||||
'post_type' => 'page',
|
||||
'post_title' => sprintf( 'Top Level Page %d', $i ),
|
||||
)
|
||||
);
|
||||
|
||||
self::$top[ $i ] = $p;
|
||||
self::$top[ $i ] = $p;
|
||||
self::$post_ids[] = $p->ID;
|
||||
}
|
||||
|
||||
@@ -38,14 +40,16 @@ class Tests_Admin_includesListTable extends WP_UnitTestCase {
|
||||
$num_children = 3;
|
||||
foreach ( self::$top as $top => $top_page ) {
|
||||
foreach ( range( 1, $num_children ) as $i ) {
|
||||
$p = $factory->post->create_and_get( array(
|
||||
'post_type' => 'page',
|
||||
'post_parent' => $top_page->ID,
|
||||
'post_title' => sprintf( 'Child %d', $i ),
|
||||
) );
|
||||
$p = $factory->post->create_and_get(
|
||||
array(
|
||||
'post_type' => 'page',
|
||||
'post_parent' => $top_page->ID,
|
||||
'post_title' => sprintf( 'Child %d', $i ),
|
||||
)
|
||||
);
|
||||
|
||||
self::$children[ $top ][ $i ] = $p;
|
||||
self::$post_ids[] = $p->ID;
|
||||
self::$post_ids[] = $p->ID;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,14 +58,16 @@ class Tests_Admin_includesListTable extends WP_UnitTestCase {
|
||||
foreach ( range( 3, 4 ) as $top ) {
|
||||
foreach ( self::$children[ $top ] as $child => $child_page ) {
|
||||
foreach ( range( 1, $num_grandchildren ) as $i ) {
|
||||
$p = $factory->post->create_and_get( array(
|
||||
'post_type' => 'page',
|
||||
'post_parent' => $child_page->ID,
|
||||
'post_title' => sprintf( 'Grandchild %d', $i ),
|
||||
) );
|
||||
$p = $factory->post->create_and_get(
|
||||
array(
|
||||
'post_type' => 'page',
|
||||
'post_parent' => $child_page->ID,
|
||||
'post_title' => sprintf( 'Grandchild %d', $i ),
|
||||
)
|
||||
);
|
||||
|
||||
self::$grandchildren[ $top ][ $child ][ $i ] = $p;
|
||||
self::$post_ids[] = $p->ID;
|
||||
self::$post_ids[] = $p->ID;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -71,55 +77,63 @@ class Tests_Admin_includesListTable extends WP_UnitTestCase {
|
||||
* @ticket 15459
|
||||
*/
|
||||
function test_list_hierarchical_pages_first_page() {
|
||||
$this->_test_list_hierarchical_page( array(
|
||||
'paged' => 1,
|
||||
'posts_per_page' => 2,
|
||||
), array(
|
||||
self::$top[1]->ID,
|
||||
self::$children[1][1]->ID,
|
||||
) );
|
||||
$this->_test_list_hierarchical_page(
|
||||
array(
|
||||
'paged' => 1,
|
||||
'posts_per_page' => 2,
|
||||
), array(
|
||||
self::$top[1]->ID,
|
||||
self::$children[1][1]->ID,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 15459
|
||||
*/
|
||||
function test_list_hierarchical_pages_second_page() {
|
||||
$this->_test_list_hierarchical_page( array(
|
||||
'paged' => 2,
|
||||
'posts_per_page' => 2,
|
||||
), array(
|
||||
self::$top[1]->ID,
|
||||
self::$children[1][2]->ID,
|
||||
self::$children[1][3]->ID,
|
||||
) );
|
||||
$this->_test_list_hierarchical_page(
|
||||
array(
|
||||
'paged' => 2,
|
||||
'posts_per_page' => 2,
|
||||
), array(
|
||||
self::$top[1]->ID,
|
||||
self::$children[1][2]->ID,
|
||||
self::$children[1][3]->ID,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 15459
|
||||
*/
|
||||
function test_search_hierarchical_pages_first_page() {
|
||||
$this->_test_list_hierarchical_page( array(
|
||||
'paged' => 1,
|
||||
'posts_per_page' => 2,
|
||||
's' => 'Child',
|
||||
), array(
|
||||
self::$children[1][1]->ID,
|
||||
self::$children[1][2]->ID,
|
||||
) );
|
||||
$this->_test_list_hierarchical_page(
|
||||
array(
|
||||
'paged' => 1,
|
||||
'posts_per_page' => 2,
|
||||
's' => 'Child',
|
||||
), array(
|
||||
self::$children[1][1]->ID,
|
||||
self::$children[1][2]->ID,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 15459
|
||||
*/
|
||||
function test_search_hierarchical_pages_second_page() {
|
||||
$this->_test_list_hierarchical_page( array(
|
||||
'paged' => 2,
|
||||
'posts_per_page' => 2,
|
||||
's' => 'Top',
|
||||
), array(
|
||||
self::$top[3]->ID,
|
||||
self::$top[4]->ID,
|
||||
) );
|
||||
$this->_test_list_hierarchical_page(
|
||||
array(
|
||||
'paged' => 2,
|
||||
'posts_per_page' => 2,
|
||||
's' => 'Top',
|
||||
), array(
|
||||
self::$top[3]->ID,
|
||||
self::$top[4]->ID,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,15 +141,17 @@ class Tests_Admin_includesListTable extends WP_UnitTestCase {
|
||||
*/
|
||||
function test_grandchildren_hierarchical_pages_first_page() {
|
||||
// page 6 is the first page with grandchildren
|
||||
$this->_test_list_hierarchical_page( array(
|
||||
'paged' => 6,
|
||||
'posts_per_page' => 2,
|
||||
), array(
|
||||
self::$top[3]->ID,
|
||||
self::$children[3][1]->ID,
|
||||
self::$grandchildren[3][1][1]->ID,
|
||||
self::$grandchildren[3][1][2]->ID,
|
||||
) );
|
||||
$this->_test_list_hierarchical_page(
|
||||
array(
|
||||
'paged' => 6,
|
||||
'posts_per_page' => 2,
|
||||
), array(
|
||||
self::$top[3]->ID,
|
||||
self::$children[3][1]->ID,
|
||||
self::$grandchildren[3][1][1]->ID,
|
||||
self::$grandchildren[3][1][2]->ID,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,15 +159,17 @@ class Tests_Admin_includesListTable extends WP_UnitTestCase {
|
||||
*/
|
||||
function test_grandchildren_hierarchical_pages_second_page() {
|
||||
// page 7 is the second page with grandchildren
|
||||
$this->_test_list_hierarchical_page( array(
|
||||
'paged' => 7,
|
||||
'posts_per_page' => 2,
|
||||
), array(
|
||||
self::$top[3]->ID,
|
||||
self::$children[3][1]->ID,
|
||||
self::$grandchildren[3][1][3]->ID,
|
||||
self::$children[3][2]->ID,
|
||||
) );
|
||||
$this->_test_list_hierarchical_page(
|
||||
array(
|
||||
'paged' => 7,
|
||||
'posts_per_page' => 2,
|
||||
), array(
|
||||
self::$top[3]->ID,
|
||||
self::$children[3][1]->ID,
|
||||
self::$grandchildren[3][1][3]->ID,
|
||||
self::$children[3][2]->ID,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -166,9 +184,11 @@ class Tests_Admin_includesListTable extends WP_UnitTestCase {
|
||||
$_REQUEST['paged'] = $args['paged'];
|
||||
$GLOBALS['per_page'] = $args['posts_per_page'];
|
||||
|
||||
$args = array_merge( array(
|
||||
'post_type' => 'page',
|
||||
), $args );
|
||||
$args = array_merge(
|
||||
array(
|
||||
'post_type' => 'page',
|
||||
), $args
|
||||
);
|
||||
|
||||
// Mimic the behaviour of `wp_edit_posts_query()`:
|
||||
if ( ! isset( $args['orderby'] ) ) {
|
||||
|
||||
@@ -19,7 +19,8 @@ class Tests_Admin_includesMisc extends WP_UnitTestCase {
|
||||
'http://wordpress.org/about/philosophy/#decisions'
|
||||
=> 'wordpress.org/about/philosophy/#…', // shorten to 32 if > 35 after cleaning
|
||||
);
|
||||
foreach ( $tests as $k => $v )
|
||||
foreach ( $tests as $k => $v ) {
|
||||
$this->assertEquals( $v, url_shorten( $k ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,22 +8,22 @@ class Tests_Admin_includesPlugin extends WP_UnitTestCase {
|
||||
$data = get_plugin_data( DIR_TESTDATA . '/plugins/hello.php' );
|
||||
|
||||
$default_headers = array(
|
||||
'Name' => 'Hello Dolly',
|
||||
'Title' => '<a href="http://wordpress.org/#">Hello Dolly</a>',
|
||||
'PluginURI' => 'http://wordpress.org/#',
|
||||
'Name' => 'Hello Dolly',
|
||||
'Title' => '<a href="http://wordpress.org/#">Hello Dolly</a>',
|
||||
'PluginURI' => 'http://wordpress.org/#',
|
||||
'Description' => 'This is not just a plugin, it symbolizes the hope and enthusiasm of an entire generation summed up in two words sung most famously by Louis Armstrong: Hello, Dolly. When activated you will randomly see a lyric from Hello, Dolly in the upper right of your admin screen on every page. <cite>By <a href="http://ma.tt/">Matt Mullenweg</a>.</cite>',
|
||||
'Author' => '<a href="http://ma.tt/">Matt Mullenweg</a>',
|
||||
'AuthorURI' => 'http://ma.tt/',
|
||||
'Version' => '1.5.1',
|
||||
'TextDomain' => 'hello-dolly',
|
||||
'DomainPath' => ''
|
||||
'Author' => '<a href="http://ma.tt/">Matt Mullenweg</a>',
|
||||
'AuthorURI' => 'http://ma.tt/',
|
||||
'Version' => '1.5.1',
|
||||
'TextDomain' => 'hello-dolly',
|
||||
'DomainPath' => '',
|
||||
);
|
||||
|
||||
$this->assertTrue( is_array($data) );
|
||||
$this->assertTrue( is_array( $data ) );
|
||||
|
||||
foreach ($default_headers as $name => $value) {
|
||||
$this->assertTrue(isset($data[$name]));
|
||||
$this->assertEquals($value, $data[$name]);
|
||||
foreach ( $default_headers as $name => $value ) {
|
||||
$this->assertTrue( isset( $data[ $name ] ) );
|
||||
$this->assertEquals( $value, $data[ $name ] );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,16 +41,16 @@ class Tests_Admin_includesPlugin extends WP_UnitTestCase {
|
||||
add_theme_page( 'With Spaces', 'With Spaces', 'manage_options', 'With Spaces', 'mt_tools_page' );
|
||||
add_pages_page( 'Appending Query Arg', 'Test Pages', 'edit_pages', 'testpages', 'mt_pages_page' );
|
||||
|
||||
$expected['testsettings'] = 'http://example.com/wp-admin/options-general.php?page=testsettings';
|
||||
$expected['testtools'] = 'http://example.com/wp-admin/tools.php?page=testtools';
|
||||
$expected['testsettings'] = 'http://example.com/wp-admin/options-general.php?page=testsettings';
|
||||
$expected['testtools'] = 'http://example.com/wp-admin/tools.php?page=testtools';
|
||||
$expected['mt-top-level-handle'] = 'http://example.com/wp-admin/admin.php?page=mt-top-level-handle';
|
||||
$expected['sub-page'] = 'http://example.com/wp-admin/admin.php?page=sub-page';
|
||||
$expected['sub-page2'] = 'http://example.com/wp-admin/admin.php?page=sub-page2';
|
||||
$expected['not_registered'] = '';
|
||||
$expected['With Spaces'] = 'http://example.com/wp-admin/themes.php?page=With%20Spaces';
|
||||
$expected['testpages'] = 'http://example.com/wp-admin/edit.php?post_type=page&page=testpages';
|
||||
$expected['sub-page'] = 'http://example.com/wp-admin/admin.php?page=sub-page';
|
||||
$expected['sub-page2'] = 'http://example.com/wp-admin/admin.php?page=sub-page2';
|
||||
$expected['not_registered'] = '';
|
||||
$expected['With Spaces'] = 'http://example.com/wp-admin/themes.php?page=With%20Spaces';
|
||||
$expected['testpages'] = 'http://example.com/wp-admin/edit.php?post_type=page&page=testpages';
|
||||
|
||||
foreach ($expected as $name => $value) {
|
||||
foreach ( $expected as $name => $value ) {
|
||||
$this->assertEquals( $value, menu_page_url( $name, false ) );
|
||||
}
|
||||
|
||||
@@ -99,14 +99,14 @@ class Tests_Admin_includesPlugin extends WP_UnitTestCase {
|
||||
public function test_get_plugin_files_folder() {
|
||||
$plugin_dir = WP_PLUGIN_DIR . '/list_files_test_plugin';
|
||||
@mkdir( $plugin_dir );
|
||||
$plugin = $this->_create_plugin(null, 'list_files_test_plugin.php', $plugin_dir );
|
||||
$plugin = $this->_create_plugin( null, 'list_files_test_plugin.php', $plugin_dir );
|
||||
|
||||
$sub_dir = trailingslashit( dirname( $plugin[1] ) ) . 'subdir';
|
||||
@mkdir( $sub_dir );
|
||||
@file_put_contents( $sub_dir . '/subfile.php', '<?php // Silence.' );
|
||||
|
||||
$plugin_files = get_plugin_files( plugin_basename( $plugin[1] ) );
|
||||
$expected = array(
|
||||
$expected = array(
|
||||
'list_files_test_plugin/list_files_test_plugin.php',
|
||||
'list_files_test_plugin/subdir/subfile.php',
|
||||
);
|
||||
@@ -320,11 +320,11 @@ class Tests_Admin_includesPlugin extends WP_UnitTestCase {
|
||||
public function test_validate_active_plugins_remove_invalid() {
|
||||
$plugin = $this->_create_plugin();
|
||||
|
||||
activate_plugin( $plugin[ 0 ] );
|
||||
unlink( $plugin[ 1 ] );
|
||||
activate_plugin( $plugin[0] );
|
||||
unlink( $plugin[1] );
|
||||
|
||||
$result = validate_active_plugins();
|
||||
$this->assertTrue( isset( $result[ $plugin[ 0 ] ] ) );
|
||||
$this->assertTrue( isset( $result[ $plugin[0] ] ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -347,7 +347,7 @@ class Tests_Admin_includesPlugin extends WP_UnitTestCase {
|
||||
public function test_is_uninstallable_plugin_true() {
|
||||
$plugin = $this->_create_plugin();
|
||||
|
||||
$uninstallable_plugins = (array) get_option( 'uninstall_plugins' );
|
||||
$uninstallable_plugins = (array) get_option( 'uninstall_plugins' );
|
||||
$uninstallable_plugins[ $plugin[0] ] = true;
|
||||
update_option( 'uninstall_plugins', $uninstallable_plugins );
|
||||
|
||||
@@ -430,7 +430,7 @@ class Tests_Admin_includesPlugin extends WP_UnitTestCase {
|
||||
* @access private
|
||||
*/
|
||||
private function _restore_mu_plugins() {
|
||||
$mu_bu_dir = WP_CONTENT_DIR . '/mu-plugin-backup';
|
||||
$mu_bu_dir = WP_CONTENT_DIR . '/mu-plugin-backup';
|
||||
$files_to_move = array();
|
||||
if ( is_dir( $mu_bu_dir ) && $mu_plugins = opendir( $mu_bu_dir ) ) {
|
||||
while ( false !== $plugin = readdir( $mu_plugins ) ) {
|
||||
@@ -464,7 +464,7 @@ class Tests_Admin_includesPlugin extends WP_UnitTestCase {
|
||||
mkdir( $di_bu_dir );
|
||||
}
|
||||
|
||||
foreach( _get_dropins() as $file_to_move => $v ) {
|
||||
foreach ( _get_dropins() as $file_to_move => $v ) {
|
||||
if ( file_exists( WP_CONTENT_DIR . '/' . $file_to_move ) ) {
|
||||
rename( WP_CONTENT_DIR . '/' . $file_to_move, $di_bu_dir . '/' . $file_to_move );
|
||||
}
|
||||
@@ -481,7 +481,7 @@ class Tests_Admin_includesPlugin extends WP_UnitTestCase {
|
||||
private function _restore_drop_ins() {
|
||||
$di_bu_dir = WP_CONTENT_DIR . '/drop-ins-backup';
|
||||
|
||||
foreach( _get_dropins() as $file_to_move => $v ) {
|
||||
foreach ( _get_dropins() as $file_to_move => $v ) {
|
||||
if ( file_exists( $di_bu_dir . '/' . $file_to_move ) ) {
|
||||
rename( $di_bu_dir . '/' . $file_to_move, WP_CONTENT_DIR . '/' . $file_to_move );
|
||||
}
|
||||
|
||||
@@ -26,9 +26,9 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
|
||||
wp_set_current_user( self::$contributor_id );
|
||||
|
||||
// Create New Draft Post
|
||||
$_post_data = array();
|
||||
$_post_data = array();
|
||||
$_post_data['post_author'] = self::$contributor_id;
|
||||
$_post_data['post_type'] = 'post';
|
||||
$_post_data['post_type'] = 'post';
|
||||
$_post_data['saveasdraft'] = true;
|
||||
|
||||
$_results = _wp_translate_postdata( false, $_post_data );
|
||||
@@ -37,10 +37,10 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
|
||||
$this->assertEquals( 'draft', $_results['post_status'] );
|
||||
|
||||
// Submit Post for Approval
|
||||
$_post_data = array();
|
||||
$_post_data = array();
|
||||
$_post_data['post_author'] = self::$contributor_id;
|
||||
$_post_data['post_type'] = 'post';
|
||||
$_post_data['publish'] = true;
|
||||
$_post_data['post_type'] = 'post';
|
||||
$_post_data['publish'] = true;
|
||||
|
||||
$_results = _wp_translate_postdata( false, $_post_data );
|
||||
$this->assertNotInstanceOf( 'WP_Error', $_results );
|
||||
@@ -48,9 +48,9 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
|
||||
$this->assertEquals( 'pending', $_results['post_status'] );
|
||||
|
||||
// Create New Draft Post for another user
|
||||
$_post_data = array();
|
||||
$_post_data = array();
|
||||
$_post_data['post_author'] = self::$editor_id;
|
||||
$_post_data['post_type'] = 'post';
|
||||
$_post_data['post_type'] = 'post';
|
||||
$_post_data['saveasdraft'] = true;
|
||||
|
||||
$_results = _wp_translate_postdata( false, $_post_data );
|
||||
@@ -59,10 +59,10 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
|
||||
$this->assertEquals( 'Sorry, you are not allowed to create posts as this user.', $_results->get_error_message() );
|
||||
|
||||
// Edit Draft Post for another user
|
||||
$_post_data = array();
|
||||
$_post_data['post_ID'] = self::factory()->post->create( array( 'post_author' => self::$editor_id ) );
|
||||
$_post_data = array();
|
||||
$_post_data['post_ID'] = self::factory()->post->create( array( 'post_author' => self::$editor_id ) );
|
||||
$_post_data['post_author'] = self::$editor_id;
|
||||
$_post_data['post_type'] = 'post';
|
||||
$_post_data['post_type'] = 'post';
|
||||
$_post_data['post_status'] = 'draft';
|
||||
$_post_data['saveasdraft'] = true;
|
||||
|
||||
@@ -76,9 +76,9 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
|
||||
wp_set_current_user( self::$editor_id );
|
||||
|
||||
// Create New Draft Post
|
||||
$_post_data = array();
|
||||
$_post_data = array();
|
||||
$_post_data['post_author'] = self::$editor_id;
|
||||
$_post_data['post_type'] = 'post';
|
||||
$_post_data['post_type'] = 'post';
|
||||
$_post_data['saveasdraft'] = true;
|
||||
|
||||
$_results = _wp_translate_postdata( false, $_post_data );
|
||||
@@ -87,10 +87,10 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
|
||||
$this->assertEquals( 'draft', $_results['post_status'] );
|
||||
|
||||
// Publish Post
|
||||
$_post_data = array();
|
||||
$_post_data = array();
|
||||
$_post_data['post_author'] = self::$editor_id;
|
||||
$_post_data['post_type'] = 'post';
|
||||
$_post_data['publish'] = true;
|
||||
$_post_data['post_type'] = 'post';
|
||||
$_post_data['publish'] = true;
|
||||
|
||||
$_results = _wp_translate_postdata( false, $_post_data );
|
||||
$this->assertNotInstanceOf( 'WP_Error', $_results );
|
||||
@@ -98,9 +98,9 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
|
||||
$this->assertEquals( 'publish', $_results['post_status'] );
|
||||
|
||||
// Create New Draft Post for another user
|
||||
$_post_data = array();
|
||||
$_post_data = array();
|
||||
$_post_data['post_author'] = self::$contributor_id;
|
||||
$_post_data['post_type'] = 'post';
|
||||
$_post_data['post_type'] = 'post';
|
||||
$_post_data['saveasdraft'] = true;
|
||||
|
||||
$_results = _wp_translate_postdata( false, $_post_data );
|
||||
@@ -109,10 +109,10 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
|
||||
$this->assertEquals( 'draft', $_results['post_status'] );
|
||||
|
||||
// Edit Draft Post for another user
|
||||
$_post_data = array();
|
||||
$_post_data['post_ID'] = self::factory()->post->create( array( 'post_author' => self::$contributor_id ) );
|
||||
$_post_data = array();
|
||||
$_post_data['post_ID'] = self::factory()->post->create( array( 'post_author' => self::$contributor_id ) );
|
||||
$_post_data['post_author'] = self::$contributor_id;
|
||||
$_post_data['post_type'] = 'post';
|
||||
$_post_data['post_type'] = 'post';
|
||||
$_post_data['post_status'] = 'draft';
|
||||
$_post_data['saveasdraft'] = true;
|
||||
|
||||
@@ -133,9 +133,9 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
|
||||
$this->assertEquals( 'auto-draft', $post->post_status );
|
||||
$post_data = array(
|
||||
'post_title' => 'Post title',
|
||||
'content' => 'Post content',
|
||||
'post_type' => 'post',
|
||||
'post_ID' => $post->ID,
|
||||
'content' => 'Post content',
|
||||
'post_type' => 'post',
|
||||
'post_ID' => $post->ID,
|
||||
);
|
||||
edit_post( $post_data );
|
||||
$this->assertEquals( 'draft', get_post( $post->ID )->post_status );
|
||||
@@ -148,19 +148,23 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
|
||||
wp_set_current_user( self::$editor_id );
|
||||
|
||||
register_taxonomy( 'wptests_tax', array( 'post' ) );
|
||||
$t1 = self::factory()->term->create( array(
|
||||
'taxonomy' => 'wptests_tax',
|
||||
'name' => 'foo',
|
||||
'slug' => 'bar',
|
||||
) );
|
||||
$t2 = self::factory()->term->create( array(
|
||||
'taxonomy' => 'wptests_tax',
|
||||
'name' => 'bar',
|
||||
'slug' => 'foo',
|
||||
) );
|
||||
$t1 = self::factory()->term->create(
|
||||
array(
|
||||
'taxonomy' => 'wptests_tax',
|
||||
'name' => 'foo',
|
||||
'slug' => 'bar',
|
||||
)
|
||||
);
|
||||
$t2 = self::factory()->term->create(
|
||||
array(
|
||||
'taxonomy' => 'wptests_tax',
|
||||
'name' => 'bar',
|
||||
'slug' => 'foo',
|
||||
)
|
||||
);
|
||||
|
||||
$post_data = array(
|
||||
'post_ID' => self::$post_id,
|
||||
'post_ID' => self::$post_id,
|
||||
'tax_input' => array(
|
||||
'wptests_tax' => 'foo,baz',
|
||||
),
|
||||
@@ -184,14 +188,16 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
|
||||
wp_set_current_user( self::$editor_id );
|
||||
|
||||
register_taxonomy( 'wptests_tax', array( 'post' ) );
|
||||
self::factory()->term->create( array(
|
||||
'taxonomy' => 'wptests_tax',
|
||||
'name' => 'foo',
|
||||
'slug' => 'bar',
|
||||
) );
|
||||
self::factory()->term->create(
|
||||
array(
|
||||
'taxonomy' => 'wptests_tax',
|
||||
'name' => 'foo',
|
||||
'slug' => 'bar',
|
||||
)
|
||||
);
|
||||
|
||||
$post_data = array(
|
||||
'post_ID' => self::$post_id,
|
||||
'post_ID' => self::$post_id,
|
||||
'tax_input' => array(
|
||||
'wptests_tax' => ' ',
|
||||
),
|
||||
@@ -210,27 +216,31 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
|
||||
public function test_bulk_edit_posts_stomping() {
|
||||
wp_set_current_user( self::$admin_id );
|
||||
|
||||
$post1 = self::factory()->post->create( array(
|
||||
'post_author' => self::$author_ids[0],
|
||||
'comment_status' => 'open',
|
||||
'ping_status' => 'open',
|
||||
'post_status' => 'publish',
|
||||
) );
|
||||
$post1 = self::factory()->post->create(
|
||||
array(
|
||||
'post_author' => self::$author_ids[0],
|
||||
'comment_status' => 'open',
|
||||
'ping_status' => 'open',
|
||||
'post_status' => 'publish',
|
||||
)
|
||||
);
|
||||
|
||||
$post2 = self::factory()->post->create( array(
|
||||
'post_author' => self::$author_ids[1],
|
||||
'comment_status' => 'closed',
|
||||
'ping_status' => 'closed',
|
||||
'post_status' => 'draft',
|
||||
) );
|
||||
$post2 = self::factory()->post->create(
|
||||
array(
|
||||
'post_author' => self::$author_ids[1],
|
||||
'comment_status' => 'closed',
|
||||
'ping_status' => 'closed',
|
||||
'post_status' => 'draft',
|
||||
)
|
||||
);
|
||||
|
||||
$request = array(
|
||||
'post_type' => 'post',
|
||||
'post_author' => -1,
|
||||
'ping_status' => -1,
|
||||
'comment_status' => -1,
|
||||
'_status' => -1,
|
||||
'post' => array( $post1, $post2 ),
|
||||
'post_type' => 'post',
|
||||
'post_author' => -1,
|
||||
'ping_status' => -1,
|
||||
'comment_status' => -1,
|
||||
'_status' => -1,
|
||||
'post' => array( $post1, $post2 ),
|
||||
);
|
||||
|
||||
bulk_edit_posts( $request );
|
||||
@@ -311,9 +321,15 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
|
||||
$this->set_permalink_structure( "/$permalink_structure/" );
|
||||
|
||||
$future_date = date( 'Y-m-d H:i:s', time() + 100 );
|
||||
$p = self::factory()->post->create( array( 'post_status' => 'future', 'post_name' => 'foo', 'post_date' => $future_date ) );
|
||||
$p = self::factory()->post->create(
|
||||
array(
|
||||
'post_status' => 'future',
|
||||
'post_name' => 'foo',
|
||||
'post_date' => $future_date,
|
||||
)
|
||||
);
|
||||
|
||||
$found = get_sample_permalink( $p );
|
||||
$found = get_sample_permalink( $p );
|
||||
$expected = trailingslashit( home_url( $permalink_structure ) );
|
||||
|
||||
$this->assertSame( $expected, $found[0] );
|
||||
@@ -327,7 +343,13 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
|
||||
wp_set_current_user( self::$admin_id );
|
||||
|
||||
$future_date = date( 'Y-m-d H:i:s', time() + 100 );
|
||||
$p = self::factory()->post->create( array( 'post_status' => 'future', 'post_name' => 'foo', 'post_date' => $future_date ) );
|
||||
$p = self::factory()->post->create(
|
||||
array(
|
||||
'post_status' => 'future',
|
||||
'post_name' => 'foo',
|
||||
'post_date' => $future_date,
|
||||
)
|
||||
);
|
||||
|
||||
$found = get_sample_permalink_html( $p );
|
||||
$this->assertContains( 'href="' . get_option( 'home' ) . '/?p=' . $p . '"', $found );
|
||||
@@ -344,11 +366,17 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
|
||||
wp_set_current_user( self::$admin_id );
|
||||
|
||||
$future_date = date( 'Y-m-d H:i:s', time() + 100 );
|
||||
$p = self::factory()->post->create( array( 'post_status' => 'future', 'post_name' => 'foo-صورة', 'post_date' => $future_date ) );
|
||||
$p = self::factory()->post->create(
|
||||
array(
|
||||
'post_status' => 'future',
|
||||
'post_name' => 'foo-صورة',
|
||||
'post_date' => $future_date,
|
||||
)
|
||||
);
|
||||
|
||||
$found = get_sample_permalink_html( $p );
|
||||
$post = get_post( $p );
|
||||
$this->assertContains( 'href="' . get_option( 'home' ) . "/" . $post->post_name . '/"', $found );
|
||||
$post = get_post( $p );
|
||||
$this->assertContains( 'href="' . get_option( 'home' ) . '/' . $post->post_name . '/"', $found );
|
||||
$this->assertContains( '>' . urldecode( $post->post_name ) . '<', $found );
|
||||
}
|
||||
|
||||
@@ -360,16 +388,18 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
|
||||
|
||||
wp_set_current_user( self::$admin_id );
|
||||
|
||||
$p = self::factory()->attachment->create_object( 'صورة.jpg', 0, array(
|
||||
'post_mime_type' => 'image/jpeg',
|
||||
'post_type' => 'attachment',
|
||||
'post_title' => 'صورة',
|
||||
'post_status' => 'inherit',
|
||||
) );
|
||||
$p = self::factory()->attachment->create_object(
|
||||
'صورة.jpg', 0, array(
|
||||
'post_mime_type' => 'image/jpeg',
|
||||
'post_type' => 'attachment',
|
||||
'post_title' => 'صورة',
|
||||
'post_status' => 'inherit',
|
||||
)
|
||||
);
|
||||
|
||||
$found = get_sample_permalink_html( $p );
|
||||
$post = get_post( $p );
|
||||
$this->assertContains( 'href="' . get_option( 'home' ) . "/" . $post->post_name . '/"', $found );
|
||||
$post = get_post( $p );
|
||||
$this->assertContains( 'href="' . get_option( 'home' ) . '/' . $post->post_name . '/"', $found );
|
||||
$this->assertContains( '>' . urldecode( get_permalink( $post ) ) . '<', $found );
|
||||
}
|
||||
|
||||
@@ -383,29 +413,45 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
|
||||
wp_set_current_user( self::$admin_id );
|
||||
|
||||
// Published posts should use published permalink
|
||||
$p = self::factory()->post->create( array( 'post_status' => 'publish', 'post_name' => 'foo-صورة' ) );
|
||||
$p = self::factory()->post->create(
|
||||
array(
|
||||
'post_status' => 'publish',
|
||||
'post_name' => 'foo-صورة',
|
||||
)
|
||||
);
|
||||
|
||||
$found = get_sample_permalink_html( $p, null, 'new_slug-صورة' );
|
||||
$post = get_post( $p );
|
||||
$found = get_sample_permalink_html( $p, null, 'new_slug-صورة' );
|
||||
$post = get_post( $p );
|
||||
$message = 'Published post';
|
||||
$this->assertContains( 'href="' . get_option( 'home' ) . "/" . $post->post_name . '/"', $found, $message );
|
||||
$this->assertContains( 'href="' . get_option( 'home' ) . '/' . $post->post_name . '/"', $found, $message );
|
||||
$this->assertContains( '>new_slug-صورة<', $found, $message );
|
||||
|
||||
// Scheduled posts should use published permalink
|
||||
$future_date = date( 'Y-m-d H:i:s', time() + 100 );
|
||||
$p = self::factory()->post->create( array( 'post_status' => 'future', 'post_name' => 'bar-صورة', 'post_date' => $future_date ) );
|
||||
$p = self::factory()->post->create(
|
||||
array(
|
||||
'post_status' => 'future',
|
||||
'post_name' => 'bar-صورة',
|
||||
'post_date' => $future_date,
|
||||
)
|
||||
);
|
||||
|
||||
$found = get_sample_permalink_html( $p, null, 'new_slug-صورة' );
|
||||
$post = get_post( $p );
|
||||
$found = get_sample_permalink_html( $p, null, 'new_slug-صورة' );
|
||||
$post = get_post( $p );
|
||||
$message = 'Scheduled post';
|
||||
$this->assertContains( 'href="' . get_option( 'home' ) . "/" . $post->post_name . '/"', $found, $message );
|
||||
$this->assertContains( 'href="' . get_option( 'home' ) . '/' . $post->post_name . '/"', $found, $message );
|
||||
$this->assertContains( '>new_slug-صورة<', $found, $message );
|
||||
|
||||
// Draft posts should use preview link
|
||||
$p = self::factory()->post->create( array( 'post_status' => 'draft', 'post_name' => 'baz-صورة' ) );
|
||||
$p = self::factory()->post->create(
|
||||
array(
|
||||
'post_status' => 'draft',
|
||||
'post_name' => 'baz-صورة',
|
||||
)
|
||||
);
|
||||
|
||||
$found = get_sample_permalink_html( $p, null, 'new_slug-صورة' );
|
||||
$post = get_post( $p );
|
||||
$found = get_sample_permalink_html( $p, null, 'new_slug-صورة' );
|
||||
$post = get_post( $p );
|
||||
$message = 'Draft post';
|
||||
|
||||
$preview_link = get_permalink( $post->ID );
|
||||
@@ -425,10 +471,16 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
|
||||
wp_set_current_user( self::$admin_id );
|
||||
|
||||
$future_date = date( 'Y-m-d H:i:s', time() + 100 );
|
||||
$p = self::factory()->post->create( array( 'post_status' => 'pending', 'post_name' => '', 'post_date' => $future_date ) );
|
||||
$p = self::factory()->post->create(
|
||||
array(
|
||||
'post_status' => 'pending',
|
||||
'post_name' => '',
|
||||
'post_date' => $future_date,
|
||||
)
|
||||
);
|
||||
|
||||
$found = get_sample_permalink_html( $p );
|
||||
$post = get_post( $p );
|
||||
$post = get_post( $p );
|
||||
$this->assertContains( 'href="' . esc_url( get_preview_post_link( $post ) ), $found );
|
||||
}
|
||||
|
||||
@@ -438,9 +490,11 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
|
||||
public function test_get_sample_permalink_should_avoid_slugs_that_would_create_clashes_with_year_archives() {
|
||||
$this->set_permalink_structure( '/%postname%/' );
|
||||
|
||||
$p = self::factory()->post->create( array(
|
||||
'post_name' => '2015',
|
||||
) );
|
||||
$p = self::factory()->post->create(
|
||||
array(
|
||||
'post_name' => '2015',
|
||||
)
|
||||
);
|
||||
|
||||
$found = get_sample_permalink( $p );
|
||||
$this->assertEquals( '2015-2', $found[1] );
|
||||
@@ -452,9 +506,11 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
|
||||
public function test_get_sample_permalink_should_allow_yearlike_slugs_if_permastruct_does_not_cause_an_archive_conflict() {
|
||||
$this->set_permalink_structure( '/%year%/%postname%/' );
|
||||
|
||||
$p = self::factory()->post->create( array(
|
||||
'post_name' => '2015',
|
||||
) );
|
||||
$p = self::factory()->post->create(
|
||||
array(
|
||||
'post_name' => '2015',
|
||||
)
|
||||
);
|
||||
|
||||
$found = get_sample_permalink( $p );
|
||||
$this->assertEquals( '2015', $found[1] );
|
||||
@@ -466,9 +522,11 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
|
||||
public function test_get_sample_permalink_should_avoid_slugs_that_would_create_clashes_with_month_archives() {
|
||||
$this->set_permalink_structure( '/%year%/%postname%/' );
|
||||
|
||||
$p = self::factory()->post->create( array(
|
||||
'post_name' => '11',
|
||||
) );
|
||||
$p = self::factory()->post->create(
|
||||
array(
|
||||
'post_name' => '11',
|
||||
)
|
||||
);
|
||||
|
||||
$found = get_sample_permalink( $p );
|
||||
$this->assertEquals( '11-2', $found[1] );
|
||||
@@ -480,9 +538,11 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
|
||||
public function test_get_sample_permalink_should_ignore_potential_month_conflicts_for_invalid_monthnum() {
|
||||
$this->set_permalink_structure( '/%year%/%postname%/' );
|
||||
|
||||
$p = self::factory()->post->create( array(
|
||||
'post_name' => '13',
|
||||
) );
|
||||
$p = self::factory()->post->create(
|
||||
array(
|
||||
'post_name' => '13',
|
||||
)
|
||||
);
|
||||
|
||||
$found = get_sample_permalink( $p );
|
||||
$this->assertEquals( '13', $found[1] );
|
||||
@@ -494,9 +554,11 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
|
||||
public function test_get_sample_permalink_should_avoid_slugs_that_would_create_clashes_with_day_archives() {
|
||||
$this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' );
|
||||
|
||||
$p = self::factory()->post->create( array(
|
||||
'post_name' => '30',
|
||||
) );
|
||||
$p = self::factory()->post->create(
|
||||
array(
|
||||
'post_name' => '30',
|
||||
)
|
||||
);
|
||||
|
||||
$found = get_sample_permalink( $p );
|
||||
$this->assertEquals( '30-2', $found[1] );
|
||||
@@ -508,13 +570,17 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
|
||||
public function test_get_sample_permalink_should_iterate_slug_suffix_when_a_date_conflict_is_found() {
|
||||
$this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' );
|
||||
|
||||
self::factory()->post->create( array(
|
||||
'post_name' => '30-2',
|
||||
) );
|
||||
self::factory()->post->create(
|
||||
array(
|
||||
'post_name' => '30-2',
|
||||
)
|
||||
);
|
||||
|
||||
$p = self::factory()->post->create( array(
|
||||
'post_name' => '30',
|
||||
) );
|
||||
$p = self::factory()->post->create(
|
||||
array(
|
||||
'post_name' => '30',
|
||||
)
|
||||
);
|
||||
|
||||
$found = get_sample_permalink( $p );
|
||||
$this->assertEquals( '30-3', $found[1] );
|
||||
@@ -526,9 +592,11 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
|
||||
public function test_get_sample_permalink_should_ignore_potential_day_conflicts_for_invalid_day() {
|
||||
$this->set_permalink_structure( '/%year%/%monthnum%/%postname%/' );
|
||||
|
||||
$p = self::factory()->post->create( array(
|
||||
'post_name' => '32',
|
||||
) );
|
||||
$p = self::factory()->post->create(
|
||||
array(
|
||||
'post_name' => '32',
|
||||
)
|
||||
);
|
||||
|
||||
$found = get_sample_permalink( $p );
|
||||
$this->assertEquals( '32', $found[1] );
|
||||
@@ -540,9 +608,11 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
|
||||
public function test_get_sample_permalink_should_allow_daylike_slugs_if_permastruct_does_not_cause_an_archive_conflict() {
|
||||
$this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
|
||||
|
||||
$p = self::factory()->post->create( array(
|
||||
'post_name' => '30',
|
||||
) );
|
||||
$p = self::factory()->post->create(
|
||||
array(
|
||||
'post_name' => '30',
|
||||
)
|
||||
);
|
||||
|
||||
$found = get_sample_permalink( $p );
|
||||
$this->assertEquals( '30', $found[1] );
|
||||
@@ -554,17 +624,21 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
|
||||
public function test_get_sample_permalink_should_respect_hierarchy_of_draft_pages() {
|
||||
$this->set_permalink_structure( '/%postname%/' );
|
||||
|
||||
$parent = self::factory()->post->create( array(
|
||||
'post_type' => 'page',
|
||||
'post_title' => 'Parent Page',
|
||||
) );
|
||||
$parent = self::factory()->post->create(
|
||||
array(
|
||||
'post_type' => 'page',
|
||||
'post_title' => 'Parent Page',
|
||||
)
|
||||
);
|
||||
|
||||
$child = self::factory()->post->create( array(
|
||||
'post_type' => 'page',
|
||||
'post_title' => 'Child Page',
|
||||
'post_parent' => $parent,
|
||||
'post_status' => 'draft',
|
||||
) );
|
||||
$child = self::factory()->post->create(
|
||||
array(
|
||||
'post_type' => 'page',
|
||||
'post_title' => 'Child Page',
|
||||
'post_parent' => $parent,
|
||||
'post_status' => 'draft',
|
||||
)
|
||||
);
|
||||
|
||||
$actual = get_sample_permalink( $child );
|
||||
$this->assertSame( home_url() . '/parent-page/%pagename%/', $actual[0] );
|
||||
@@ -572,28 +646,34 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
public function test_post_exists_should_match_title() {
|
||||
$p = self::factory()->post->create( array(
|
||||
'post_title' => 'Foo Bar',
|
||||
) );
|
||||
$p = self::factory()->post->create(
|
||||
array(
|
||||
'post_title' => 'Foo Bar',
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertSame( $p, post_exists( 'Foo Bar' ) );
|
||||
}
|
||||
|
||||
public function test_post_exists_should_not_match_nonexistent_title() {
|
||||
$p = self::factory()->post->create( array(
|
||||
'post_title' => 'Foo Bar',
|
||||
) );
|
||||
$p = self::factory()->post->create(
|
||||
array(
|
||||
'post_title' => 'Foo Bar',
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertSame( 0, post_exists( 'Foo Bar Baz' ) );
|
||||
}
|
||||
|
||||
public function test_post_exists_should_match_nonempty_content() {
|
||||
$title = 'Foo Bar';
|
||||
$title = 'Foo Bar';
|
||||
$content = 'Foo Bar Baz';
|
||||
$p = self::factory()->post->create( array(
|
||||
'post_title' => $title,
|
||||
'post_content' => $content,
|
||||
) );
|
||||
$p = self::factory()->post->create(
|
||||
array(
|
||||
'post_title' => $title,
|
||||
'post_content' => $content,
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertSame( $p, post_exists( $title, $content ) );
|
||||
}
|
||||
@@ -602,58 +682,68 @@ class Tests_Admin_Includes_Post extends WP_UnitTestCase {
|
||||
* @ticket 35246
|
||||
*/
|
||||
public function test_post_exists_should_match_content_with_no_title() {
|
||||
$title = '';
|
||||
$title = '';
|
||||
$content = 'Foo Bar Baz';
|
||||
$p = self::factory()->post->create( array(
|
||||
'post_title' => $title,
|
||||
'post_content' => $content,
|
||||
) );
|
||||
$p = self::factory()->post->create(
|
||||
array(
|
||||
'post_title' => $title,
|
||||
'post_content' => $content,
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertSame( $p, post_exists( $title, $content ) );
|
||||
}
|
||||
|
||||
public function test_post_exists_should_not_match_when_nonempty_content_doesnt_match() {
|
||||
$title = 'Foo Bar';
|
||||
$title = 'Foo Bar';
|
||||
$content = 'Foo Bar Baz';
|
||||
$p = self::factory()->post->create( array(
|
||||
'post_title' => $title,
|
||||
'post_content' => $content . ' Quz',
|
||||
) );
|
||||
$p = self::factory()->post->create(
|
||||
array(
|
||||
'post_title' => $title,
|
||||
'post_content' => $content . ' Quz',
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertSame( 0, post_exists( $title, $content ) );
|
||||
}
|
||||
|
||||
public function test_post_exists_should_match_nonempty_date() {
|
||||
$title = 'Foo Bar';
|
||||
$date = '2014-05-08 12:00:00';
|
||||
$p = self::factory()->post->create( array(
|
||||
'post_title' => $title,
|
||||
'post_date' => $date,
|
||||
) );
|
||||
$date = '2014-05-08 12:00:00';
|
||||
$p = self::factory()->post->create(
|
||||
array(
|
||||
'post_title' => $title,
|
||||
'post_date' => $date,
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertSame( $p, post_exists( $title, '', $date ) );
|
||||
}
|
||||
|
||||
public function test_post_exists_should_not_match_when_nonempty_date_doesnt_match() {
|
||||
$title = 'Foo Bar';
|
||||
$date = '2014-05-08 12:00:00';
|
||||
$p = self::factory()->post->create( array(
|
||||
'post_title' => $title,
|
||||
'post_date' => '2015-10-10 00:00:00',
|
||||
) );
|
||||
$date = '2014-05-08 12:00:00';
|
||||
$p = self::factory()->post->create(
|
||||
array(
|
||||
'post_title' => $title,
|
||||
'post_date' => '2015-10-10 00:00:00',
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertSame( 0, post_exists( $title, '', $date ) );
|
||||
}
|
||||
|
||||
public function test_post_exists_should_match_nonempty_title_content_and_date() {
|
||||
$title = 'Foo Bar';
|
||||
$title = 'Foo Bar';
|
||||
$content = 'Foo Bar Baz';
|
||||
$date = '2014-05-08 12:00:00';
|
||||
$p = self::factory()->post->create( array(
|
||||
'post_title' => $title,
|
||||
'post_content' => $content,
|
||||
'post_date' => $date,
|
||||
) );
|
||||
$date = '2014-05-08 12:00:00';
|
||||
$p = self::factory()->post->create(
|
||||
array(
|
||||
'post_title' => $title,
|
||||
'post_content' => $content,
|
||||
'post_date' => $date,
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertSame( $p, post_exists( $title, $content, $date ) );
|
||||
}
|
||||
|
||||
@@ -6,31 +6,122 @@
|
||||
*/
|
||||
class Tests_Admin_includesScreen extends WP_UnitTestCase {
|
||||
var $core_screens = array(
|
||||
'index.php' => array( 'base' => 'dashboard', 'id' => 'dashboard' ),
|
||||
'edit.php' => array( 'base' => 'edit', 'id' => 'edit-post', 'post_type' => 'post' ),
|
||||
'post-new.php'=> array( 'action' => 'add', 'base' => 'post', 'id' => 'post', 'post_type' => 'post' ),
|
||||
'edit-tags.php' => array( 'base' => 'edit-tags', 'id' => 'edit-post_tag', 'post_type' => 'post', 'taxonomy' => 'post_tag' ),
|
||||
'edit-tags.php?taxonomy=post_tag' => array( 'base' => 'edit-tags', 'id' => 'edit-post_tag', 'post_type' => 'post', 'taxonomy' => 'post_tag' ),
|
||||
'edit-tags.php?taxonomy=category' => array( 'base' => 'edit-tags', 'id' => 'edit-category', 'post_type' => 'post', 'taxonomy' => 'category' ),
|
||||
'upload.php' => array( 'base' => 'upload', 'id' => 'upload', 'post_type' => 'attachment' ),
|
||||
'media-new.php' => array( 'action' => 'add', 'base' => 'media', 'id' => 'media' ),
|
||||
'edit.php?post_type=page' => array( 'base' => 'edit', 'id' => 'edit-page', 'post_type' => 'page' ),
|
||||
'link-manager.php' => array( 'base' => 'link-manager', 'id' => 'link-manager' ),
|
||||
'link-add.php' => array( 'action' => 'add', 'base' => 'link', 'id' => 'link' ),
|
||||
'edit-tags.php?taxonomy=link_category' => array( 'base' => 'edit-tags', 'id' => 'edit-link_category', 'taxonomy' => 'link_category', 'post_type' => '' ),
|
||||
'edit-comments.php' => array( 'base' => 'edit-comments', 'id' => 'edit-comments' ),
|
||||
'themes.php' => array( 'base' => 'themes', 'id' => 'themes' ),
|
||||
'widgets.php' => array( 'base' => 'widgets', 'id' => 'widgets' ),
|
||||
'nav-menus.php' => array( 'base' => 'nav-menus', 'id' => 'nav-menus' ),
|
||||
'plugins.php' => array( 'base' => 'plugins', 'id' => 'plugins' ),
|
||||
'users.php' => array( 'base' => 'users', 'id' => 'users' ),
|
||||
'user-new.php' => array( 'action' => 'add', 'base' => 'user', 'id' => 'user' ),
|
||||
'profile.php' => array( 'base' => 'profile', 'id' => 'profile' ),
|
||||
'tools.php' => array( 'base' => 'tools', 'id' => 'tools' ),
|
||||
'import.php' => array( 'base' => 'import', 'id' => 'import' ),
|
||||
'export.php' => array( 'base' => 'export', 'id' => 'export' ),
|
||||
'options-general.php' => array( 'base' => 'options-general', 'id' => 'options-general' ),
|
||||
'options-writing.php' => array( 'base' => 'options-writing', 'id' => 'options-writing' ),
|
||||
'index.php' => array(
|
||||
'base' => 'dashboard',
|
||||
'id' => 'dashboard',
|
||||
),
|
||||
'edit.php' => array(
|
||||
'base' => 'edit',
|
||||
'id' => 'edit-post',
|
||||
'post_type' => 'post',
|
||||
),
|
||||
'post-new.php' => array(
|
||||
'action' => 'add',
|
||||
'base' => 'post',
|
||||
'id' => 'post',
|
||||
'post_type' => 'post',
|
||||
),
|
||||
'edit-tags.php' => array(
|
||||
'base' => 'edit-tags',
|
||||
'id' => 'edit-post_tag',
|
||||
'post_type' => 'post',
|
||||
'taxonomy' => 'post_tag',
|
||||
),
|
||||
'edit-tags.php?taxonomy=post_tag' => array(
|
||||
'base' => 'edit-tags',
|
||||
'id' => 'edit-post_tag',
|
||||
'post_type' => 'post',
|
||||
'taxonomy' => 'post_tag',
|
||||
),
|
||||
'edit-tags.php?taxonomy=category' => array(
|
||||
'base' => 'edit-tags',
|
||||
'id' => 'edit-category',
|
||||
'post_type' => 'post',
|
||||
'taxonomy' => 'category',
|
||||
),
|
||||
'upload.php' => array(
|
||||
'base' => 'upload',
|
||||
'id' => 'upload',
|
||||
'post_type' => 'attachment',
|
||||
),
|
||||
'media-new.php' => array(
|
||||
'action' => 'add',
|
||||
'base' => 'media',
|
||||
'id' => 'media',
|
||||
),
|
||||
'edit.php?post_type=page' => array(
|
||||
'base' => 'edit',
|
||||
'id' => 'edit-page',
|
||||
'post_type' => 'page',
|
||||
),
|
||||
'link-manager.php' => array(
|
||||
'base' => 'link-manager',
|
||||
'id' => 'link-manager',
|
||||
),
|
||||
'link-add.php' => array(
|
||||
'action' => 'add',
|
||||
'base' => 'link',
|
||||
'id' => 'link',
|
||||
),
|
||||
'edit-tags.php?taxonomy=link_category' => array(
|
||||
'base' => 'edit-tags',
|
||||
'id' => 'edit-link_category',
|
||||
'taxonomy' => 'link_category',
|
||||
'post_type' => '',
|
||||
),
|
||||
'edit-comments.php' => array(
|
||||
'base' => 'edit-comments',
|
||||
'id' => 'edit-comments',
|
||||
),
|
||||
'themes.php' => array(
|
||||
'base' => 'themes',
|
||||
'id' => 'themes',
|
||||
),
|
||||
'widgets.php' => array(
|
||||
'base' => 'widgets',
|
||||
'id' => 'widgets',
|
||||
),
|
||||
'nav-menus.php' => array(
|
||||
'base' => 'nav-menus',
|
||||
'id' => 'nav-menus',
|
||||
),
|
||||
'plugins.php' => array(
|
||||
'base' => 'plugins',
|
||||
'id' => 'plugins',
|
||||
),
|
||||
'users.php' => array(
|
||||
'base' => 'users',
|
||||
'id' => 'users',
|
||||
),
|
||||
'user-new.php' => array(
|
||||
'action' => 'add',
|
||||
'base' => 'user',
|
||||
'id' => 'user',
|
||||
),
|
||||
'profile.php' => array(
|
||||
'base' => 'profile',
|
||||
'id' => 'profile',
|
||||
),
|
||||
'tools.php' => array(
|
||||
'base' => 'tools',
|
||||
'id' => 'tools',
|
||||
),
|
||||
'import.php' => array(
|
||||
'base' => 'import',
|
||||
'id' => 'import',
|
||||
),
|
||||
'export.php' => array(
|
||||
'base' => 'export',
|
||||
'id' => 'export',
|
||||
),
|
||||
'options-general.php' => array(
|
||||
'base' => 'options-general',
|
||||
'id' => 'options-general',
|
||||
),
|
||||
'options-writing.php' => array(
|
||||
'base' => 'options-writing',
|
||||
'id' => 'options-writing',
|
||||
),
|
||||
);
|
||||
|
||||
function setUp() {
|
||||
@@ -47,19 +138,21 @@ class Tests_Admin_includesScreen extends WP_UnitTestCase {
|
||||
global $current_screen;
|
||||
|
||||
foreach ( $this->core_screens as $hook_name => $screen ) {
|
||||
$_GET = $_POST = $_REQUEST = array();
|
||||
$_GET = $_POST = $_REQUEST = array();
|
||||
$GLOBALS['taxnow'] = $GLOBALS['typenow'] = '';
|
||||
$screen = (object) $screen;
|
||||
$hook = parse_url( $hook_name );
|
||||
$screen = (object) $screen;
|
||||
$hook = parse_url( $hook_name );
|
||||
|
||||
if ( ! empty( $hook['query'] ) ) {
|
||||
$args = wp_parse_args( $hook['query'] );
|
||||
if ( isset( $args['taxonomy'] ) )
|
||||
if ( isset( $args['taxonomy'] ) ) {
|
||||
$GLOBALS['taxnow'] = $_GET['taxonomy'] = $_POST['taxonomy'] = $_REQUEST['taxonomy'] = $args['taxonomy'];
|
||||
if ( isset( $args['post_type'] ) )
|
||||
}
|
||||
if ( isset( $args['post_type'] ) ) {
|
||||
$GLOBALS['typenow'] = $_GET['post_type'] = $_POST['post_type'] = $_REQUEST['post_type'] = $args['post_type'];
|
||||
else if ( isset( $screen->post_type ) )
|
||||
} elseif ( isset( $screen->post_type ) ) {
|
||||
$GLOBALS['typenow'] = $_GET['post_type'] = $_POST['post_type'] = $_REQUEST['post_type'] = $screen->post_type;
|
||||
}
|
||||
}
|
||||
|
||||
$GLOBALS['hook_suffix'] = $hook['path'];
|
||||
@@ -67,14 +160,17 @@ class Tests_Admin_includesScreen extends WP_UnitTestCase {
|
||||
|
||||
$this->assertEquals( $screen->id, $current_screen->id, $hook_name );
|
||||
$this->assertEquals( $screen->base, $current_screen->base, $hook_name );
|
||||
if ( isset( $screen->action ) )
|
||||
if ( isset( $screen->action ) ) {
|
||||
$this->assertEquals( $screen->action, $current_screen->action, $hook_name );
|
||||
if ( isset( $screen->post_type ) )
|
||||
}
|
||||
if ( isset( $screen->post_type ) ) {
|
||||
$this->assertEquals( $screen->post_type, $current_screen->post_type, $hook_name );
|
||||
else
|
||||
} else {
|
||||
$this->assertEmpty( $current_screen->post_type, $hook_name );
|
||||
if ( isset( $screen->taxonomy ) )
|
||||
}
|
||||
if ( isset( $screen->taxonomy ) ) {
|
||||
$this->assertEquals( $screen->taxonomy, $current_screen->taxonomy, $hook_name );
|
||||
}
|
||||
|
||||
$this->assertTrue( $current_screen->in_admin() );
|
||||
$this->assertTrue( $current_screen->in_admin( 'site' ) );
|
||||
@@ -87,8 +183,9 @@ class Tests_Admin_includesScreen extends WP_UnitTestCase {
|
||||
|
||||
// With convert_to_screen(), the hook_suffix should return the exact $current_screen.
|
||||
// But, convert_to_screen() cannot figure out ?taxonomy and ?post_type.
|
||||
if ( empty( $hook['query'] ) )
|
||||
if ( empty( $hook['query'] ) ) {
|
||||
$this->assertSame( $current_screen, convert_to_screen( $GLOBALS['hook_suffix'] ), $hook_name );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,23 +251,25 @@ class Tests_Admin_includesScreen extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
function test_help_tabs() {
|
||||
$tab = __FUNCTION__;
|
||||
$tab = __FUNCTION__;
|
||||
$tab_args = array(
|
||||
'id' => $tab,
|
||||
'title' => 'Help!',
|
||||
'content' => 'Some content',
|
||||
'id' => $tab,
|
||||
'title' => 'Help!',
|
||||
'content' => 'Some content',
|
||||
'callback' => false,
|
||||
);
|
||||
|
||||
$screen = get_current_screen();
|
||||
$screen->add_help_tab( $tab_args );
|
||||
$this->assertEquals( $screen->get_help_tab( $tab ), array(
|
||||
'id' => $tab,
|
||||
'title' => 'Help!',
|
||||
'content' => 'Some content',
|
||||
'callback' => false,
|
||||
'priority' => 10,
|
||||
) );
|
||||
$this->assertEquals(
|
||||
$screen->get_help_tab( $tab ), array(
|
||||
'id' => $tab,
|
||||
'title' => 'Help!',
|
||||
'content' => 'Some content',
|
||||
'callback' => false,
|
||||
'priority' => 10,
|
||||
)
|
||||
);
|
||||
|
||||
$tabs = $screen->get_help_tabs();
|
||||
$this->assertArrayHasKey( $tab, $tabs );
|
||||
@@ -235,7 +334,7 @@ class Tests_Admin_includesScreen extends WP_UnitTestCase {
|
||||
|
||||
$screen->add_help_tab( $tab_4_args );
|
||||
// Priority is added with the default for future calls
|
||||
$tab_4_args[ 'priority' ] = 10;
|
||||
$tab_4_args['priority'] = 10;
|
||||
$this->assertEquals( $screen->get_help_tab( $tab_4 ), $tab_4_args );
|
||||
|
||||
$tabs = $screen->get_help_tabs();
|
||||
@@ -247,12 +346,14 @@ class Tests_Admin_includesScreen extends WP_UnitTestCase {
|
||||
|
||||
// Test priority order.
|
||||
|
||||
$this->assertSame( array(
|
||||
$tab_2 => $tab_2_args,
|
||||
$tab_1 => $tab_1_args,
|
||||
$tab_4 => $tab_4_args,
|
||||
$tab_3 => $tab_3_args,
|
||||
), $tabs );
|
||||
$this->assertSame(
|
||||
array(
|
||||
$tab_2 => $tab_2_args,
|
||||
$tab_1 => $tab_1_args,
|
||||
$tab_4 => $tab_4_args,
|
||||
$tab_3 => $tab_3_args,
|
||||
), $tabs
|
||||
);
|
||||
|
||||
$screen->remove_help_tab( $tab_1 );
|
||||
$this->assertNull( $screen->get_help_tab( $tab_1 ) );
|
||||
@@ -278,11 +379,11 @@ class Tests_Admin_includesScreen extends WP_UnitTestCase {
|
||||
* @ticket 25799
|
||||
*/
|
||||
function test_options() {
|
||||
$option = __FUNCTION__;
|
||||
$option = __FUNCTION__;
|
||||
$option_args = array(
|
||||
'label' => 'Option',
|
||||
'default' => 10,
|
||||
'option' => $option
|
||||
'option' => $option,
|
||||
);
|
||||
|
||||
$screen = get_current_screen();
|
||||
|
||||
@@ -4,53 +4,53 @@
|
||||
*/
|
||||
class Tests_Admin_includesTemplate extends WP_UnitTestCase {
|
||||
function test_equal() {
|
||||
$this->assertEquals(' selected=\'selected\'', selected('foo','foo',false));
|
||||
$this->assertEquals(' checked=\'checked\'', checked('foo','foo',false));
|
||||
$this->assertEquals( ' selected=\'selected\'', selected( 'foo', 'foo', false ) );
|
||||
$this->assertEquals( ' checked=\'checked\'', checked( 'foo', 'foo', false ) );
|
||||
|
||||
$this->assertEquals(' selected=\'selected\'', selected('1',1,false));
|
||||
$this->assertEquals(' checked=\'checked\'', checked('1',1,false));
|
||||
$this->assertEquals( ' selected=\'selected\'', selected( '1', 1, false ) );
|
||||
$this->assertEquals( ' checked=\'checked\'', checked( '1', 1, false ) );
|
||||
|
||||
$this->assertEquals(' selected=\'selected\'', selected('1',true,false));
|
||||
$this->assertEquals(' checked=\'checked\'', checked('1',true,false));
|
||||
$this->assertEquals( ' selected=\'selected\'', selected( '1', true, false ) );
|
||||
$this->assertEquals( ' checked=\'checked\'', checked( '1', true, false ) );
|
||||
|
||||
$this->assertEquals(' selected=\'selected\'', selected(1,1,false));
|
||||
$this->assertEquals(' checked=\'checked\'', checked(1,1,false));
|
||||
$this->assertEquals( ' selected=\'selected\'', selected( 1, 1, false ) );
|
||||
$this->assertEquals( ' checked=\'checked\'', checked( 1, 1, false ) );
|
||||
|
||||
$this->assertEquals(' selected=\'selected\'', selected(1,true,false));
|
||||
$this->assertEquals(' checked=\'checked\'', checked(1,true,false));
|
||||
$this->assertEquals( ' selected=\'selected\'', selected( 1, true, false ) );
|
||||
$this->assertEquals( ' checked=\'checked\'', checked( 1, true, false ) );
|
||||
|
||||
$this->assertEquals(' selected=\'selected\'', selected(true,true,false));
|
||||
$this->assertEquals(' checked=\'checked\'', checked(true,true,false));
|
||||
$this->assertEquals( ' selected=\'selected\'', selected( true, true, false ) );
|
||||
$this->assertEquals( ' checked=\'checked\'', checked( true, true, false ) );
|
||||
|
||||
$this->assertEquals(' selected=\'selected\'', selected('0',0,false));
|
||||
$this->assertEquals(' checked=\'checked\'', checked('0',0,false));
|
||||
$this->assertEquals( ' selected=\'selected\'', selected( '0', 0, false ) );
|
||||
$this->assertEquals( ' checked=\'checked\'', checked( '0', 0, false ) );
|
||||
|
||||
$this->assertEquals(' selected=\'selected\'', selected(0,0,false));
|
||||
$this->assertEquals(' checked=\'checked\'', checked(0,0,false));
|
||||
$this->assertEquals( ' selected=\'selected\'', selected( 0, 0, false ) );
|
||||
$this->assertEquals( ' checked=\'checked\'', checked( 0, 0, false ) );
|
||||
|
||||
$this->assertEquals(' selected=\'selected\'', selected('',false,false));
|
||||
$this->assertEquals(' checked=\'checked\'', checked('',false,false));
|
||||
$this->assertEquals( ' selected=\'selected\'', selected( '', false, false ) );
|
||||
$this->assertEquals( ' checked=\'checked\'', checked( '', false, false ) );
|
||||
|
||||
$this->assertEquals(' selected=\'selected\'', selected(false,false,false));
|
||||
$this->assertEquals(' checked=\'checked\'', checked(false,false,false));
|
||||
$this->assertEquals( ' selected=\'selected\'', selected( false, false, false ) );
|
||||
$this->assertEquals( ' checked=\'checked\'', checked( false, false, false ) );
|
||||
}
|
||||
|
||||
function test_notequal() {
|
||||
$this->assertEquals('', selected('0','',false));
|
||||
$this->assertEquals('', checked('0','',false));
|
||||
$this->assertEquals( '', selected( '0', '', false ) );
|
||||
$this->assertEquals( '', checked( '0', '', false ) );
|
||||
|
||||
$this->assertEquals('', selected(0,'',false));
|
||||
$this->assertEquals('', checked(0,'',false));
|
||||
$this->assertEquals( '', selected( 0, '', false ) );
|
||||
$this->assertEquals( '', checked( 0, '', false ) );
|
||||
|
||||
$this->assertEquals('', selected(0,false,false));
|
||||
$this->assertEquals('', checked(0,false,false));
|
||||
$this->assertEquals( '', selected( 0, false, false ) );
|
||||
$this->assertEquals( '', checked( 0, false, false ) );
|
||||
}
|
||||
|
||||
public function test_add_meta_box() {
|
||||
global $wp_meta_boxes;
|
||||
|
||||
add_meta_box( 'testbox1', 'Test Metabox', '__return_false', 'post' );
|
||||
|
||||
|
||||
$this->assertArrayHasKey( 'testbox1', $wp_meta_boxes['post']['advanced']['default'] );
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ class Tests_Admin_includesTemplate extends WP_UnitTestCase {
|
||||
// Add a meta box to three different post types
|
||||
add_meta_box( 'testbox1', 'Test Metabox', '__return_false', array( 'post', 'comment', 'attachment' ) );
|
||||
|
||||
$this->assertArrayHasKey( 'testbox1', $wp_meta_boxes['post']['advanced']['default'] );
|
||||
$this->assertArrayHasKey( 'testbox1', $wp_meta_boxes['post']['advanced']['default'] );
|
||||
$this->assertArrayHasKey( 'testbox1', $wp_meta_boxes['comment']['advanced']['default'] );
|
||||
$this->assertArrayHasKey( 'testbox1', $wp_meta_boxes['attachment']['advanced']['default'] );
|
||||
}
|
||||
@@ -108,4 +108,4 @@ class Tests_Admin_includesTemplate extends WP_UnitTestCase {
|
||||
$this->assertFalse( $wp_meta_boxes['attachment']['advanced']['default']['testbox1'] );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,12 +8,12 @@ class Tests_Admin_includesTheme extends WP_UnitTestCase {
|
||||
parent::setUp();
|
||||
$this->theme_root = DIR_TESTDATA . '/themedir1';
|
||||
|
||||
$this->orig_theme_dir = $GLOBALS['wp_theme_directories'];
|
||||
$this->orig_theme_dir = $GLOBALS['wp_theme_directories'];
|
||||
$GLOBALS['wp_theme_directories'] = array( WP_CONTENT_DIR . '/themes', $this->theme_root );
|
||||
|
||||
add_filter('theme_root', array($this, '_theme_root'));
|
||||
add_filter( 'stylesheet_root', array($this, '_theme_root') );
|
||||
add_filter( 'template_root', array($this, '_theme_root') );
|
||||
add_filter( 'theme_root', array( $this, '_theme_root' ) );
|
||||
add_filter( 'stylesheet_root', array( $this, '_theme_root' ) );
|
||||
add_filter( 'template_root', array( $this, '_theme_root' ) );
|
||||
|
||||
// clear caches
|
||||
wp_clean_themes_cache();
|
||||
@@ -22,9 +22,9 @@ class Tests_Admin_includesTheme extends WP_UnitTestCase {
|
||||
|
||||
function tearDown() {
|
||||
$GLOBALS['wp_theme_directories'] = $this->orig_theme_dir;
|
||||
remove_filter('theme_root', array($this, '_theme_root'));
|
||||
remove_filter( 'stylesheet_root', array($this, '_theme_root') );
|
||||
remove_filter( 'template_root', array($this, '_theme_root') );
|
||||
remove_filter( 'theme_root', array( $this, '_theme_root' ) );
|
||||
remove_filter( 'stylesheet_root', array( $this, '_theme_root' ) );
|
||||
remove_filter( 'template_root', array( $this, '_theme_root' ) );
|
||||
|
||||
wp_clean_themes_cache();
|
||||
unset( $GLOBALS['wp_themes'] );
|
||||
@@ -32,7 +32,7 @@ class Tests_Admin_includesTheme extends WP_UnitTestCase {
|
||||
}
|
||||
|
||||
// replace the normal theme root dir with our premade test dir
|
||||
function _theme_root($dir) {
|
||||
function _theme_root( $dir ) {
|
||||
return $this->theme_root;
|
||||
}
|
||||
|
||||
@@ -48,22 +48,26 @@ class Tests_Admin_includesTheme extends WP_UnitTestCase {
|
||||
|
||||
switch_theme( $theme['Template'], $theme['Stylesheet'] );
|
||||
|
||||
$this->assertEqualSetsWithIndex( array(
|
||||
'Top Level' => 'template-top-level.php',
|
||||
'Sub Dir' => 'subdir/template-sub-dir.php',
|
||||
'This Template Header Is On One Line' => 'template-header.php',
|
||||
), get_page_templates() );
|
||||
$this->assertEqualSetsWithIndex(
|
||||
array(
|
||||
'Top Level' => 'template-top-level.php',
|
||||
'Sub Dir' => 'subdir/template-sub-dir.php',
|
||||
'This Template Header Is On One Line' => 'template-header.php',
|
||||
), get_page_templates()
|
||||
);
|
||||
|
||||
$theme = wp_get_theme( 'page-templates' );
|
||||
$this->assertNotEmpty( $theme );
|
||||
|
||||
switch_theme( $theme['Template'], $theme['Stylesheet'] );
|
||||
|
||||
$this->assertEqualSetsWithIndex( array(
|
||||
'Top Level' => 'template-top-level.php',
|
||||
'Sub Dir' => 'subdir/template-sub-dir.php',
|
||||
'This Template Header Is On One Line' => 'template-header.php',
|
||||
), get_page_templates() );
|
||||
$this->assertEqualSetsWithIndex(
|
||||
array(
|
||||
'Top Level' => 'template-top-level.php',
|
||||
'Sub Dir' => 'subdir/template-sub-dir.php',
|
||||
'This Template Header Is On One Line' => 'template-header.php',
|
||||
), get_page_templates()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,14 +79,18 @@ class Tests_Admin_includesTheme extends WP_UnitTestCase {
|
||||
|
||||
switch_theme( $theme['Template'], $theme['Stylesheet'] );
|
||||
|
||||
$this->assertEqualSetsWithIndex( array(
|
||||
'Top Level' => 'template-top-level-post-types.php',
|
||||
'Sub Dir' => 'subdir/template-sub-dir-post-types.php',
|
||||
), get_page_templates( null, 'foo' ) );
|
||||
$this->assertEqualSetsWithIndex( array(
|
||||
'Top Level' => 'template-top-level-post-types.php',
|
||||
'Sub Dir' => 'subdir/template-sub-dir-post-types.php',
|
||||
), get_page_templates( null, 'post' ) );
|
||||
$this->assertEqualSetsWithIndex(
|
||||
array(
|
||||
'Top Level' => 'template-top-level-post-types.php',
|
||||
'Sub Dir' => 'subdir/template-sub-dir-post-types.php',
|
||||
), get_page_templates( null, 'foo' )
|
||||
);
|
||||
$this->assertEqualSetsWithIndex(
|
||||
array(
|
||||
'Top Level' => 'template-top-level-post-types.php',
|
||||
'Sub Dir' => 'subdir/template-sub-dir-post-types.php',
|
||||
), get_page_templates( null, 'post' )
|
||||
);
|
||||
$this->assertEquals( array(), get_page_templates( null, 'bar' ) );
|
||||
}
|
||||
|
||||
@@ -95,21 +103,25 @@ class Tests_Admin_includesTheme extends WP_UnitTestCase {
|
||||
|
||||
switch_theme( $theme['Template'], $theme['Stylesheet'] );
|
||||
|
||||
$this->assertEqualSetsWithIndex( array(
|
||||
'No Trailing Period' => '38766/no-trailing-period-post-types.php',
|
||||
'Trailing Period.' => '38766/trailing-period-post-types.php',
|
||||
'Trailing Comma,' => '38766/trailing-comma-post-types.php',
|
||||
'Trailing Period, White Space.' => '38766/trailing-period-whitespace-post-types.php',
|
||||
'Trailing White Space, Period.' => '38766/trailing-whitespace-period-post-types.php',
|
||||
'Tilde in Post Type.' => '38766/tilde-post-types.php',
|
||||
), get_page_templates( null, 'period' ) );
|
||||
$this->assertEqualSetsWithIndex( array(
|
||||
'No Trailing Period' => '38766/no-trailing-period-post-types.php',
|
||||
'Trailing Period.' => '38766/trailing-period-post-types.php',
|
||||
'Trailing Comma,' => '38766/trailing-comma-post-types.php',
|
||||
'Trailing Period, White Space.' => '38766/trailing-period-whitespace-post-types.php',
|
||||
'Trailing White Space, Period.' => '38766/trailing-whitespace-period-post-types.php',
|
||||
), get_page_templates( null, 'full-stop' ) );
|
||||
$this->assertEqualSetsWithIndex(
|
||||
array(
|
||||
'No Trailing Period' => '38766/no-trailing-period-post-types.php',
|
||||
'Trailing Period.' => '38766/trailing-period-post-types.php',
|
||||
'Trailing Comma,' => '38766/trailing-comma-post-types.php',
|
||||
'Trailing Period, White Space.' => '38766/trailing-period-whitespace-post-types.php',
|
||||
'Trailing White Space, Period.' => '38766/trailing-whitespace-period-post-types.php',
|
||||
'Tilde in Post Type.' => '38766/tilde-post-types.php',
|
||||
), get_page_templates( null, 'period' )
|
||||
);
|
||||
$this->assertEqualSetsWithIndex(
|
||||
array(
|
||||
'No Trailing Period' => '38766/no-trailing-period-post-types.php',
|
||||
'Trailing Period.' => '38766/trailing-period-post-types.php',
|
||||
'Trailing Comma,' => '38766/trailing-comma-post-types.php',
|
||||
'Trailing Period, White Space.' => '38766/trailing-period-whitespace-post-types.php',
|
||||
'Trailing White Space, Period.' => '38766/trailing-whitespace-period-post-types.php',
|
||||
), get_page_templates( null, 'full-stop' )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,23 +133,29 @@ class Tests_Admin_includesTheme extends WP_UnitTestCase {
|
||||
|
||||
switch_theme( $theme['Template'], $theme['Stylesheet'] );
|
||||
|
||||
$this->assertEqualSetsWithIndex( array(
|
||||
'Top Level' => 'template-top-level-post-types.php',
|
||||
'Sub Dir' => 'subdir/template-sub-dir-post-types.php',
|
||||
'Top Level In A Child Theme' => 'template-top-level-post-types-child.php',
|
||||
'Sub Dir In A Child Theme' => 'subdir/template-sub-dir-post-types-child.php',
|
||||
), get_page_templates( null, 'foo' ) );
|
||||
$this->assertEqualSetsWithIndex(
|
||||
array(
|
||||
'Top Level' => 'template-top-level-post-types.php',
|
||||
'Sub Dir' => 'subdir/template-sub-dir-post-types.php',
|
||||
'Top Level In A Child Theme' => 'template-top-level-post-types-child.php',
|
||||
'Sub Dir In A Child Theme' => 'subdir/template-sub-dir-post-types-child.php',
|
||||
), get_page_templates( null, 'foo' )
|
||||
);
|
||||
|
||||
$this->assertEqualSetsWithIndex( array(
|
||||
'Top Level' => 'template-top-level-post-types.php',
|
||||
'Sub Dir' => 'subdir/template-sub-dir-post-types.php',
|
||||
), get_page_templates( null, 'post' ) );
|
||||
$this->assertEqualSetsWithIndex(
|
||||
array(
|
||||
'Top Level' => 'template-top-level-post-types.php',
|
||||
'Sub Dir' => 'subdir/template-sub-dir-post-types.php',
|
||||
), get_page_templates( null, 'post' )
|
||||
);
|
||||
|
||||
$this->assertEqualSetsWithIndex( array(
|
||||
'Top Level' => 'template-top-level.php',
|
||||
'Sub Dir' => 'subdir/template-sub-dir.php',
|
||||
'This Template Header Is On One Line' => 'template-header.php',
|
||||
), get_page_templates() );
|
||||
$this->assertEqualSetsWithIndex(
|
||||
array(
|
||||
'Top Level' => 'template-top-level.php',
|
||||
'Sub Dir' => 'subdir/template-sub-dir.php',
|
||||
'This Template Header Is On One Line' => 'template-header.php',
|
||||
), get_page_templates()
|
||||
);
|
||||
|
||||
$this->assertEquals( array(), get_page_templates( null, 'bar' ) );
|
||||
}
|
||||
@@ -153,23 +171,29 @@ class Tests_Admin_includesTheme extends WP_UnitTestCase {
|
||||
|
||||
$post_templates = $theme->get_post_templates();
|
||||
|
||||
$this->assertEqualSetsWithIndex( array(
|
||||
'template-top-level-post-types.php' => 'Top Level',
|
||||
'subdir/template-sub-dir-post-types.php' => 'Sub Dir',
|
||||
'template-top-level-post-types-child.php' => 'Top Level In A Child Theme',
|
||||
'subdir/template-sub-dir-post-types-child.php' => 'Sub Dir In A Child Theme',
|
||||
), $post_templates['foo'] );
|
||||
$this->assertEqualSetsWithIndex(
|
||||
array(
|
||||
'template-top-level-post-types.php' => 'Top Level',
|
||||
'subdir/template-sub-dir-post-types.php' => 'Sub Dir',
|
||||
'template-top-level-post-types-child.php' => 'Top Level In A Child Theme',
|
||||
'subdir/template-sub-dir-post-types-child.php' => 'Sub Dir In A Child Theme',
|
||||
), $post_templates['foo']
|
||||
);
|
||||
|
||||
$this->assertEqualSetsWithIndex( array(
|
||||
'template-top-level-post-types.php' => 'Top Level',
|
||||
'subdir/template-sub-dir-post-types.php' => 'Sub Dir',
|
||||
), $post_templates['post'] );
|
||||
$this->assertEqualSetsWithIndex(
|
||||
array(
|
||||
'template-top-level-post-types.php' => 'Top Level',
|
||||
'subdir/template-sub-dir-post-types.php' => 'Sub Dir',
|
||||
), $post_templates['post']
|
||||
);
|
||||
|
||||
$this->assertEqualSetsWithIndex( array(
|
||||
'template-top-level.php' => 'Top Level',
|
||||
'subdir/template-sub-dir.php' => 'Sub Dir',
|
||||
'template-header.php' => 'This Template Header Is On One Line',
|
||||
), $post_templates['page'] );
|
||||
$this->assertEqualSetsWithIndex(
|
||||
array(
|
||||
'template-top-level.php' => 'Top Level',
|
||||
'subdir/template-sub-dir.php' => 'Sub Dir',
|
||||
'template-header.php' => 'This Template Header Is On One Line',
|
||||
), $post_templates['page']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user