Test post endpoints #99

merged 38 commits into from Jun 2, 2014


None yet

2 participants

rmccue commented Mar 4, 2014

The WP_JSON_Posts endpoints should be tested to ensure they return a reliable representation of posts.

@rmccue rmccue added this to the 1.0 milestone Mar 4, 2014
This was referenced Mar 4, 2014
@rmccue rmccue modified the milestone: 1.1, 1.0 Apr 9, 2014
@rachelbaker rachelbaker self-assigned this May 26, 2014

Began adding unit tests for the /posts/ endpoints, still a long way to go to get close to full coverage.

@rmccue rmccue referenced this pull request May 27, 2014

Fix errors with excerpt #226

@rmccue rmccue commented on an outdated diff May 27, 2014
+ $this->assertEquals( $response_data['menu_order'], $post_obj->menu_order );
+ $this->assertEquals( $response_data['comment_status'], $post_obj->comment_status );
+ $this->assertEquals( $response_data['ping_status'], $post_obj->ping_status );
+ $this->assertEquals( $response_data['password'], $post_obj->post_password );
+ $this->assertEquals( $response_data['sticky'], is_sticky( $post_obj->ID ) );
+ // Check post format.
+ $post_format = get_post_format( $post_obj->ID );
+ if ( empty( $post_format ) ) {
+ $this->assertEquals( $response_data['format'], 'standard' );
+ } else {
+ $this->assertEquals( $response_data['format'], get_post_format( $post_obj->ID ) );
+ }
+ // Check post dates.
+ $timezone = $this->fake_server->get_timezone();
rmccue May 27, 2014 Member

This returns null, since everything is stubbed out, but the same happens internally too, so...

rmccue commented May 27, 2014

Coverage is currently at 47.96%.

rmccue and others added some commits May 27, 2014
@rmccue rmccue Create abstract base test class 6b5c739
@rmccue rmccue Check correct date for creation 8b507a5
@rmccue rmccue Check other post types 36cdb6c
@rmccue rmccue Add more post creation tests 99c47a4
@rmccue rmccue Use (int) not absint for author sanitization 43a3953
@rmccue rmccue Check _raw fields with edit context 852fc95
@rmccue rmccue Add extra braces
This helps coverage understand the code better, and fits with coding
@rmccue rmccue Create post as test user c28b467
@rmccue rmccue Test more post editing af34612
@rmccue rmccue Test post creation permissions 33eacca
@rmccue rmccue Return 403 error if user can't create posts 0b08c8c
@rmccue rmccue Check with invalid post author object dd99e90
@rmccue rmccue Test creating draft and private posts fe4bb02
@rmccue rmccue Give `null` as date for draft posts 2bde2c2
@rmccue rmccue Test password-protected posts 36b065c
@rmccue rmccue Check page creation with parent bd5b90f
@rmccue rmccue Partially revert "Give `null` as date for draft posts"
This reverts commit 2bde2c2. This is
going to be fixed in #229 instead.
@rmccue rmccue Correct post parent tests 4f70d01
@rmccue rmccue Ensure assertions are always `$expected, $actual` 90f5372
@rmccue rmccue Add missing base testcase
@rachelbaker rachelbaker Use tabs vs spaces in the test config file. e950f1a
@rachelbaker rachelbaker Added test for get_revisions method. f35a0e3
@rmccue rmccue Test creating post with custom date 66c7457
@rmccue rmccue Don't mock out server methods
This never should have been disabled, and was causing stupid errors. We
can remove this when we refactor in #185.
@rmccue rmccue Test dates with custom TZs/GMT ab95e87
@rmccue rmccue Test that custom modified dates are ignored
As per #285.
@rmccue rmccue Test menu order 19a01ad
@rmccue rmccue Test sticky posts e03b13b
@rmccue rmccue Merge branch 'master' into test-post-endpoints ba34f4b
@rmccue rmccue Mark password test skipped c4cb0a1
@rmccue rmccue Don't skip parent tests
Now that #228 has been fixed, we can reenable these.
@rmccue rmccue Don't skip draft test
We've now corrected the date issue in #229. Wa-hoo!
@rmccue rmccue Test invalid statuses 20401af
rmccue commented Jun 2, 2014

We're now at 54% coverage for tests (my previous figure was wrong; it was closer to 10%); more importantly, insert_post is at 81%, with that figure to increase dramatically once #218 and #286 are fixed.

Merging for now so that we can avoid this going stale, and so that it helps us in the mean time. More tests to come!

@rmccue rmccue merged commit bc40226 into master Jun 2, 2014

1 check passed

continuous-integration/travis-ci The Travis CI build passed
@rmccue rmccue deleted the test-post-endpoints branch Jun 2, 2014


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment