<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[39189] trunk/tests/phpunit/tests: Build/Test Tools: Re-use a bunch of fixtures in test classes for user and XMLRPC tests.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/39189">39189</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/39189","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>johnbillion</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2016-11-10 01:53:08 +0000 (Thu, 10 Nov 2016)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Build/Test Tools: Re-use a bunch of fixtures in test classes for user and XMLRPC tests.
Shaves a couple of seconds off of the tests.
See <a href="https://core.trac.wordpress.org/ticket/30017">#30017</a>, <a href="https://core.trac.wordpress.org/ticket/38716">#38716</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunktestsphpunittestsuserauthorphp">trunk/tests/phpunit/tests/user/author.php</a></li>
<li><a href="#trunktestsphpunittestsusermapMetaCapphp">trunk/tests/phpunit/tests/user/mapMetaCap.php</a></li>
<li><a href="#trunktestsphpunittestsxmlrpcmwgetPostphp">trunk/tests/phpunit/tests/xmlrpc/mw/getPost.php</a></li>
<li><a href="#trunktestsphpunittestsxmlrpcmwgetRecentPostsphp">trunk/tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php</a></li>
<li><a href="#trunktestsphpunittestsxmlrpcwpdeleteTermphp">trunk/tests/phpunit/tests/xmlrpc/wp/deleteTerm.php</a></li>
<li><a href="#trunktestsphpunittestsxmlrpcwpeditTermphp">trunk/tests/phpunit/tests/xmlrpc/wp/editTerm.php</a></li>
<li><a href="#trunktestsphpunittestsxmlrpcwpgetCommentphp">trunk/tests/phpunit/tests/xmlrpc/wp/getComment.php</a></li>
<li><a href="#trunktestsphpunittestsxmlrpcwpgetMediaItemphp">trunk/tests/phpunit/tests/xmlrpc/wp/getMediaItem.php</a></li>
<li><a href="#trunktestsphpunittestsxmlrpcwpgetPagephp">trunk/tests/phpunit/tests/xmlrpc/wp/getPage.php</a></li>
<li><a href="#trunktestsphpunittestsxmlrpcwpgetPageListphp">trunk/tests/phpunit/tests/xmlrpc/wp/getPageList.php</a></li>
<li><a href="#trunktestsphpunittestsxmlrpcwpgetPagesphp">trunk/tests/phpunit/tests/xmlrpc/wp/getPages.php</a></li>
<li><a href="#trunktestsphpunittestsxmlrpcwpgetTermphp">trunk/tests/phpunit/tests/xmlrpc/wp/getTerm.php</a></li>
<li><a href="#trunktestsphpunittestsxmlrpcwpnewTermphp">trunk/tests/phpunit/tests/xmlrpc/wp/newTerm.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunktestsphpunittestsuserauthorphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/user/author.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/user/author.php 2016-11-09 22:59:02 UTC (rev 39188)
+++ trunk/tests/phpunit/tests/user/author.php 2016-11-10 01:53:08 UTC (rev 39189)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -7,33 +7,31 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @group user
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class Tests_User_Author_Template extends WP_UnitTestCase {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- protected $author_id = 0;
- protected $post_id = 0;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected static $author_id = 0;
+ protected static $post_id = 0;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> private $permalink_structure;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function setUp() {
- parent::setUp();
-
- $this->author_id = self::factory()->user->create( array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$author_id = $factory->user->create( array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'role' => 'author',
</span><span class="cx" style="display: block; padding: 0 10px"> 'user_login' => 'test_author',
</span><span class="cx" style="display: block; padding: 0 10px"> 'description' => 'test_author',
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user = new WP_User( $this->author_id );
</del><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post = array(
- 'post_author' => $this->author_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$post_id = $factory->post->create( array(
+ 'post_author' => self::$author_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'post_status' => 'publish',
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_content' => rand_str(),
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_title' => rand_str(),
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_type' => 'post'
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // insert a post and make sure the ID is ok
- $this->post_id = self::factory()->post->create( $post );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ function setUp() {
+ parent::setUp();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- setup_postdata( get_post( $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ setup_postdata( get_post( self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function tearDown() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -43,7 +41,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function test_get_the_author() {
</span><span class="cx" style="display: block; padding: 0 10px"> $author_name = get_the_author();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user = new WP_User( $this->author_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user = new WP_User( self::$author_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $user->display_name, $author_name );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 'test_author', $author_name );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -56,14 +54,14 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 'test_author', get_the_author_meta( 'description' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 'test_author', get_the_author_meta( 'user_description' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_user_meta( $this->author_id, 'user_description', 'user description' );
- $this->assertEquals( 'user description', get_user_meta( $this->author_id, 'user_description', true ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_user_meta( self::$author_id, 'user_description', 'user description' );
+ $this->assertEquals( 'user description', get_user_meta( self::$author_id, 'user_description', true ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> // user_description in meta is ignored. The content of description is returned instead.
</span><span class="cx" style="display: block; padding: 0 10px"> // See #20285
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 'test_author', get_the_author_meta( 'user_description' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 'test_author', get_the_author_meta( 'description' ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- update_user_meta( $this->author_id, 'user_description', '' );
- $this->assertEquals( '', get_user_meta( $this->author_id, 'user_description', true ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ update_user_meta( self::$author_id, 'user_description', '' );
+ $this->assertEquals( '', get_user_meta( self::$author_id, 'user_description', true ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 'test_author', get_the_author_meta( 'user_description' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 'test_author', get_the_author_meta( 'description' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -80,7 +78,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function test_get_the_author_posts() {
</span><span class="cx" style="display: block; padding: 0 10px"> // Test with no global post, result should be 0 because no author is found
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 0, get_the_author_posts() );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $GLOBALS['post'] = $this->post_id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $GLOBALS['post'] = self::$post_id;
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 1, get_the_author_posts() );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -91,7 +89,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> register_post_type( 'wptests_pt' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $cpt_ids = self::factory()->post->create_many( 2, array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_author' => $this->author_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post_author' => self::$author_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'post_type' => 'wptests_pt',
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $GLOBALS['post'] = $cpt_ids[0];
</span></span></pre></div>
<a id="trunktestsphpunittestsusermapMetaCapphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/user/mapMetaCap.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/user/mapMetaCap.php 2016-11-09 22:59:02 UTC (rev 39188)
+++ trunk/tests/phpunit/tests/user/mapMetaCap.php 2016-11-10 01:53:08 UTC (rev 39189)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -5,36 +5,35 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @group capabilities
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class Tests_User_MapMetaCap extends WP_UnitTestCase {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- var $super_admins = null;
</del><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function setUp() {
- parent::setUp();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected static $post_type = 'mapmetacap';
+ protected static $super_admins = null;
+ protected static $user_id = null;
+ protected static $author_id = null;
+ protected static $post_id = null;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->user_ids = array();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$user_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
+ self::$author_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->user_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
- $this->author_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
-
- if ( isset( $GLOBALS['super_admins'] ) )
- $this->super_admins = $GLOBALS['super_admins'];
- $user = new WP_User( $this->user_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( isset( $GLOBALS['super_admins'] ) ) {
+ self::$super_admins = $GLOBALS['super_admins'];
+ }
+ $user = new WP_User( self::$user_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $GLOBALS['super_admins'] = array( $user->user_login );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->post_type = rand_str( 20 );
- register_post_type( $this->post_type );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ register_post_type( self::$post_type );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->post_id = wp_insert_post( array(
- 'post_title' => rand_str(),
- 'post_type' => $this->post_type,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$post_id = $factory->post->create( array(
+ 'post_type' => self::$post_type,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'post_status' => 'private',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_author' => $this->author_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post_author' => self::$author_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function tearDown() {
- $GLOBALS['super_admins'] = $this->super_admins;
- unset( $GLOBALS['wp_post_types'][ $this->post_type ] );
- parent::tearDown();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpTearDownAfterClass() {
+ $GLOBALS['super_admins'] = self::$super_admins;
+ unset( $GLOBALS['wp_post_types'][ self::$post_type ] );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -43,87 +42,87 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function test_capability_type_post_with_invalid_id() {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals(
</span><span class="cx" style="display: block; padding: 0 10px"> array( 'do_not_allow' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- map_meta_cap( 'edit_post', $this->user_id, $this->post_id + 1 )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ map_meta_cap( 'edit_post', self::$user_id, self::$post_id + 1 )
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function test_capability_type_post_with_no_extra_caps() {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- register_post_type( $this->post_type, array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ register_post_type( self::$post_type, array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'capability_type' => 'post',
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post_type_object = get_post_type_object( $this->post_type );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post_type_object = get_post_type_object( self::$post_type );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue( $post_type_object->map_meta_cap );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( array( 'edit_others_posts', 'edit_private_posts' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- map_meta_cap( 'edit_post', $this->user_id, $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ map_meta_cap( 'edit_post', self::$user_id, self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( array( 'edit_others_posts', 'edit_private_posts' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- map_meta_cap( $post_type_object->cap->edit_post, $this->user_id, $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ map_meta_cap( $post_type_object->cap->edit_post, self::$user_id, self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( array( 'read_private_posts' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- map_meta_cap( 'read_post', $this->user_id, $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ map_meta_cap( 'read_post', self::$user_id, self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( array( 'read_private_posts' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- map_meta_cap( $post_type_object->cap->read_post, $this->user_id, $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ map_meta_cap( $post_type_object->cap->read_post, self::$user_id, self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( array( 'delete_others_posts', 'delete_private_posts' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- map_meta_cap( 'delete_post', $this->user_id, $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ map_meta_cap( 'delete_post', self::$user_id, self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( array( 'delete_others_posts', 'delete_private_posts' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- map_meta_cap( $post_type_object->cap->delete_post, $this->user_id, $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ map_meta_cap( $post_type_object->cap->delete_post, self::$user_id, self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function test_custom_capability_type_with_map_meta_cap() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- register_post_type( $this->post_type, array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ register_post_type( self::$post_type, array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'capability_type' => 'book',
</span><span class="cx" style="display: block; padding: 0 10px"> 'map_meta_cap' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post_type_object = get_post_type_object( $this->post_type );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post_type_object = get_post_type_object( self::$post_type );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( array( 'edit_others_books', 'edit_private_books' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- map_meta_cap( 'edit_post', $this->user_id, $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ map_meta_cap( 'edit_post', self::$user_id, self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( array( 'edit_others_books', 'edit_private_books' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- map_meta_cap( $post_type_object->cap->edit_post, $this->user_id, $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ map_meta_cap( $post_type_object->cap->edit_post, self::$user_id, self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( array( 'read_private_books' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- map_meta_cap( 'read_post', $this->user_id, $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ map_meta_cap( 'read_post', self::$user_id, self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( array( 'read_private_books' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- map_meta_cap( $post_type_object->cap->read_post, $this->user_id, $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ map_meta_cap( $post_type_object->cap->read_post, self::$user_id, self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( array( 'delete_others_books', 'delete_private_books' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- map_meta_cap( 'delete_post', $this->user_id, $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ map_meta_cap( 'delete_post', self::$user_id, self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( array( 'delete_others_books', 'delete_private_books' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- map_meta_cap( $post_type_object->cap->delete_post, $this->user_id, $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ map_meta_cap( $post_type_object->cap->delete_post, self::$user_id, self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function test_capability_type_post_with_one_renamed_cap() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- register_post_type( $this->post_type, array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ register_post_type( self::$post_type, array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'capability_type' => 'post',
</span><span class="cx" style="display: block; padding: 0 10px"> 'capabilities' => array( 'edit_posts' => 'edit_books' ),
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post_type_object = get_post_type_object( $this->post_type );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post_type_object = get_post_type_object( self::$post_type );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse( $post_type_object->map_meta_cap );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( array( 'edit_post' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- map_meta_cap( 'edit_post', $this->user_id, $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ map_meta_cap( 'edit_post', self::$user_id, self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( array( 'edit_post' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- map_meta_cap( $post_type_object->cap->edit_post, $this->user_id, $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ map_meta_cap( $post_type_object->cap->edit_post, self::$user_id, self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( array( 'read_post' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- map_meta_cap( 'read_post', $this->user_id, $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ map_meta_cap( 'read_post', self::$user_id, self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( array( 'read_post' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- map_meta_cap( $post_type_object->cap->read_post, $this->user_id, $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ map_meta_cap( $post_type_object->cap->read_post, self::$user_id, self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( array( 'delete_post' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- map_meta_cap( 'delete_post', $this->user_id, $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ map_meta_cap( 'delete_post', self::$user_id, self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( array( 'delete_post' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- map_meta_cap( $post_type_object->cap->delete_post, $this->user_id, $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ map_meta_cap( $post_type_object->cap->delete_post, self::$user_id, self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function test_capability_type_post_map_meta_cap_true_with_renamed_cap() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- register_post_type( $this->post_type, array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ register_post_type( self::$post_type, array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'capability_type' => 'post',
</span><span class="cx" style="display: block; padding: 0 10px"> 'map_meta_cap' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> 'capabilities' => array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -132,28 +131,28 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post_type_object = get_post_type_object( $this->post_type );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post_type_object = get_post_type_object( self::$post_type );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue( $post_type_object->map_meta_cap );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( array( 'edit_others_books', 'edit_private_posts' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- map_meta_cap( 'edit_post', $this->user_id, $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ map_meta_cap( 'edit_post', self::$user_id, self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( array( 'edit_others_books', 'edit_private_posts' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- map_meta_cap( $post_type_object->cap->edit_post, $this->user_id, $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ map_meta_cap( $post_type_object->cap->edit_post, self::$user_id, self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( array( 'read_private_posts' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- map_meta_cap( 'read_post', $this->user_id, $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ map_meta_cap( 'read_post', self::$user_id, self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( array( 'read_private_posts' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- map_meta_cap( $post_type_object->cap->read_post, $this->user_id, $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ map_meta_cap( $post_type_object->cap->read_post, self::$user_id, self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( array( 'delete_others_posts', 'delete_private_posts' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- map_meta_cap( 'delete_post', $this->user_id, $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ map_meta_cap( 'delete_post', self::$user_id, self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( array( 'delete_others_posts', 'delete_private_posts' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- map_meta_cap( $post_type_object->cap->delete_post, $this->user_id, $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ map_meta_cap( $post_type_object->cap->delete_post, self::$user_id, self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function test_capability_type_post_with_all_meta_caps_renamed() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- register_post_type( $this->post_type, array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ register_post_type( self::$post_type, array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'capability_type' => 'post',
</span><span class="cx" style="display: block; padding: 0 10px"> 'capabilities' => array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'edit_post' => 'edit_book',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -162,28 +161,28 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post_type_object = get_post_type_object( $this->post_type );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post_type_object = get_post_type_object( self::$post_type );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse( $post_type_object->map_meta_cap );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( array( 'edit_book' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- map_meta_cap( 'edit_post', $this->user_id, $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ map_meta_cap( 'edit_post', self::$user_id, self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( array( 'edit_book' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- map_meta_cap( $post_type_object->cap->edit_post, $this->user_id, $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ map_meta_cap( $post_type_object->cap->edit_post, self::$user_id, self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( array( 'read_book' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- map_meta_cap( 'read_post', $this->user_id, $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ map_meta_cap( 'read_post', self::$user_id, self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( array( 'read_book' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- map_meta_cap( $post_type_object->cap->read_post, $this->user_id, $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ map_meta_cap( $post_type_object->cap->read_post, self::$user_id, self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( array( 'delete_book' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- map_meta_cap( 'delete_post', $this->user_id, $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ map_meta_cap( 'delete_post', self::$user_id, self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( array( 'delete_book' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- map_meta_cap( $post_type_object->cap->delete_post, $this->user_id, $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ map_meta_cap( $post_type_object->cap->delete_post, self::$user_id, self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function test_capability_type_post_with_all_meta_caps_renamed_mapped() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- register_post_type( $this->post_type, array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ register_post_type( self::$post_type, array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'capability_type' => 'post',
</span><span class="cx" style="display: block; padding: 0 10px"> 'map_meta_cap' => true,
</span><span class="cx" style="display: block; padding: 0 10px"> 'capabilities' => array(
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -193,24 +192,24 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ),
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post_type_object = get_post_type_object( $this->post_type );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post_type_object = get_post_type_object( self::$post_type );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue( $post_type_object->map_meta_cap );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( array( 'edit_others_posts', 'edit_private_posts' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- map_meta_cap( 'edit_post', $this->user_id, $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ map_meta_cap( 'edit_post', self::$user_id, self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( array( 'edit_others_posts', 'edit_private_posts' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- map_meta_cap( $post_type_object->cap->edit_post, $this->user_id, $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ map_meta_cap( $post_type_object->cap->edit_post, self::$user_id, self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( array( 'read_private_posts' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- map_meta_cap( 'read_post', $this->user_id, $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ map_meta_cap( 'read_post', self::$user_id, self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( array( 'read_private_posts' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- map_meta_cap( $post_type_object->cap->read_post, $this->user_id, $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ map_meta_cap( $post_type_object->cap->read_post, self::$user_id, self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( array( 'delete_others_posts', 'delete_private_posts' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- map_meta_cap( 'delete_post', $this->user_id, $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ map_meta_cap( 'delete_post', self::$user_id, self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( array( 'delete_others_posts', 'delete_private_posts' ),
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- map_meta_cap( $post_type_object->cap->delete_post, $this->user_id, $this->post_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ map_meta_cap( $post_type_object->cap->delete_post, self::$user_id, self::$post_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function test_unfiltered_html_cap() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -218,9 +217,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->markTestSkipped( 'DISALLOW_UNFILTERED_HTML is defined.' );
</span><span class="cx" style="display: block; padding: 0 10px"> if ( is_multisite() ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( array( 'do_not_allow' ), map_meta_cap( 'unfiltered_html', 0 ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( array( 'unfiltered_html' ), map_meta_cap( 'unfiltered_html', $this->user_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( array( 'unfiltered_html' ), map_meta_cap( 'unfiltered_html', self::$user_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( array( 'unfiltered_html' ), map_meta_cap( 'unfiltered_html', $this->user_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( array( 'unfiltered_html' ), map_meta_cap( 'unfiltered_html', self::$user_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -238,8 +237,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> define( 'DISALLOW_UNFILTERED_HTML', true );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( array( 'update_core' ), map_meta_cap( 'update_core', $this->user_id ) );
- $this->assertEquals( array( 'edit_plugins' ), map_meta_cap( 'edit_plugins', $this->user_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( array( 'update_core' ), map_meta_cap( 'update_core', self::$user_id ) );
+ $this->assertEquals( array( 'edit_plugins' ), map_meta_cap( 'edit_plugins', self::$user_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -268,7 +267,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> update_option( 'page_on_front', $post_id );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $caps = map_meta_cap( 'delete_page', $this->user_id, $post_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $caps = map_meta_cap( 'delete_page', self::$user_id, $post_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> delete_option( 'page_on_front' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( array( 'manage_options' ), $caps );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -286,7 +285,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> update_option( 'page_for_posts', $post_id );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $caps = map_meta_cap( 'delete_page', $this->user_id, $post_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $caps = map_meta_cap( 'delete_page', self::$user_id, $post_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> delete_option( 'page_for_posts' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( array( 'manage_options' ), $caps );
</span></span></pre></div>
<a id="trunktestsphpunittestsxmlrpcmwgetPostphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/xmlrpc/mw/getPost.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/xmlrpc/mw/getPost.php 2016-11-09 22:59:02 UTC (rev 39188)
+++ trunk/tests/phpunit/tests/xmlrpc/mw/getPost.php 2016-11-10 01:53:08 UTC (rev 39189)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4,27 +4,21 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @group xmlrpc
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class Tests_XMLRPC_mw_getPost extends WP_XMLRPC_UnitTestCase {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- var $post_data;
- var $post_id;
- var $post_date_ts;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected static $post_id;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function setUp() {
- parent::setUp();
-
- $author_id = $this->make_user_by_role( 'author' );
- $this->post_date_ts = strtotime( '+1 day' );
- $this->post_data = array(
- 'post_title' => rand_str(),
- 'post_content' => rand_str( 2000 ),
- 'post_excerpt' => rand_str( 100 ),
- 'post_author' => $author_id,
- 'post_date' => strftime( "%Y-%m-%d %H:%M:%S", $this->post_date_ts ),
- );
- $this->post_id = wp_insert_post( $this->post_data );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$post_id = $factory->post->create( array(
+ 'post_author' => $factory->user->create( array(
+ 'user_login' => 'author',
+ 'user_pass' => 'author',
+ 'role' => 'author'
+ ) ),
+ 'post_date' => strftime( "%Y-%m-%d %H:%M:%S", strtotime( '+1 day' ) ),
+ ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function test_invalid_username_password() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = $this->myxmlrpcserver->mw_getPost( array( $this->post_id, 'username', 'password' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = $this->myxmlrpcserver->mw_getPost( array( self::$post_id, 'username', 'password' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertInstanceOf( 'IXR_Error', $result );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 403, $result->code );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -32,7 +26,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function test_incapable_user() {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->make_user_by_role( 'subscriber' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = $this->myxmlrpcserver->mw_getPost( array( $this->post_id, 'subscriber', 'subscriber' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = $this->myxmlrpcserver->mw_getPost( array( self::$post_id, 'subscriber', 'subscriber' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertInstanceOf( 'IXR_Error', $result );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 401, $result->code );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -50,7 +44,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> add_theme_support( 'post-thumbnails' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $fields = array( 'post' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = $this->myxmlrpcserver->mw_getPost( array( $this->post_id, 'author', 'author' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = $this->myxmlrpcserver->mw_getPost( array( self::$post_id, 'author', 'author' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotInstanceOf( 'IXR_Error', $result );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Check data types
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -76,14 +70,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertInternalType( 'string', $result['wp_post_format'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertInternalType( 'bool', $result['sticky'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post_data = get_post( self::$post_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Check expected values
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertStringMatchesFormat( '%d', $result['userid'] );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( $this->post_data['post_title'], $result['title'] );
- $this->assertEquals( 'draft', $result['post_status'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( $post_data->post_title, $result['title'] );
+ $this->assertEquals( 'publish', $result['post_status'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertStringMatchesFormat( '%d', $result['wp_author_id'] );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( $this->post_data['post_excerpt'], $result['mt_excerpt'] );
- $this->assertEquals( url_to_postid( $result['link'] ), $this->post_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( $post_data->post_excerpt, $result['mt_excerpt'] );
+ $this->assertEquals( url_to_postid( $result['link'] ), self::$post_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( '', $result['wp_post_thumbnail'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -97,10 +92,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $filename = ( DIR_TESTDATA.'/images/a2-small.jpg' );
</span><span class="cx" style="display: block; padding: 0 10px"> $attachment_id = self::factory()->attachment->create_upload_object( $filename );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- set_post_thumbnail( $this->post_id, $attachment_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ set_post_thumbnail( self::$post_id, $attachment_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $fields = array( 'post' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = $this->myxmlrpcserver->mw_getPost( array( $this->post_id, 'author', 'author' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = $this->myxmlrpcserver->mw_getPost( array( self::$post_id, 'author', 'author' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotInstanceOf( 'IXR_Error', $result );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertInternalType( 'string', $result['wp_post_thumbnail'] );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -112,7 +107,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function test_date() {
</span><span class="cx" style="display: block; padding: 0 10px"> $fields = array( 'post' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = $this->myxmlrpcserver->mw_getPost( array( $this->post_id, 'author', 'author' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = $this->myxmlrpcserver->mw_getPost( array( self::$post_id, 'author', 'author' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotInstanceOf( 'IXR_Error', $result );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertInstanceOf( 'IXR_Date', $result['dateCreated'] );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -120,12 +115,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertInstanceOf( 'IXR_Date', $result['date_modified'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertInstanceOf( 'IXR_Date', $result['date_modified_gmt'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( $this->post_date_ts, $result['dateCreated']->getTimestamp() );
- $this->assertEquals( $this->post_date_ts, $result['date_modified']->getTimestamp() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post_data = get_post( self::$post_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $post_date_gmt = strtotime( get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $this->post_data['post_date'], false ), 'Ymd\TH:i:s' ) );
- $post_modified_gmt = strtotime( get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $this->post_data['post_date'], false ), 'Ymd\TH:i:s' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( strtotime( $post_data->post_date ), $result['dateCreated']->getTimestamp() );
+ $this->assertEquals( strtotime( $post_data->post_date ), $result['date_modified']->getTimestamp() );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post_date_gmt = strtotime( get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $post_data->post_date, false ), 'Ymd\TH:i:s' ) );
+ $post_modified_gmt = strtotime( get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $post_data->post_date, false ), 'Ymd\TH:i:s' ) );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $post_date_gmt, $result['date_created_gmt']->getTimestamp() );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $post_modified_gmt, $result['date_modified_gmt']->getTimestamp() );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsphpunittestsxmlrpcmwgetRecentPostsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php 2016-11-09 22:59:02 UTC (rev 39188)
+++ trunk/tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php 2016-11-10 01:53:08 UTC (rev 39189)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4,23 +4,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @group xmlrpc
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class Tests_XMLRPC_mw_getRecentPosts extends WP_XMLRPC_UnitTestCase {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- var $post_data;
- var $post_id;
- var $post_date_ts;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected static $post_id;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function setUp() {
- parent::setUp();
-
- $author_id = $this->make_user_by_role( 'author' );
- $this->post_date_ts = strtotime( '+1 day' );
- $this->post_data = array(
- 'post_title' => rand_str(),
- 'post_content' => rand_str( 2000 ),
- 'post_excerpt' => rand_str( 100 ),
- 'post_author' => $author_id,
- 'post_date' => strftime( "%Y-%m-%d %H:%M:%S", $this->post_date_ts ),
- );
- $this->post_id = wp_insert_post( $this->post_data );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$post_id = $factory->post->create( array(
+ 'post_type' => 'page',
+ 'post_author' => $factory->user->create( array(
+ 'user_login' => 'author',
+ 'user_pass' => 'author',
+ 'role' => 'author'
+ ) ),
+ 'post_date' => strftime( "%Y-%m-%d %H:%M:%S", strtotime( '+1 day' ) ),
+ ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function test_invalid_username_password() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -41,7 +36,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function test_no_editable_posts() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_delete_post( $this->post_id, true );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_delete_post( self::$post_id, true );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $result = $this->myxmlrpcserver->mw_getRecentPosts( array( 1, 'author', 'author' ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotInstanceOf( 'IXR_Error', $result );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -100,17 +95,17 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // create attachment
</span><span class="cx" style="display: block; padding: 0 10px"> $filename = ( DIR_TESTDATA.'/images/a2-small.jpg' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $attachment_id = self::factory()->attachment->create_upload_object( $filename, $this->post_id );
- set_post_thumbnail( $this->post_id, $attachment_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $attachment_id = self::factory()->attachment->create_upload_object( $filename, self::$post_id );
+ set_post_thumbnail( self::$post_id, $attachment_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $results = $this->myxmlrpcserver->mw_getRecentPosts( array( $this->post_id, 'author', 'author' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $results = $this->myxmlrpcserver->mw_getRecentPosts( array( self::$post_id, 'author', 'author' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotInstanceOf( 'IXR_Error', $results );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> foreach( $results as $result ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertInternalType( 'string', $result['wp_post_thumbnail'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertStringMatchesFormat( '%d', $result['wp_post_thumbnail'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if( ! empty( $result['wp_post_thumbnail'] ) || $result['postid'] == $this->post_id ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if( ! empty( $result['wp_post_thumbnail'] ) || $result['postid'] == self::$post_id ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $attachment_id = get_post_meta( $result['postid'], '_thumbnail_id', true );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $attachment_id, $result['wp_post_thumbnail'] );
</span></span></pre></div>
<a id="trunktestsphpunittestsxmlrpcwpdeleteTermphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/xmlrpc/wp/deleteTerm.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/xmlrpc/wp/deleteTerm.php 2016-11-09 22:59:02 UTC (rev 39188)
+++ trunk/tests/phpunit/tests/xmlrpc/wp/deleteTerm.php 2016-11-10 01:53:08 UTC (rev 39189)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4,13 +4,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @group xmlrpc
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class Tests_XMLRPC_wp_deleteTerm extends WP_XMLRPC_UnitTestCase {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- var $term;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected static $term_id;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function setUp() {
- parent::setUp();
-
- $this->term = wp_insert_term( 'term' . rand_str() , 'category' );
- $this->assertInternalType( 'array', $this->term );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$term_id = $factory->term->create( array(
+ 'taxonomy' => 'category',
+ ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function test_invalid_username_password() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -40,7 +39,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function test_incapable_user() {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->make_user_by_role( 'subscriber' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = $this->myxmlrpcserver->wp_deleteTerm( array( 1, 'subscriber', 'subscriber', 'category', $this->term['term_id'] ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = $this->myxmlrpcserver->wp_deleteTerm( array( 1, 'subscriber', 'subscriber', 'category', self::$term_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertInstanceOf( 'IXR_Error', $result );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 401, $result->code );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( __( 'Sorry, you are not allowed to delete this term.' ), $result->message );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -67,7 +66,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function test_term_deleted() {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->make_user_by_role( 'editor' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = $this->myxmlrpcserver->wp_deleteTerm( array( 1, 'editor', 'editor', 'category', $this->term['term_id'] ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = $this->myxmlrpcserver->wp_deleteTerm( array( 1, 'editor', 'editor', 'category', self::$term_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotInstanceOf( 'IXR_Error', $result );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertInternalType( 'boolean', $result );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsphpunittestsxmlrpcwpeditTermphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/xmlrpc/wp/editTerm.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/xmlrpc/wp/editTerm.php 2016-11-09 22:59:02 UTC (rev 39188)
+++ trunk/tests/phpunit/tests/xmlrpc/wp/editTerm.php 2016-11-10 01:53:08 UTC (rev 39189)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4,19 +4,20 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @group xmlrpc
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class Tests_XMLRPC_wp_editTerm extends WP_XMLRPC_UnitTestCase {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- var $parent_term;
- var $child_term;
- var $post_tag;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected static $parent_term;
+ protected static $child_term;
+ protected static $post_tag;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function setUp() {
- parent::setUp();
-
- $this->parent_term = wp_insert_term( 'parent' . rand_str() , 'category' );
- $this->assertInternalType( 'array', $this->parent_term );
- $this->child_term = wp_insert_term( 'child' . rand_str() , 'category' );
- $this->assertInternalType( 'array', $this->child_term );
- $this->post_tag = wp_insert_term( 'test' . rand_str() , 'post_tag' );
- $this->assertInternalType( 'array', $this->post_tag );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$parent_term = $factory->term->create( array(
+ 'taxonomy' => 'category',
+ ) );
+ self::$child_term = $factory->term->create( array(
+ 'taxonomy' => 'category',
+ ) );
+ self::$post_tag = $factory->term->create( array(
+ 'taxonomy' => 'post_tag',
+ ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function test_invalid_username_password() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -37,7 +38,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function test_invalid_taxonomy() {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->make_user_by_role( 'subscriber' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'subscriber', 'subscriber', $this->parent_term['term_id'], array( 'taxonomy' => 'not_existing' ) ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'subscriber', 'subscriber', self::$parent_term, array( 'taxonomy' => 'not_existing' ) ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertInstanceOf( 'IXR_Error', $result );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 403, $result->code );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( __( 'Invalid taxonomy.' ), $result->message );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -46,7 +47,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function test_incapable_user() {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->make_user_by_role( 'subscriber' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'subscriber', 'subscriber', $this->parent_term['term_id'], array( 'taxonomy' => 'category' ) ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'subscriber', 'subscriber', self::$parent_term, array( 'taxonomy' => 'category' ) ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertInstanceOf( 'IXR_Error', $result );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 401, $result->code );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( __( 'Sorry, you are not allowed to edit this term.' ), $result->message );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -73,7 +74,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function test_empty_term_name() {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->make_user_by_role( 'editor' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', $this->parent_term['term_id'], array( 'taxonomy' => 'category', 'name' => '' ) ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$parent_term, array( 'taxonomy' => 'category', 'name' => '' ) ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertInstanceOf( 'IXR_Error', $result );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 403, $result->code );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( __( 'The term name cannot be empty.' ), $result->message );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -82,7 +83,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function test_parent_for_nonhierarchical() {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->make_user_by_role( 'editor' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', $this->post_tag['term_id'], array( 'taxonomy' => 'post_tag', 'parent' => $this->parent_term['term_id'] ) ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$post_tag, array( 'taxonomy' => 'post_tag', 'parent' => self::$parent_term ) ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertInstanceOf( 'IXR_Error', $result );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 403, $result->code );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( __( "This taxonomy is not hierarchical so you can't set a parent." ), $result->message );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -91,7 +92,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function test_parent_empty() {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->make_user_by_role( 'editor' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', $this->child_term['term_id'], array( 'taxonomy' => 'category', 'parent' => '', 'name' => 'test' ) ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, array( 'taxonomy' => 'category', 'parent' => '', 'name' => 'test' ) ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotInstanceOf( 'IXR_Error', $result );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue( $result );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -99,19 +100,19 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function test_parent_null() {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->make_user_by_role( 'editor' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', $this->child_term['term_id'], array( 'taxonomy' => 'category', 'parent' => NULL, 'name' => 'test' ) ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, array( 'taxonomy' => 'category', 'parent' => NULL, 'name' => 'test' ) ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotInstanceOf( 'IXR_Error', $result );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertInternalType( 'boolean', $result );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $term = get_term( $this->child_term['term_id'], 'category' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $term = get_term( self::$child_term, 'category' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( '0', $term->parent );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function test_parent_invalid() {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->make_user_by_role( 'editor' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', $this->child_term['term_id'], array( 'taxonomy' => 'category', 'parent' => 'dasda', 'name' => 'test' ) ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, array( 'taxonomy' => 'category', 'parent' => 'dasda', 'name' => 'test' ) ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertInstanceOf( 'IXR_Error', $result );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 500, $result->code );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -119,7 +120,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function test_parent_not_existing() {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->make_user_by_role( 'editor' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', $this->child_term['term_id'], array( 'taxonomy' => 'category', 'parent' => 9999, 'name' => 'test' ) ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, array( 'taxonomy' => 'category', 'parent' => 9999, 'name' => 'test' ) ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertInstanceOf( 'IXR_Error', $result );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 403, $result->code );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( __( 'Parent term does not exist.' ), $result->message );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -128,8 +129,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function test_parent_duplicate_slug() {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->make_user_by_role( 'editor' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $parent_term = get_term_by( 'id', $this->parent_term['term_id'], 'category' );
- $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', $this->child_term['term_id'], array( 'taxonomy' => 'category', 'slug' => $parent_term->slug ) ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $parent_term = get_term_by( 'id', self::$parent_term, 'category' );
+ $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, array( 'taxonomy' => 'category', 'slug' => $parent_term->slug ) ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertInstanceOf( 'IXR_Error', $result );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 500, $result->code );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( htmlspecialchars( sprintf( __('The slug “%s” is already in use by another term'), $parent_term->slug ) ), $result->message );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -138,8 +139,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function test_edit_all_fields() {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->make_user_by_role( 'editor' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $fields = array( 'taxonomy' => 'category', 'name' => 'Child 2', 'parent' => $this->parent_term['term_id'], 'description' => 'Child term', 'slug' => 'child_2' );
- $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', $this->child_term['term_id'], $fields ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $fields = array( 'taxonomy' => 'category', 'name' => 'Child 2', 'parent' => self::$parent_term, 'description' => 'Child term', 'slug' => 'child_2' );
+ $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, $fields ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotInstanceOf( 'IXR_Error', $result );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertInternalType( 'boolean', $result );
</span></span></pre></div>
<a id="trunktestsphpunittestsxmlrpcwpgetCommentphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/xmlrpc/wp/getComment.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/xmlrpc/wp/getComment.php 2016-11-09 22:59:02 UTC (rev 39188)
+++ trunk/tests/phpunit/tests/xmlrpc/wp/getComment.php 2016-11-10 01:53:08 UTC (rev 39189)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4,39 +4,37 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @group xmlrpc
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class Tests_XMLRPC_wp_getComment extends WP_XMLRPC_UnitTestCase {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- var $post_id;
- var $parent_comment_id;
- var $parent_comment_data;
- var $child_comment_id;
- var $child_comment_data;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected static $post_id;
+ protected static $parent_comment_id;
+ protected static $parent_comment_data;
+ protected static $child_comment_id;
+ protected static $child_comment_data;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function setUp() {
- parent::setUp();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$post_id = $factory->post->create();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->post_id = self::factory()->post->create();
-
- $this->parent_comment_data = array(
- 'comment_post_ID' => $this->post_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$parent_comment_data = array(
+ 'comment_post_ID' => self::$post_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'comment_author' => 'Test commenter',
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_author_url' => 'http://example.com/',
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_author_email' => 'example@example.com',
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_content' => rand_str( 100 ),
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->parent_comment_id = wp_insert_comment( $this->parent_comment_data );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$parent_comment_id = wp_insert_comment( self::$parent_comment_data );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->child_comment_data = array(
- 'comment_post_ID' => $this->post_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$child_comment_data = array(
+ 'comment_post_ID' => self::$post_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'comment_author' => 'Test commenter 2',
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_author_url' => 'http://example.org/',
</span><span class="cx" style="display: block; padding: 0 10px"> 'comment_author_email' => 'example@example.org',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'comment_parent' => $this->parent_comment_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'comment_parent' => self::$parent_comment_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'comment_content' => rand_str( 100 )
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->child_comment_id = wp_insert_comment( $this->child_comment_data );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ self::$child_comment_id = wp_insert_comment( self::$child_comment_data );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function test_invalid_username_password() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = $this->myxmlrpcserver->wp_getComment( array( 1, 'username', 'password', $this->parent_comment_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = $this->myxmlrpcserver->wp_getComment( array( 1, 'username', 'password', self::$parent_comment_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertInstanceOf( 'IXR_Error', $result );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 403, $result->code );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -44,7 +42,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function test_incapable_user() {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->make_user_by_role( 'contributor' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = $this->myxmlrpcserver->wp_getComment( array( 1, 'contributor', 'contributor', $this->parent_comment_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = $this->myxmlrpcserver->wp_getComment( array( 1, 'contributor', 'contributor', self::$parent_comment_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertInstanceOf( 'IXR_Error', $result );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 403, $result->code );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -52,7 +50,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function test_valid_comment() {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->make_user_by_role( 'editor' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = $this->myxmlrpcserver->wp_getComment( array( 1, 'editor', 'editor', $this->parent_comment_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = $this->myxmlrpcserver->wp_getComment( array( 1, 'editor', 'editor', self::$parent_comment_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotInstanceOf( 'IXR_Error', $result );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Check data types
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -76,23 +74,23 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertStringMatchesFormat( '%d', $result['comment_id'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertStringMatchesFormat( '%d', $result['parent'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertStringMatchesFormat( '%d', $result['post_id'] );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( $this->parent_comment_id, $result['comment_id'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( self::$parent_comment_id, $result['comment_id'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 0, $result['parent'] );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( $this->parent_comment_data['comment_content'], $result['content'] );
- $this->assertEquals( $this->post_id, $result['post_id'] );
- $this->assertEquals( $this->parent_comment_data['comment_author'], $result['author'] );
- $this->assertEquals( $this->parent_comment_data['comment_author_url'], $result['author_url'] );
- $this->assertEquals( $this->parent_comment_data['comment_author_email'], $result['author_email'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( self::$parent_comment_data['comment_content'], $result['content'] );
+ $this->assertEquals( self::$post_id, $result['post_id'] );
+ $this->assertEquals( self::$parent_comment_data['comment_author'], $result['author'] );
+ $this->assertEquals( self::$parent_comment_data['comment_author_url'], $result['author_url'] );
+ $this->assertEquals( self::$parent_comment_data['comment_author_email'], $result['author_email'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function test_valid_child_comment() {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->make_user_by_role( 'editor' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = $this->myxmlrpcserver->wp_getComment( array( 1, 'editor', 'editor', $this->child_comment_id ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = $this->myxmlrpcserver->wp_getComment( array( 1, 'editor', 'editor', self::$child_comment_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotInstanceOf( 'IXR_Error', $result );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( $this->child_comment_id, $result['comment_id'] );
- $this->assertEquals( $this->parent_comment_id, $result['parent'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( self::$child_comment_id, $result['comment_id'] );
+ $this->assertEquals( self::$parent_comment_id, $result['parent'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function test_invalid_id() {
</span></span></pre></div>
<a id="trunktestsphpunittestsxmlrpcwpgetMediaItemphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/xmlrpc/wp/getMediaItem.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/xmlrpc/wp/getMediaItem.php 2016-11-09 22:59:02 UTC (rev 39188)
+++ trunk/tests/phpunit/tests/xmlrpc/wp/getMediaItem.php 2016-11-10 01:53:08 UTC (rev 39189)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4,29 +4,28 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @group xmlrpc
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class Tests_XMLRPC_wp_getMediaItem extends WP_XMLRPC_UnitTestCase {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- var $post_id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected static $post_id;
+
</ins><span class="cx" style="display: block; padding: 0 10px"> var $attachment_data;
</span><span class="cx" style="display: block; padding: 0 10px"> var $attachment_id;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$post_id = $factory->post->create();
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> function setUp() {
</span><span class="cx" style="display: block; padding: 0 10px"> parent::setUp();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> add_theme_support( 'post-thumbnails' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->post_id = wp_insert_post( array(
- 'post_title' => rand_str(),
- 'post_content' => rand_str(),
- 'post_status' => 'publish'
- ));
-
</del><span class="cx" style="display: block; padding: 0 10px"> $filename = ( DIR_TESTDATA.'/images/waffles.jpg' );
</span><span class="cx" style="display: block; padding: 0 10px"> $contents = file_get_contents( $filename );
</span><span class="cx" style="display: block; padding: 0 10px"> $upload = wp_upload_bits(basename($filename), null, $contents);
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->attachment_id = $this->_make_attachment( $upload, $this->post_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->attachment_id = $this->_make_attachment( $upload, self::$post_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->attachment_data = get_post( $this->attachment_id, ARRAY_A );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- set_post_thumbnail( $this->post_id, $this->attachment_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ set_post_thumbnail( self::$post_id, $this->attachment_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function tearDown() {
</span></span></pre></div>
<a id="trunktestsphpunittestsxmlrpcwpgetPagephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/xmlrpc/wp/getPage.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/xmlrpc/wp/getPage.php 2016-11-09 22:59:02 UTC (rev 39188)
+++ trunk/tests/phpunit/tests/xmlrpc/wp/getPage.php 2016-11-10 01:53:08 UTC (rev 39189)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4,27 +4,22 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @group xmlrpc
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class Tests_XMLRPC_wp_getPage extends WP_XMLRPC_UnitTestCase {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- var $post_data;
- var $post_id;
- var $post_date_ts;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected static $post_id;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function setUp() {
- parent::setUp();
-
- $this->post_date_ts = strtotime( '+1 day' );
- $this->post_data = array(
- 'post_type' => 'page',
- 'post_title' => rand_str(),
- 'post_content' => rand_str( 2000 ),
- 'post_excerpt' => rand_str( 100 ),
- 'post_author' => $this->make_user_by_role( 'author' ),
- 'post_date' => strftime( "%Y-%m-%d %H:%M:%S", $this->post_date_ts ),
- );
- $this->post_id = wp_insert_post( $this->post_data );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$post_id = $factory->post->create( array(
+ 'post_type' => 'page',
+ 'post_author' => $factory->user->create( array(
+ 'user_login' => 'author',
+ 'user_pass' => 'author',
+ 'role' => 'author'
+ ) ),
+ 'post_date' => strftime( "%Y-%m-%d %H:%M:%S", strtotime( '+1 day' ) ),
+ ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function test_invalid_username_password() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = $this->myxmlrpcserver->wp_getPage( array( 1, $this->post_id, 'username', 'password' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = $this->myxmlrpcserver->wp_getPage( array( 1, self::$post_id, 'username', 'password' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertInstanceOf( 'IXR_Error', $result );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 403, $result->code );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -43,7 +38,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function test_valid_page() {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->make_user_by_role( 'editor' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = $this->myxmlrpcserver->wp_getPage( array( 1, $this->post_id, 'editor', 'editor' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = $this->myxmlrpcserver->wp_getPage( array( 1, self::$post_id, 'editor', 'editor' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotInstanceOf( 'IXR_Error', $result );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Check data types
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -70,27 +65,31 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertInternalType( 'array', $result['custom_fields'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertInternalType( 'string', $result['wp_page_template'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post_data = get_post( self::$post_id );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Check expected values
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertStringMatchesFormat( '%d', $result['userid'] );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( 'draft', $result['page_status'] );
- $this->assertEquals( $this->post_data['post_title'], $result['title'] );
- $this->assertEquals( url_to_postid( $result['link'] ), $this->post_id );
- $this->assertEquals( $this->post_data['post_excerpt'], $result['excerpt'] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( 'future', $result['page_status'] );
+ $this->assertEquals( $post_data->post_title, $result['title'] );
+ $this->assertEquals( url_to_postid( $result['link'] ), self::$post_id );
+ $this->assertEquals( $post_data->post_excerpt, $result['excerpt'] );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertStringMatchesFormat( '%d', $result['wp_author_id'] );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function test_date() {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->make_user_by_role( 'editor' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = $this->myxmlrpcserver->wp_getPage( array( 1, $this->post_id, 'editor', 'editor' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = $this->myxmlrpcserver->wp_getPage( array( 1, self::$post_id, 'editor', 'editor' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotInstanceOf( 'IXR_Error', $result );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertInstanceOf( 'IXR_Date', $result['dateCreated'] );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertInstanceOf( 'IXR_Date', $result['date_created_gmt'] );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $date_gmt = strtotime( get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $this->post_data['post_date'], false ), 'Ymd\TH:i:s' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post_data = get_post( self::$post_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( $this->post_date_ts, $result['dateCreated']->getTimestamp() );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $date_gmt = strtotime( get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $post_data->post_date, false ), 'Ymd\TH:i:s' ) );
+
+ $this->assertEquals( strtotime( $post_data->post_date ), $result['dateCreated']->getTimestamp() );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $date_gmt, $result['date_created_gmt']->getTimestamp() );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsphpunittestsxmlrpcwpgetPageListphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/xmlrpc/wp/getPageList.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/xmlrpc/wp/getPageList.php 2016-11-09 22:59:02 UTC (rev 39188)
+++ trunk/tests/phpunit/tests/xmlrpc/wp/getPageList.php 2016-11-10 01:53:08 UTC (rev 39189)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4,23 +4,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @group xmlrpc
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class Tests_XMLRPC_wp_getPageList extends WP_XMLRPC_UnitTestCase {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- var $post_data;
- var $post_id;
- var $post_date_ts;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected static $post_id;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function setUp() {
- parent::setUp();
-
- $this->post_date_ts = strtotime( '+1 day' );
- $this->post_data = array(
- 'post_type' => 'page',
- 'post_title' => rand_str(),
- 'post_content' => rand_str( 2000 ),
- 'post_excerpt' => rand_str( 100 ),
- 'post_author' => $this->make_user_by_role( 'author' ),
- 'post_date' => strftime( "%Y-%m-%d %H:%M:%S", $this->post_date_ts ),
- );
- $this->post_id = wp_insert_post( $this->post_data );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$post_id = $factory->post->create( array(
+ 'post_type' => 'page',
+ 'post_author' => $factory->user->create( array(
+ 'user_login' => 'author',
+ 'user_pass' => 'author',
+ 'role' => 'author'
+ ) ),
+ 'post_date' => strftime( "%Y-%m-%d %H:%M:%S", strtotime( '+1 day' ) ),
+ ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function test_invalid_username_password() {
</span></span></pre></div>
<a id="trunktestsphpunittestsxmlrpcwpgetPagesphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/xmlrpc/wp/getPages.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/xmlrpc/wp/getPages.php 2016-11-09 22:59:02 UTC (rev 39188)
+++ trunk/tests/phpunit/tests/xmlrpc/wp/getPages.php 2016-11-10 01:53:08 UTC (rev 39189)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4,83 +4,82 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @group xmlrpc
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class Tests_XMLRPC_wp_getPages extends WP_XMLRPC_UnitTestCase {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- var $post_data;
- var $post_id;
- var $post_date_ts;
- var $editor_id;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected static $post_id;
+ protected static $editor_id;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function setUp() {
- parent::setUp();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$post_id = $factory->post->create( array(
+ 'post_type' => 'page',
+ 'post_author' => $factory->user->create( array(
+ 'user_login' => 'administrator',
+ 'user_pass' => 'administrator',
+ 'role' => 'administrator'
+ ) ),
+ 'post_date' => strftime( "%Y-%m-%d %H:%M:%S", strtotime( '+1 day' ) ),
+ ) );
+ self::$editor_id = $factory->user->create( array(
+ 'user_login' => 'editor',
+ 'user_pass' => 'editor',
+ 'role' => 'editor'
+ ) );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->post_date_ts = strtotime( '+1 day' );
- $this->post_data = array(
- 'post_type' => 'page',
- 'post_title' => rand_str(),
- 'post_content' => rand_str( 2000 ),
- 'post_excerpt' => rand_str( 100 ),
- 'post_author' => $this->make_user_by_role( 'administrator' ),
- 'post_date' => strftime( "%Y-%m-%d %H:%M:%S", $this->post_date_ts ),
- );
- $this->post_id = wp_insert_post( $this->post_data );
- $this->editor_id = $this->make_user_by_role( 'editor' );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ function test_invalid_username_password() {
+ $result = $this->myxmlrpcserver->wp_getPages( array( 1, 'username', 'password' ) );
+ $this->assertInstanceOf( 'IXR_Error', $result );
+ $this->assertEquals( 403, $result->code );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function test_invalid_username_password() {
- $result = $this->myxmlrpcserver->wp_getPages( array( 1, 'username', 'password' ) );
- $this->assertInstanceOf( 'IXR_Error', $result );
- $this->assertEquals( 403, $result->code );
- }
-
- function test_incapable_user() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ function test_incapable_user() {
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->make_user_by_role( 'contributor' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = $this->myxmlrpcserver->wp_getPages( array( 1, 'contributor', 'contributor' ) );
- $this->assertInstanceOf( 'IXR_Error', $result );
- $this->assertEquals( 401, $result->code );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = $this->myxmlrpcserver->wp_getPages( array( 1, 'contributor', 'contributor' ) );
+ $this->assertInstanceOf( 'IXR_Error', $result );
+ $this->assertEquals( 401, $result->code );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function test_capable_user() {
- $results = $this->myxmlrpcserver->wp_getPages( array( 1, 'administrator', 'administrator' ) );
- $this->assertNotInstanceOf( 'IXR_Error', $results );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ function test_capable_user() {
+ $results = $this->myxmlrpcserver->wp_getPages( array( 1, 'administrator', 'administrator' ) );
+ $this->assertNotInstanceOf( 'IXR_Error', $results );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach( $results as $result ) {
- $page = get_post( $result['page_id'] );
- $this->assertEquals( $page->post_type, 'page' );
- }
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach( $results as $result ) {
+ $page = get_post( $result['page_id'] );
+ $this->assertEquals( $page->post_type, 'page' );
+ }
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function remove_editor_edit_page_cap( $caps, $cap, $user_id, $args ) {
- if ( in_array( $cap, array( 'edit_page', 'edit_others_pages' ) ) ) {
- if ( $user_id == $this->editor_id && $args[0] == $this->post_id ) {
- return array( false );
- }
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ function remove_editor_edit_page_cap( $caps, $cap, $user_id, $args ) {
+ if ( in_array( $cap, array( 'edit_page', 'edit_others_pages' ) ) ) {
+ if ( $user_id == self::$editor_id && $args[0] == self::$post_id ) {
+ return array( false );
+ }
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- return $caps;
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return $caps;
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 20629
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function test_semi_capable_user() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- add_filter( 'map_meta_cap', array( $this, 'remove_editor_edit_page_cap') , 10, 4 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ add_filter( 'map_meta_cap', array( $this, 'remove_editor_edit_page_cap') , 10, 4 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $results = $this->myxmlrpcserver->wp_getPages( array( 1, 'editor', 'editor' ) );
- $this->assertNotInstanceOf( 'IXR_Error', $results );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $results = $this->myxmlrpcserver->wp_getPages( array( 1, 'editor', 'editor' ) );
+ $this->assertNotInstanceOf( 'IXR_Error', $results );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $found_incapable = false;
- foreach( $results as $result ) {
- // WP#20629
- $this->assertNotInstanceOf( 'IXR_Error', $result );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $found_incapable = false;
+ foreach( $results as $result ) {
+ // WP#20629
+ $this->assertNotInstanceOf( 'IXR_Error', $result );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $result['page_id'] == $this->post_id ) {
- $found_incapable = true;
- break;
- }
- }
- $this->assertFalse( $found_incapable );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $result['page_id'] == self::$post_id ) {
+ $found_incapable = true;
+ break;
+ }
+ }
+ $this->assertFalse( $found_incapable );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- remove_filter( 'map_meta_cap', array( $this, 'remove_editor_edit_page_cap' ), 10, 4 );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ remove_filter( 'map_meta_cap', array( $this, 'remove_editor_edit_page_cap' ), 10, 4 );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsphpunittestsxmlrpcwpgetTermphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/xmlrpc/wp/getTerm.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/xmlrpc/wp/getTerm.php 2016-11-09 22:59:02 UTC (rev 39188)
+++ trunk/tests/phpunit/tests/xmlrpc/wp/getTerm.php 2016-11-10 01:53:08 UTC (rev 39189)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4,13 +4,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @group xmlrpc
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class Tests_XMLRPC_wp_getTerm extends WP_XMLRPC_UnitTestCase {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- var $term;
</del><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function setUp() {
- parent::setUp();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected static $term_id;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->term = wp_insert_term( 'term' . rand_str() , 'category' );
- $this->assertInternalType( 'array', $this->term );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$term_id = $factory->term->create( array(
+ 'taxonomy' => 'category',
+ ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function test_invalid_username_password() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -40,7 +40,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function test_incapable_user() {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->make_user_by_role( 'subscriber' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = $this->myxmlrpcserver->wp_getTerm( array( 1, 'subscriber', 'subscriber', 'category', $this->term['term_id'] ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = $this->myxmlrpcserver->wp_getTerm( array( 1, 'subscriber', 'subscriber', 'category', self::$term_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertInstanceOf( 'IXR_Error', $result );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 401, $result->code );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( __( 'Sorry, you are not allowed to assign this term.' ), $result->message );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -68,9 +68,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function test_valid_term() {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->make_user_by_role( 'editor' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $term = get_term( $this->term['term_id'], 'category', ARRAY_A );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $term = get_term( self::$term_id, 'category', ARRAY_A );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = $this->myxmlrpcserver->wp_getTerm( array( 1, 'editor', 'editor', 'category', $this->term['term_id'] ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = $this->myxmlrpcserver->wp_getTerm( array( 1, 'editor', 'editor', 'category', self::$term_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotInstanceOf( 'IXR_Error', $result );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $result, $term );
</span></span></pre></div>
<a id="trunktestsphpunittestsxmlrpcwpnewTermphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/xmlrpc/wp/newTerm.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/xmlrpc/wp/newTerm.php 2016-11-09 22:59:02 UTC (rev 39188)
+++ trunk/tests/phpunit/tests/xmlrpc/wp/newTerm.php 2016-11-10 01:53:08 UTC (rev 39189)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4,14 +4,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @group xmlrpc
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class Tests_XMLRPC_wp_newTerm extends WP_XMLRPC_UnitTestCase {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- var $parent_term;
</del><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function setUp() {
- parent::setUp();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected static $parent_term_id;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->parent_term = wp_insert_term( 'parent' . rand_str(), 'category' );
- $this->assertInternalType( 'array', $this->parent_term );
- $this->parent_term = $this->parent_term['term_id'];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$parent_term_id = $factory->term->create( array(
+ 'taxonomy' => 'category',
+ ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function test_invalid_username_password() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -59,7 +58,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function test_parent_for_nonhierarchical() {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->make_user_by_role( 'editor' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', array( 'taxonomy' => 'post_tag', 'parent' => $this->parent_term, 'name' => 'test' ) ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', array( 'taxonomy' => 'post_tag', 'parent' => self::$parent_term_id, 'name' => 'test' ) ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertInstanceOf( 'IXR_Error', $result );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 403, $result->code );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( __( 'This taxonomy is not hierarchical.' ), $result->message );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -94,7 +93,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function test_add_term_with_parent() {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->make_user_by_role( 'editor' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', array( 'taxonomy' => 'category', 'parent' => $this->parent_term, 'name' => 'test' ) ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', array( 'taxonomy' => 'category', 'parent' => self::$parent_term_id, 'name' => 'test' ) ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotInstanceOf( 'IXR_Error', $result );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertStringMatchesFormat( '%d', $result );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -102,7 +101,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function test_add_term_with_all() {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->make_user_by_role( 'editor' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $taxonomy = array( 'taxonomy' => 'category', 'parent' => $this->parent_term, 'name' => 'test_all', 'description' => 'Test all', 'slug' => 'test_all' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $taxonomy = array( 'taxonomy' => 'category', 'parent' => self::$parent_term_id, 'name' => 'test_all', 'description' => 'Test all', 'slug' => 'test_all' );
</ins><span class="cx" style="display: block; padding: 0 10px"> $result = $this->myxmlrpcserver->wp_newTerm( array( 1, 'editor', 'editor', $taxonomy ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotInstanceOf( 'IXR_Error', $result );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertStringMatchesFormat( '%d', $result );
</span></span></pre>
</div>
</div>
</body>
</html>