Commit Graph

19 Commits

Author SHA1 Message Date
Gary Pendergast 94201ff1f5 Tests: Fix a PHP notice introduced in [38907].
`WP_DEFAULT_THEME` was being defined in the wrong location.

Also, if WordPress has the original "default" theme installed, ensure that our test theme overrides it.

Props swissspidy for daring to dive into Themes of WordPress Past.
See #31550, #38457.



git-svn-id: https://develop.svn.wordpress.org/trunk@38908 602fd350-edb4-49c9-b593-d223f7449a82
2016-10-25 11:05:17 +00:00
Gary Pendergast ee65fc1f80 Tests: Use a minimal theme for tests.
This functionality was originally added in [38858], using `symlink()` to put a link to the theme in WordPress' `themes` directory. Unfortunately, not all installs have write access to the `themes` directory, causing unit tests to fail.

The new method is to add the test theme directory to `$wp_theme_directories`, and fix the handful of tests that don't expect `$wp_theme_directories` to have multiple entries.

The test install/bootstrap routines now also check that `WP_DEFAULT_THEME` is defined, in case the tests are being run on a system that hasn't upgraded its' `wp-tests-config.php`.

See #31550.
Fixes #38457.



git-svn-id: https://develop.svn.wordpress.org/trunk@38907 602fd350-edb4-49c9-b593-d223f7449a82
2016-10-25 10:24:57 +00:00
Scott Taylor cba0e2c8f7 Bootstrap: do not go gentle into that good night r38411, r38412, and parts of r38389.
See #36335.


git-svn-id: https://develop.svn.wordpress.org/trunk@38470 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-31 16:30:48 +00:00
Scott Taylor 4225e71a6b Bootstrap: after r38409 and r38410, revert r38402 which reverted r38399.
This fixes the paths in `wp-vendor/` that were including `src`. I want to drop this in so we can find out what else will break.

See #36335.


git-svn-id: https://develop.svn.wordpress.org/trunk@38411 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-27 22:31:11 +00:00
Dion Hulse e353179ce5 Bootstrap: Revert [38399] as it's broken `/build/` and subsequently core.svn.wordpress.org.
The generated classmaps reference `/src/` files and operates in the assumption that the base directory is one level above `wp-settings.php`, which it isn't after our build processes are run.

See #36335


git-svn-id: https://develop.svn.wordpress.org/trunk@38402 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-27 14:36:42 +00:00
Scott Taylor 388690382c Bootstrap: Autoload classes using a Composer-generated PHP 5.2-compatible Autoloader.
* `wp-admin` and `wp-includes` are scanned for classes to autoload
* Several 3rd-party and Ryan McCue-shaped libraries are excluded when the classmap is generated, see `composer.json`: `autoload.exclude-from-classmap`
* `wp-vendor/autoload_52.php` is included at the top of `wp-settings.php` - no changes need to be made to unit tests to include the autoloader
* An avalanche of `require()` and `require_once()` calls that loaded class files have been removed from the codebase.

The following files have been added to `svn:ignore` - they are not 5.2-compatible and fail during pre-commit:
* src/wp-vendor/autoload.php
* src/wp-vendor/composer/autoload_real.php
* src/wp-vendor/composer/autoload_static.php
* src/wp-vendor/composer/ClassLoader.php

We favor these files instead:
* src/wp-vendor/autoload_52.php
* src/wp-vendor/composer/autoload_real_52.php
* src/wp-vendor/composer/ClassLoader52.php

When new PHP classes are added to the codebase, simply run `composer install` or `composer update` from the project root to update the autoloader.

The future is now.

See #36335.


git-svn-id: https://develop.svn.wordpress.org/trunk@38399 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-27 09:15:01 +00:00
Gary Pendergast 5c4a15d0fc Tests: Disable `foreign_key_checks` while dropping existing tables.
To ensure a clean run, the test suite drops all tables before installing, by simply looping over the table list and dropping them if they exist. This works well for Core, but may fail when a plugin has created a table with foreign key constraints in a previous test run.

Many plugins choose to base their test suite on the Core setup, so making life easier for them is a plus, even if Core doesn't directly need this change.

Props javorszky.

Fixes #37046.



git-svn-id: https://develop.svn.wordpress.org/trunk@37654 602fd350-edb4-49c9-b593-d223f7449a82
2016-06-08 03:03:16 +00:00
John Blackbourn 1ebe4658f1 Remove (or at least reduce) the need to reset common `$_SERVER` variables before assertions or between tests, by introducing a method which automatically resets them during test setup.
See #35954


git-svn-id: https://develop.svn.wordpress.org/trunk@36721 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-26 02:08:47 +00:00
John Blackbourn 6cf0caf13e Unify the initialisation of `$_SERVER` variables during test bootstrap. This abstracts the (re-)initialisation into a function that can be used inside of tests too, before assertions are performed.
See #35954


git-svn-id: https://develop.svn.wordpress.org/trunk@36715 602fd350-edb4-49c9-b593-d223f7449a82
2016-02-25 21:59:56 +00:00
Gary Pendergast d303221d08 Tests: Use the `default_storage_engine` MySQL option on newer MySQL versions.
In MySQL 5.5.3, `storage_engine` was deprecated in favour of `default_storage_engine`, and subsequently removed in MySQL 5.7. To avoid errors when running tests on MySQL 5.7, we need to switch between the options based on MySQL version.

Props skithund, jeremyfelt.

Fixes #34692.



git-svn-id: https://develop.svn.wordpress.org/trunk@36055 602fd350-edb4-49c9-b593-d223f7449a82
2015-12-21 22:26:52 +00:00
John Blackbourn 82cb793355 Initialise `$_SERVER['SERVER_NAME']` during the test bootstrap to avoid individual tests having to do it.
Fixes #34394


git-svn-id: https://develop.svn.wordpress.org/trunk@35350 602fd350-edb4-49c9-b593-d223f7449a82
2015-10-21 23:51:45 +00:00
Scott Taylor 2860548f5b Set `$_SERVER['REQUEST_METHOD']` for unit tests.
Props johnbillion.
Fixes #32636.


git-svn-id: https://develop.svn.wordpress.org/trunk@32785 602fd350-edb4-49c9-b593-d223f7449a82
2015-06-16 00:03:25 +00:00
Boone Gorges bf3773dbfb During PHPUnit tests, don't autodetect permalink structure during WP installation.
The unit tests expect non-pretty permalinks, so there's no benefit to detecting
the ability to have pretty permalinks. Moreover, the `wp_remote_get()` call can
cause installation to hang when there are DNS issues.

Fixes #31994.

git-svn-id: https://develop.svn.wordpress.org/trunk@32139 602fd350-edb4-49c9-b593-d223f7449a82
2015-04-16 23:59:01 +00:00
Boone Gorges 73eee04d38 Unset the default permalink structure after installing Multisite for automated tests.
Most of our unit tests that involve permalinks expect non-pretty permalinks;
this is the default setting for WP. However, when the test suite installs
multisite, `populate_network()` is run before WP recogizes itself as multisite,
which leads to pretty permalinks being set. This breaks a number of unit
tests in ways that are difficult to trace.

git-svn-id: https://develop.svn.wordpress.org/trunk@30267 602fd350-edb4-49c9-b593-d223f7449a82
2014-11-07 01:24:19 +00:00
Scott Taylor 3708cdc7c2 Bring back `define( 'WP_INSTALLING', true );` in `phpunit/includes/install.php`, which was removed in [28965]. tl;dr = wp-cli. Unit tests still pass in multisite because of the skips I added.
Fixes #28738, #28706.


git-svn-id: https://develop.svn.wordpress.org/trunk@28988 602fd350-edb4-49c9-b593-d223f7449a82
2014-07-04 01:38:43 +00:00
Scott Taylor 73bde8a278 Transient timeouts are untestable when `WP_INSTALLING` is defined and set to ANY value. Transient timeouts cannot be tested during multisite runs because `wpmu_create_blog()` sets `WP_INSTALLING`. I have zero idea how these tests ever passed.
See #28706.


git-svn-id: https://develop.svn.wordpress.org/trunk@28965 602fd350-edb4-49c9-b593-d223f7449a82
2014-07-03 01:16:33 +00:00
Andrew Nacin b807bea28c Test framework: Override PHPMailer during installation.
props bpetty.
fixes #26836.


git-svn-id: https://develop.svn.wordpress.org/trunk@26944 602fd350-edb4-49c9-b593-d223f7449a82
2014-01-14 21:55:41 +00:00
Scott Taylor 6603f4802a Always clean install in PHPUnit Tests.
Props bpetty.
Fixes #25871.



git-svn-id: https://develop.svn.wordpress.org/trunk@26095 602fd350-edb4-49c9-b593-d223f7449a82
2013-11-11 22:14:24 +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