mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-03 04:04:35 +00:00
Allow setup_postdata() to accept a post ID.
Previously, it accepted only a full post object. Props sc0ttclark, mordauk, wonderboymusic. Fixes #30970. git-svn-id: https://develop.svn.wordpress.org/trunk@34089 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -46,6 +46,41 @@ class Tests_Query_SetupPostdata extends WP_UnitTestCase {
|
||||
$this->assertSame( $p->ID, $GLOBALS['id'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 30970
|
||||
*/
|
||||
public function test_setup_by_id() {
|
||||
$p = $this->factory->post->create_and_get();
|
||||
setup_postdata( $p->ID );
|
||||
|
||||
$this->assertSame( $p->ID, $GLOBALS['id'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 30970
|
||||
*/
|
||||
public function test_setup_by_fake_post() {
|
||||
$fake = new stdClass;
|
||||
$fake->ID = 98765;
|
||||
setup_postdata( $fake->ID );
|
||||
|
||||
// Fails because there's no post with this ID.
|
||||
$this->assertNotSame( $fake->ID, $GLOBALS['id'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 30970
|
||||
*/
|
||||
public function test_setup_by_postish_object() {
|
||||
$p = $this->factory->post->create();
|
||||
|
||||
$post = new stdClass();
|
||||
$post->ID = $p;
|
||||
setup_postdata( $p );
|
||||
|
||||
$this->assertSame( $p, $GLOBALS['id'] );
|
||||
}
|
||||
|
||||
public function test_authordata() {
|
||||
$u = $this->factory->user->create_and_get();
|
||||
$p = $this->factory->post->create_and_get( array(
|
||||
|
||||
Reference in New Issue
Block a user