diff --git a/tests/phpunit/tests/ajax/Autosave.php b/tests/phpunit/tests/ajax/Autosave.php index 457bcc4c71..9bd4cbccb3 100644 --- a/tests/phpunit/tests/ajax/Autosave.php +++ b/tests/phpunit/tests/ajax/Autosave.php @@ -34,17 +34,11 @@ class Tests_Ajax_Autosave extends WP_Ajax_UnitTestCase { self::$editor_id = $factory->user->create( array( 'role' => 'editor' ) ); self::$user_ids[] = self::$editor_id; - self::$post_id = $factory->post->create( array( 'post_status' => 'draft' ) ); - self::$post = get_post( self::$post_id ); - } - - /** - * Sets up the test fixture. - */ - public function setUp() { - parent::setUp(); // Set a user so the $post has 'post_author'. wp_set_current_user( self::$admin_id ); + + self::$post_id = $factory->post->create( array( 'post_status' => 'draft' ) ); + self::$post = get_post( self::$post_id ); } /** @@ -62,7 +56,7 @@ class Tests_Ajax_Autosave extends WP_Ajax_UnitTestCase { 'data' => array( 'wp_autosave' => array( 'post_id' => self::$post_id, - '_wpnonce' => wp_create_nonce( 'update-post_' . self::$post->ID ), + '_wpnonce' => wp_create_nonce( 'update-post_' . self::$post_id ), 'post_content' => self::$post->post_content . PHP_EOL . $md5, 'post_type' => 'post', ), @@ -85,7 +79,7 @@ class Tests_Ajax_Autosave extends WP_Ajax_UnitTestCase { // Check that the edit happened. $post = get_post( self::$post_id ); - $this->assertGreaterThanOrEqual( 0, strpos( self::$post->post_content, $md5 ) ); + $this->assertNotFalse( strpos( $post->post_content, $md5 ) ); } /** @@ -136,7 +130,7 @@ class Tests_Ajax_Autosave extends WP_Ajax_UnitTestCase { // Check if the autosave post was created. $autosave = wp_get_post_autosave( self::$post_id, get_current_user_id() ); $this->assertNotEmpty( $autosave ); - $this->assertGreaterThanOrEqual( 0, strpos( $autosave->post_content, $md5 ) ); + $this->assertNotFalse( strpos( $autosave->post_content, $md5 ) ); } /**