Commit Graph

26 Commits

Author SHA1 Message Date
Boone Gorges 7d03711fc8 Move `get_adjacent_post()` tests to their own file.
See #35211.


git-svn-id: https://develop.svn.wordpress.org/trunk@36077 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-23 19:38:29 +00:00
Sergey Biryukov 88c274fad8 Formatting: `wp_make_link_relative()` should return an empty string if no path is present in the link.
Props bcworkz, MikeHansenMe, chriscct7, SergeyBiryukov.
Fixes #26819.

git-svn-id: https://develop.svn.wordpress.org/trunk@35497 602fd350-edb4-49c9-b593-d223f7449a82
2015-11-03 21:35:17 +00:00
Scott Taylor 613e88fe86 Unit Tests: `WP_UnitTest_Generator_Sequence` needs a static incrementer - otherwise, it assumes every test class is a reset, which it no longer is (it is now static).
While we're at it, remove unnecessary `tearDown()` code.

See #30017, #33968.



git-svn-id: https://develop.svn.wordpress.org/trunk@35244 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-17 19:24:20 +00:00
Scott Taylor b757b37551 Unit Tests: after [35225], make `factory` a method/getter on `WP_UnitTestCase` and add magic methods for BC for every plugin that is extending `WP_UnitTestCase` and accessing the `$factory` instance prop.
Props nerrad, wonderboymusic.
See #30017, #33968.



git-svn-id: https://develop.svn.wordpress.org/trunk@35242 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-17 18:02:16 +00:00
Scott Taylor e70ebea219 Unit Tests: one `$factory` to rule them all, and it shall be `static`.
Using more than one instance of `WP_UnitTest_Factory` causes all kinds of craziness, due to out-of-sync internal generator sequences. Since we want to use `setUpBeforeClass`, we were creating ad hoc instances. To avoid that, we were injecting one `static` instance via Dependency Injection in `wpSetUpBeforeClass`. All tests should really use the `static` instance, so we will remove the instance prop `$factory`.

Replace `$this->factory` with `self::$factory` over 2000 times.
Rewrite all of the tests that were hard-coding dynamic values. 

#YOLOFriday



git-svn-id: https://develop.svn.wordpress.org/trunk@35225 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-16 21:04:12 +00:00
Drew Jaynes 0ea2acb720 Tests: Permalink Structures Phase II: DRY up logic for setting permalink structures in test methods.
Renames `reset_permalinks()` to `set_permalink_structure()` (mimicking `$wp_rewrite->set_permalink_structure()`) and allows it to accept an optional permalink structure. In this way, we can double dip using it to both set and reset the permalink structure from anywhere.

Removes alot of duplicated code from tests.

See #33968.


git-svn-id: https://develop.svn.wordpress.org/trunk@34810 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-03 20:54:11 +00:00
Drew Jaynes adffdab161 Tests: Introduce `WP_UnitTestCase::reset_permalinks()`, an attempt to DRY up logic for resetting and restoring default permalinks on `setUp()` and `tearDown()`.
See #33968.


git-svn-id: https://develop.svn.wordpress.org/trunk@34802 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-03 17:14:12 +00:00
Gary Pendergast ce14a63214 Permalinks: Add pretty permalinks for unattached attachments.
Previously, unattached attachments would have unsightly `/?attachment_id=1` URLs. As we've moved away from attachments being specifically attached to posts, instead being Media items, this has made the unattached URLs a more common occurrence.

We can breath easy once more, knowing that the world is a little bit safer from the horror of unnecessarily ugly URLs.

Props SergeyBiryukov, wonderboymusic, pento.

Fixes #1914.



git-svn-id: https://develop.svn.wordpress.org/trunk@34690 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-29 09:41:14 +00:00
Boone Gorges 4ebab4dc16 Remove extraneous table join in `get_adjacent_post()`.
Since [29248], a table join has not been necessary to process the
`$excluded_terms` parameter of `get_adjacent_post()`. Aside from adding extra
overhead, this join meant that post records that don't have any corresponding
rows in `wp_term_relationships` were erroneously excluded from results.

Fixes #32833.

git-svn-id: https://develop.svn.wordpress.org/trunk@34088 602fd350-edb4-49c9-b593-d223f7449a82
2015-09-12 20:33:07 +00:00
Boone Gorges 067fa3702e In PHPUnit test classes, `parent::tearDown()` should be the last thing done in `tearDown()` methods.
`WP_UnitTestCase::tearDown()` restores the test environment to the default
conditions, including rolling back the MySQL transaction that the test takes
place in, resetting globals, and unhooking test-specific filters. As such, all
teardown routines for specific tests should happen before the parent class's
`tearDown()` method is called. Failure to do so can cause database locks on
certain configurations, among other problems.

See #31537.

git-svn-id: https://develop.svn.wordpress.org/trunk@31622 602fd350-edb4-49c9-b593-d223f7449a82
2015-03-05 13:14:15 +00:00
Boone Gorges d5c9eb41d7 In `get_permalink()`, don't resolve to pretty permalink if post has 'future' status.
We already do this for other non-public statuses, to prevent leaking non-public
information about unpublished posts.

Props e.mazovetskiy, CalEvans.
Fixes #30910.

git-svn-id: https://develop.svn.wordpress.org/trunk@31114 602fd350-edb4-49c9-b593-d223f7449a82
2015-01-09 16:39:56 +00:00
Gary Pendergast 78f496f378 Fix a MySQL warning in the `test_get_adjacent_post_exclude_self_term` unit test, caused by [30400].
See #21212, #22112.


git-svn-id: https://develop.svn.wordpress.org/trunk@30401 602fd350-edb4-49c9-b593-d223f7449a82
2014-11-20 01:47:30 +00:00
Boone Gorges d1e841c03b Improvements to `wp_make_link_relative()`.
* Support relative URL input.
* When the URL being made relative has another URL as a parameter, don't make the second URL relative.

Props voldemortensen.
Fixes #30373.

git-svn-id: https://develop.svn.wordpress.org/trunk@30383 602fd350-edb4-49c9-b593-d223f7449a82
2014-11-19 01:52:57 +00:00
Boone Gorges 6f7880bcf4 In `get_adjacent_post()`, `$excluded_terms` should check term_id rather than term_taxonom_id.
See #29663, #22112.

git-svn-id: https://develop.svn.wordpress.org/trunk@30263 602fd350-edb4-49c9-b593-d223f7449a82
2014-11-06 20:11:34 +00:00
Scott Taylor 150e1367b4 In `get_adjacent_post()`, make `$excluded_terms` work as expected.
Adds unit tests.
Props jessepollak, kovshenin.
Fixes #22112.


git-svn-id: https://develop.svn.wordpress.org/trunk@29248 602fd350-edb4-49c9-b593-d223f7449a82
2014-07-19 22:26:43 +00:00
Scott Taylor f23a5ef832 Setup rewrite changes in tests in a predictable fashion. Don't mix method calls with wrapper function calls.
See #28706.


git-svn-id: https://develop.svn.wordpress.org/trunk@28966 602fd350-edb4-49c9-b593-d223f7449a82
2014-07-03 01:42:57 +00:00
Scott Taylor 80a817ebcc Make sure hundreds of canonical tests don't fail in multisite every other time they are run.
See #28706.


git-svn-id: https://develop.svn.wordpress.org/trunk@28964 602fd350-edb4-49c9-b593-d223f7449a82
2014-07-03 00:49:32 +00:00
Scott Taylor d38227dbae `test_wp_get_shortlink()` assumes permalink structure is '' when it starts. It is not.
See #28706.


git-svn-id: https://develop.svn.wordpress.org/trunk@28961 602fd350-edb4-49c9-b593-d223f7449a82
2014-07-02 19:49:05 +00:00
Andrew Nacin 0ad35e169b Revert the conversion of adjacent post queries to WP_Query. Explanation on the ticket.
Reverts [27285], [27286], [27287], [27288], [27291], [27292], [27293], [27296], [27633], [27634], [27635], and [27692].

see #26937.


git-svn-id: https://develop.svn.wordpress.org/trunk@27836 602fd350-edb4-49c9-b593-d223f7449a82
2014-03-29 06:02:01 +00:00
Andrew Nacin 7a3c12d985 Add a unit test for shortlinks of a page on front.
see #26871, see [27802].


git-svn-id: https://develop.svn.wordpress.org/trunk@27803 602fd350-edb4-49c9-b593-d223f7449a82
2014-03-28 03:01:43 +00:00
Andrew Nacin 05f0bcabec Use the current post's post type when determining post adjacency.
props ethitter.
fixes #26937.


git-svn-id: https://develop.svn.wordpress.org/trunk@27692 602fd350-edb4-49c9-b593-d223f7449a82
2014-03-24 21:29:14 +00:00
Andrew Nacin 0963ea19a0 Fix various issues with WP_Adjacent_Post:
* Performance / number of queries.
 * Incorrect results caused by sticky posts.
 * Back compat for filters, which had used "WHERE" while WP_Query does not; and fixing table references.

props ethitter.
fixes #26937.


git-svn-id: https://develop.svn.wordpress.org/trunk@27635 602fd350-edb4-49c9-b593-d223f7449a82
2014-03-20 02:58:48 +00:00
Andrew Nacin 1d8d862e97 Make get_adjacent_post() wrap a new WP_Get_Adjacent_Post object that uses WP_Query.
git-svn-id: https://develop.svn.wordpress.org/trunk@27285 602fd350-edb4-49c9-b593-d223f7449a82
2014-02-26 17:09:54 +00:00
Andrew Nacin add8bc4e57 Add a $taxonomy argument to each of the adjacent post functions.
Each took an array of category (IDs) when to search. Those can now be term IDs and each function now has $taxonomy = 'category' as an optional argument.

Functions affected: get_previous_post(), get_next_post(), get_adjacent_post(), get_adjacent_post_rel_link(), adjacent_posts_rel_link(), next_post_rel_link(), prev_post_rel_link(), get_boundary_post(), get_previous_post_link(), previous_post_link(), get_next_post_link(), next_post_link(), get_adjacent_post_link(), adjacent_post_link().

props ethitter.
finally fixes #17807.


git-svn-id: https://develop.svn.wordpress.org/trunk@25959 602fd350-edb4-49c9-b593-d223f7449a82
2013-10-27 21:39:51 +00:00
Scott Taylor 404fd85586 Fix the failing `Tests_Link::test_wp_get_shortlink()` assertion:
* `wp_get_shortlink()` was firing a notice when reading `$post->ID` while `$post` was null in some cases
* Before the assertions that assume `$GLOBALS['post']` is not set, call `unset( $GLOBALS['post'] );` - there was global spillage from other tests

See #25282.




git-svn-id: https://develop.svn.wordpress.org/trunk@25404 602fd350-edb4-49c9-b593-d223f7449a82
2013-09-12 17:30:01 +00:00
Andrew Nacin 8045afd81b Move PHPUnit tests into a tests/phpunit directory.
wp-tests-config.php can/should reside in the root of a develop checkout. `phpunit` should be run from the root.

see #25088.


git-svn-id: https://develop.svn.wordpress.org/trunk@25165 602fd350-edb4-49c9-b593-d223f7449a82
2013-08-29 18:39:34 +00:00