Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 8 years ago

#35160 closed enhancement (fixed)

Add Test Coverage for Atom & Reorganize Feeds Unit Tests

Reported by: stevenkword's profile stevenkword Owned by: johnbillion's profile johnbillion
Milestone: 4.5 Priority: high
Severity: normal Version:
Component: Feeds Keywords: has-unit-tests
Focuses: Cc:

Description (last modified by stevenkword)

In Make WordPress Core, we refer to the syndication components as the "Feeds Component". However, in our unit tests, we have the group labelled in its singular form, "Feed". I proposing that we rename this group to its plural form and relocate these test into the tests/phpunit/tests/feeds/ directory.

IMPORTANT -- I don't believe svn diff has the ability to delete directories, so if this proposal is accepted, we need to make sure to manually rename/delete the tests/phpunit/tests/feed directory before commit. Apologies in advance!

In addition to renaming the group, this ticket aims to separate generic syndication tests from the RSS-specific test and additionally provides test coverage for Atom feeds, which currently do not exists.

I feel it is also important to note that this will mandate a refresh of any feeds-related unit tests that are currently sitting in trac. I am willing to commit to refreshing those personally, but would prefer to hold on pending approval from the Committers.

Lastly, this patch proposes a new file, tests/phpunit/tests/feeds/common.php, which contains 3 brand new tests that will currently fail against trunk. I wanted to leave these in here to demonstrate what I was thinking with the common tests. These relate to ticket #30210. However, if I take them back out, the purpose of the common.php file becomes much less apparant. Let's discuss!

Attachments (4)

35160.patch (18.0 KB) - added by stevenkword 9 years ago.
35160.atom.patch (7.7 KB) - added by stevenkword 9 years ago.
Fixes formatting per PHPCS
35160.rss2.patch (10.5 KB) - added by stevenkword 9 years ago.
Clean-up for the RSS2 tests
35160.3.patch (18.2 KB) - added by stevenkword 9 years ago.

Download all attachments as: .zip

Change History (21)

@stevenkword
9 years ago

#1 @stevenkword
9 years ago

@jorbin -- You might be interested in this one.

#2 @stevenkword
9 years ago

  • Description modified (diff)

#3 @stevenkword
9 years ago

  • Description modified (diff)

#4 @stevenkword
9 years ago

  • Milestone changed from Awaiting Review to 4.5

#5 @stevenkword
9 years ago

  • Priority changed from normal to high

Raising priority since this is blocking any ticket where Atom testing is required. e.g. #33591

This ticket was mentioned in Slack in #core by stevenkword. View the logs.


9 years ago

#7 @chriscct7
9 years ago

  • Keywords needs-patch added; has-patch removed

Bug Scrub 1/8/2016 notes:

  • The renaming of the group was favorable, with the note that when it is done, the associated PHP files also need to have the file docbloc item updated as well.
  • Patch should be split as follows:

Phase 1: Add atom tests.
Phase 2: Rename the group.
Phase 3: Add the common.php tests AFTER the group is renamed, which currently fail and need to be fixed.

  • Some of the patch functions have incomplete and/or missing docblocs.
  • Some parts of the patch have formatting issues that need to be addressed.

#8 @johnbillion
9 years ago

A few notes:

  • The post_count and excerpt_only properties aren't set in the Tests_Feeds_Atom class.

In both Tests_Feeds_Atom and Tests_Feeds_RSS2:

  • The author assertion needs to test against the user's display name, not their user_login. Need to explicitly set a display name when creating the test user.
  • The test posts should have some categories and tags assigned so the category and tag assertions operate on more than just the default category and an empty tag list.
  • Creating more than 5 test posts might be a good idea, then an assertion can be added to ensure the feeds contain the correct number of posts.
  • Unless the test posts have explicitly differentiating properties (which they don't), there's no need to loop over every post and run the assertions. Just running the assertions on the first post is enough.
  • assertCount( 1, $x ) can be used instead of assertEquals( 1, count( $x ) ).

#9 @stevenkword
9 years ago

35160.atom.patch takes the suggestions made by @johnbillion into consideration. I'd rather just get the Atom tests in for now since they are blocking other tickets, and we can create new tickets down the road for dealing with common / RSS.

#10 @stevenkword
9 years ago

  • Summary changed from Reorganize Feeds Unit Tests & Add Test Coverage for Atom to Add Test Coverage for Atom & Reorganize Feeds Unit Tests

#11 @stevenkword
9 years ago

I've also added 35160.rss2.patch which improves usage of coding standards and doc, but also implements the recommended changes found in 35160.atom.patch . They are both in the same "style" at this time.

Last edited 9 years ago by stevenkword (previous) (diff)

@stevenkword
9 years ago

Fixes formatting per PHPCS

@stevenkword
9 years ago

Clean-up for the RSS2 tests

#12 @stevenkword
9 years ago

  • Owner set to johnbillion
  • Status changed from new to reviewing

#13 @stevenkword
9 years ago

  • Keywords needs-patch removed

This ticket was mentioned in Slack in #core by stevenkword. View the logs.


9 years ago

@stevenkword
9 years ago

#15 @jorbin
9 years ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 36519:

Improve Automated Feed Tests

Multiple improvements to the RSS2 automated tests along with the addition of Atom tests.

  1. General whitespace cleanup (since the rss2 file serves as the base of the atom file).
  2. Adds an author and category to the tests.
  3. Since the content of the posts is the same, we don't need to test all of the post content.
  4. Adds many posts so that the post count can be checked

Props stevenkword
Fixes #35160.

#16 @johnbillion
8 years ago

In 38924:

Feeds: Greatly reduce the number of dummy posts that are generated for the RSS2 tests. This speeds the tests up.

See #35160, #30210

#17 @johnbillion
8 years ago

In 38927:

Feeds: Greatly reduce the number of dummy posts that are generated for the Atom tests, following on from [38924].

See #35160

Note: See TracTickets for help on using tickets.