Skip to content

Commit

Permalink
QA: Make the unit tests PHPUnit cross-version compatible (#201)
Browse files Browse the repository at this point in the history
QA: Make the unit tests PHPUnit cross-version compatible
  • Loading branch information
IreneStr authored May 21, 2019
2 parents b7e31c4 + e13949a commit a01fa9a
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 28 deletions.
15 changes: 15 additions & 0 deletions .phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,19 @@
</properties>
</rule>


<!--
#############################################################################
TEMPORARY ADJUSTMENTS
Adjustments which should be removed once the associated issue has been resolved.
#############################################################################
-->

<!-- Namespaced test classes imported via a use statement are not yet correctly excluded
by WPCS. This will most likely be fixed once PHPCS 3.5.0 has been released and
WPCS has upgraded to that version. -->
<rule ref="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound">
<exclude-pattern>/tests/php/unit/Dependencies/yoast-seo-dependency-test\.php$</exclude-pattern>
</rule>

</ruleset>
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"require-dev": {
"php": ">=5.6.0",
"brain/monkey": "2.*",
"phpunit/phpunit": "5.*",
"phpunit/phpunit": "^5.4 || ^6.0 || ^7.0",
"yoast/yoastcs": "^1.2.2"
},
"autoload": {
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 21 additions & 18 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/5.7/phpunit.xsd"
backupGlobals="false"
beStrictAboutCoversAnnotation="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutTodoAnnotatedTests="true"
verbose="true">
<testsuites>
<testsuite name="unit">
<directory suffix="test.php">tests/php/unit</directory>
</testsuite>
</testsuites>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/7.5/phpunit.xsd"
backupGlobals="false"
beStrictAboutCoversAnnotation="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutTodoAnnotatedTests="true"
bootstrap="vendor/autoload.php"
verbose="true"
>
<testsuites>
<testsuite name="unit">
<directory suffix="test.php">tests/php/unit</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory suffix=".php">inc/</directory>
</whitelist>
</filter>
<filter>
<whitelist>
<directory suffix=".php">inc/</directory>
</whitelist>
</filter>
</phpunit>
3 changes: 2 additions & 1 deletion tests/php/unit/Configuration/configuration-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
use Brain\Monkey;
use Brain\Monkey\Filters;
use Brain\Monkey\Functions;
use PHPUnit\Framework\TestCase;

/**
* Class Configuration_Test.
*/
class Configuration_Test extends \PHPUnit_Framework_TestCase {
class Configuration_Test extends TestCase {

/**
* Sets up test fixtures.
Expand Down
4 changes: 3 additions & 1 deletion tests/php/unit/Configuration/string-store-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

namespace Yoast\AcfAnalysis\Tests\Configuration;

use PHPUnit\Framework\TestCase;

/**
* Class String_Store_Test.
*/
class String_Store_Test extends \PHPUnit_Framework_TestCase {
class String_Store_Test extends TestCase {

/**
* Gets the blacklist string store.
Expand Down
3 changes: 2 additions & 1 deletion tests/php/unit/Dependencies/acf-dependency-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
namespace Yoast\AcfAnalysis\Tests\Dependencies;

use Brain\Monkey;
use PHPUnit\Framework\TestCase;

/**
* Class ACF_Dependency_Test.
*/
class ACF_Dependency_Test extends \PHPUnit_Framework_TestCase {
class ACF_Dependency_Test extends TestCase {

/**
* Sets up test fixtures.
Expand Down
3 changes: 2 additions & 1 deletion tests/php/unit/Dependencies/yoast-seo-dependency-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
namespace Yoast\AcfAnalysis\Tests\Dependencies;

use Brain\Monkey;
use PHPUnit\Framework\TestCase;

/**
* Class Yoast_SEO_Dependency_Test.
*/
class Yoast_SEO_Dependency_Test extends \PHPUnit_Framework_TestCase {
class Yoast_SEO_Dependency_Test extends TestCase {

/**
* Whether or not to preserve the global state.
Expand Down
3 changes: 2 additions & 1 deletion tests/php/unit/assets-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

use Brain\Monkey;
use Brain\Monkey\Functions;
use PHPUnit\Framework\TestCase;

/**
* Class Assets_Test.
*/
class Assets_Test extends \PHPUnit_Framework_TestCase {
class Assets_Test extends TestCase {

/**
* Whether or not to preserve the global state.
Expand Down
3 changes: 2 additions & 1 deletion tests/php/unit/main-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
namespace Yoast\AcfAnalysis\Tests;

use Brain\Monkey;
use PHPUnit\Framework\TestCase;

/**
* Class Main_Test.
*/
class Main_Test extends \PHPUnit_Framework_TestCase {
class Main_Test extends TestCase {

/**
* Sets up test fixtures.
Expand Down
4 changes: 3 additions & 1 deletion tests/php/unit/registry-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

namespace Yoast\AcfAnalysis\Tests\Configuration;

use PHPUnit\Framework\TestCase;

/**
* Class Registry_Test.
*/
class Registry_Test extends \PHPUnit_Framework_TestCase {
class Registry_Test extends TestCase {

/**
* Tests that the singleton instance is properly set and that every call to the registry, is the same instance.
Expand Down
3 changes: 2 additions & 1 deletion tests/php/unit/requirements-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
use Brain\Monkey;
use Brain\Monkey\Functions;
use Brain\Monkey\Filters;
use PHPUnit\Framework\TestCase;
use Yoast\AcfAnalysis\Tests\Doubles\Passing_Dependency;
use Yoast\AcfAnalysis\Tests\Doubles\Failing_Dependency;

/**
* Class Requirements_Test.
*/
class Requirements_Test extends \PHPUnit_Framework_TestCase {
class Requirements_Test extends TestCase {

/**
* Sets up test fixtures.
Expand Down

0 comments on commit a01fa9a

Please sign in to comment.