mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Adds a `public` visibility to test fixtures, tests, data providers, and callbacks methods. Adds a `private` visibility to helper methods within test classes. Renames callbacks and helpers that previously started with a `_` prefix. Why? For consistency and to leverage using the method visibility. Further naming standardizations is beyond the scope of this commit. Props costdev, jrf, hellofromTonya. Fixes #54177. git-svn-id: https://develop.svn.wordpress.org/trunk@52010 602fd350-edb4-49c9-b593-d223f7449a82
52 lines
1.7 KiB
PHP
52 lines
1.7 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @group xmlrpc
|
|
*/
|
|
class Tests_XMLRPC_mt_getRecentPostTitles extends WP_XMLRPC_UnitTestCase {
|
|
|
|
public function test_invalid_username_password() {
|
|
$result = $this->myxmlrpcserver->mt_getRecentPostTitles( array( 1, 'username', 'password' ) );
|
|
$this->assertIXRError( $result );
|
|
$this->assertSame( 403, $result->code );
|
|
}
|
|
|
|
public function test_no_posts() {
|
|
$this->make_user_by_role( 'author' );
|
|
|
|
$result = $this->myxmlrpcserver->mt_getRecentPostTitles( array( 1, 'author', 'author' ) );
|
|
$this->assertIXRError( $result );
|
|
$this->assertSame( 500, $result->code );
|
|
}
|
|
|
|
public function test_no_editable_posts() {
|
|
$this->make_user_by_role( 'author' );
|
|
$editor = $this->make_user_by_role( 'editor' );
|
|
self::factory()->post->create( array( 'post_author' => $editor ) );
|
|
|
|
$result = $this->myxmlrpcserver->mt_getRecentPostTitles( array( 1, 'author', 'author' ) );
|
|
$this->assertNotIXRError( $result );
|
|
$this->assertCount( 0, $result );
|
|
}
|
|
|
|
public function test_date() {
|
|
$this->make_user_by_role( 'author' );
|
|
|
|
self::factory()->post->create();
|
|
|
|
$results = $this->myxmlrpcserver->mt_getRecentPostTitles( array( 1, 'author', 'author' ) );
|
|
$this->assertNotIXRError( $results );
|
|
|
|
foreach ( $results as $result ) {
|
|
$post = get_post( $result['postid'] );
|
|
$date_gmt = strtotime( get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $post->post_date, false ), 'Ymd\TH:i:s' ) );
|
|
|
|
$this->assertInstanceOf( 'IXR_Date', $result['dateCreated'] );
|
|
$this->assertInstanceOf( 'IXR_Date', $result['date_created_gmt'] );
|
|
|
|
$this->assertSame( strtotime( $post->post_date ), $result['dateCreated']->getTimestamp() );
|
|
$this->assertSame( $date_gmt, $result['date_created_gmt']->getTimestamp() );
|
|
}
|
|
}
|
|
}
|