Changeset 39161 for trunk/tests/phpunit/tests/rest-api/rest-controller.php
- Timestamp:
- 11/08/2016 01:08:49 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-controller.php
r38832 r39161 191 191 $this->assertEquals( 'a', $args['somedefault']['default'] ); 192 192 } 193 194 public $rest_the_post_filter_apply_count = 0;195 196 public function test_get_post() {197 $post_id = $this->factory()->post->create( array( 'post_title' => 'Original' ) );198 $controller = new WP_REST_Test_Controller();199 200 $post = $controller->get_post( $post_id );201 $this->assertEquals( 'Original', $post->post_title );202 203 $filter_apply_count = $this->rest_the_post_filter_apply_count;204 add_filter( 'rest_the_post', array( $this, 'filter_rest_the_post_for_test_get_post' ), 10, 2 );205 $post = $controller->get_post( $post_id );206 $this->assertEquals( 'Overridden', $post->post_title );207 $this->assertEquals( 1 + $filter_apply_count, $this->rest_the_post_filter_apply_count );208 }209 210 public function filter_rest_the_post_for_test_get_post( $post, $post_id ) {211 $this->assertInstanceOf( 'WP_Post', $post );212 $this->assertInternalType( 'int', $post_id );213 $post->post_title = 'Overridden';214 $this->rest_the_post_filter_apply_count += 1;215 return $post;216 }217 193 }
Note: See TracChangeset
for help on using the changeset viewer.