Skip to content

Commit

Permalink
Don't run WP SEO tests in multisite
Browse files Browse the repository at this point in the history
Switching blogs in the Blogs connector ended up causing issues in WP SEO which in turn caused issues in EDD. Maybe try switching back to the original blog in the cleanup for that test.
  • Loading branch information
tharsheblows committed Jul 23, 2024
1 parent e90c84a commit dedf412
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 35 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@
],
"test-one": [
"phpunit",
"WP_MULTISITE=1 phpunit"
"WP_MULTISITE=1 phpunit -c phpunit-multisite.xml"
],
"test-multisite": [
"WP_MULTISITE=1 phpunit --coverage-text",
"WP_MULTISITE=1 phpunit -c phpunit-multisite.xml --coverage-text",
"php local/scripts/make-clover-relative.php ./tests/reports/clover.xml"
],
"test-xdebug": [
"XDEBUG_TRIGGER=1 phpunit",
"WP_MULTISITE=1 XDEBUG_TRIGGER=1 phpunit"
"WP_MULTISITE=1 XDEBUG_TRIGGER=1 phpunit -c phpunit-multisite.xml"
],
"test-report": [
"php-coveralls --verbose"
Expand Down
38 changes: 38 additions & 0 deletions phpunit-multisite.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="tests/bootstrap.php"
backupGlobals="false"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
>
<coverage processUncoveredFiles="true">
<include>
<directory prefix="class-" suffix=".php">alerts</directory>
<directory prefix="class-" suffix=".php">classes</directory>
<directory prefix="class-" suffix=".php">connectors</directory>
<directory prefix="class-" suffix=".php">exporters</directory>
<directory prefix="class-" suffix=".php">includes</directory>
</include>
<exclude>
<file>classes/class-cli.php</file>
<directory>includes/lib</directory>
</exclude>
<report>
<clover outputFile="tests/reports/clover.xml"/>
</report>
</coverage>
<php>
<const name="WP_TEST_ACTIVATED_PLUGINS" value="advanced-custom-fields/acf.php,easy-digital-downloads/easy-digital-downloads.php,jetpack/jetpack.php,user-switching/user-switching.php"/>
</php>
<testsuites>
<testsuite name="stream">
<directory prefix="test-" suffix=".php">tests</directory>
</testsuite>
</testsuites>
<logging/>
</phpunit>
47 changes: 24 additions & 23 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
<?xml version="1.0"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="tests/bootstrap.php"
backupGlobals="false"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
>
<coverage processUncoveredFiles="true">
<include>
<directory prefix="class-" suffix=".php">alerts</directory>
<directory prefix="class-" suffix=".php">classes</directory>
<directory prefix="class-" suffix=".php">connectors</directory>
<directory prefix="class-" suffix=".php">exporters</directory>
<directory prefix="class-" suffix=".php">includes</directory>
</include>
<exclude>
<file>classes/class-cli.php</file>
<directory>includes/lib</directory>
</exclude>
<report>
<clover outputFile="tests/reports/clover.xml"/>
</report>
</coverage>
<php>
<const
name="WP_TEST_ACTIVATED_PLUGINS"
value="advanced-custom-fields/acf.php,easy-digital-downloads/easy-digital-downloads.php,jetpack/jetpack.php,user-switching/user-switching.php,wordpress-seo/wp-seo.php"
/>
<const name="WP_TEST_ACTIVATED_PLUGINS" value="advanced-custom-fields/acf.php,easy-digital-downloads/easy-digital-downloads.php,jetpack/jetpack.php,user-switching/user-switching.php,wordpress-seo/wp-seo.php"/>
</php>
<testsuites>
<testsuite name="stream">
<directory prefix="test-" suffix=".php">tests</directory>
</testsuite>
<testsuite name="stream">
<directory prefix="test-" suffix=".php">tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory prefix="class-" suffix=".php">alerts</directory>
<directory prefix="class-" suffix=".php">classes</directory>
<directory prefix="class-" suffix=".php">connectors</directory>
<directory prefix="class-" suffix=".php">exporters</directory>
<directory prefix="class-" suffix=".php">includes</directory>
<exclude>
<file>classes/class-cli.php</file><!-- FIXME: It can't resolve WP_CLI_Command for some reason. -->
<directory>includes/lib</directory>
</exclude>
</whitelist>
</filter>
<logging>
<log type="coverage-clover" target="tests/reports/clover.xml" />
</logging>
<logging/>
</phpunit>
5 changes: 4 additions & 1 deletion tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,12 @@ function () {
define( 'WP_USE_THEMES', false );
define( 'EDD_DOING_TESTS', true );
activate_plugin( 'easy-digital-downloads/easy-digital-downloads.php' );
activate_plugin( 'wordpress-seo/wp-seo.php' );
wp_stream_install_edd();

if ( ! is_multisite() ) {
activate_plugin( 'wordpress-seo/wp-seo.php' );
}

require __DIR__ . '/testcase.php';

// Base class for future tests
Expand Down
4 changes: 4 additions & 0 deletions tests/tests/connectors/test-class-connector-wordpress-seo.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ class Test_WP_Stream_Connector_WordPress_SEO extends WP_StreamTestCase {
public function setUp(): void {
parent::setUp();

if ( is_multisite() ) {
$this->markTestSkipped( 'Currently testing in single sites only.' );
}

$this->plugin->connectors->unload_connectors();

// Make partial of Connector_WordPress_SEO class, with mocked "log" function.
Expand Down
14 changes: 7 additions & 7 deletions tests/tests/test-class-connector.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ public function callback_simulate_fault() {
}

/**
* Log the hyphenated action callback.
*
* @action hyphenated-action
*
* @return void
*/
* Log the hyphenated action callback.
*
* @action hyphenated-action
*
* @return void
*/
public function callback_hyphenated_action() {
do_action( 'wp_stream_test_child_callback_hyphenated_action' );
}
Expand Down Expand Up @@ -125,7 +125,7 @@ public function test_callback() {

public function test_callback_hyphenated() {
global $wp_current_filter;
$action = $this->connector->actions[1];
$action = $this->connector->actions[1];
$wp_current_filter[] = $action; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited

$this->connector->callback();
Expand Down
2 changes: 1 addition & 1 deletion tests/tests/test-class-date-interval.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function test_get_predefined_intervals() {
* Test generate_date_intervals
*
* @return void
* @throws \Exception
* @throws \Exception Emits Exception in case of an error.
*/
public function test_generate_date_intervals() {
$timezone = new \DateTimeZone( 'UTC' );
Expand Down

0 comments on commit dedf412

Please sign in to comment.