Skip to content

Commit

Permalink
Make integration tests run on PHPUnit 10
Browse files Browse the repository at this point in the history
  • Loading branch information
chesio committed Mar 1, 2024
1 parent dc43d5a commit 4a702d2
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 27 deletions.
10 changes: 1 addition & 9 deletions tests/integration/phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
bootstrap="./bootstrap.php"
backupGlobals="false"
cacheResult="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="./bootstrap.php" backupGlobals="false" cacheResult="false" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd">
<testsuites>
<testsuite name="BC Security integration test">
<directory suffix="Test.php">./src/Cases</directory>
Expand Down
9 changes: 4 additions & 5 deletions tests/integration/src/Cases/Helpers/HaveIBeenPwnedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
use BlueChip\Security\Helpers\HaveIBeenPwned;
use BlueChip\Security\Tests\Integration\Constants;
use BlueChip\Security\Tests\Integration\TestCase;
use PHPUnit\Framework\Attributes\Group;

/**
* Test integration with Pwned Passwords API.
*
* @internal These tests result in external requests to https://api.pwnedpasswords.com being made!
*/
class HaveIBeenPwnedTest extends TestCase
final class HaveIBeenPwnedTest extends TestCase
{
/**
* Test that pwned password is reported as such.
*
* @group external
*/
#[Group('external')]
public function testPwnedPassword()
{
$result = HaveIBeenPwned::hasPasswordBeenPwned(Constants::PWNED_PASSWORD);
Expand All @@ -35,9 +35,8 @@ public function testPwnedPassword()

/**
* Test that safe password is reported as such.
*
* @group external
*/
#[Group('external')]
public function testSafePassword()
{
$result = HaveIBeenPwned::hasPasswordBeenPwned(Constants::SAFE_PASSWORD);
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/src/Cases/Helpers/IsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use BlueChip\Security\Helpers\Is;
use BlueChip\Security\Tests\Integration\TestCase;

class IsTest extends TestCase
final class IsTest extends TestCase
{
/**
* Test Is::admin() method and `bc-security/filter:is-admin` filter.
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/src/Cases/Helpers/UtilsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use BlueChip\Security\Helpers\Utils;
use BlueChip\Security\Tests\Integration\TestCase;

class UtilsTest extends TestCase
final class UtilsTest extends TestCase
{
/**
* Ensure that blocking access results in wp_die() being called with proper response code.
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/src/Cases/Modules/Cron/JobTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use BlueChip\Security\Modules\Cron;
use BlueChip\Security\Tests\Integration\TestCase;

class JobTest extends TestCase
final class JobTest extends TestCase
{
private const HOOK = 'test-job';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
use BlueChip\Security\Setup\IpAddress;
use BlueChip\Security\Tests\Integration\Constants;
use BlueChip\Security\Tests\Integration\TestCase;
use PHPUnit\Framework\Attributes\Group;

/**
* Test integration of external blocklists.
*
* @internal These tests result in external requests!
*/
class ManagerTest extends TestCase
final class ManagerTest extends TestCase
{
protected function prepareTest(): void
{
Expand All @@ -32,9 +33,8 @@ protected function prepareTest(): void

/**
* Test external blocklist populated with IP prefixes for Amazon Web Services.
*
* @group external
*/
#[Group('external')]
public function testAmazonWebServicesBlocklist()
{
// Refresh external blocklist.
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/src/Cases/Modules/Hardening/ActiveTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
namespace BlueChip\Security\Tests\Integration\Cases\Modules\Hardening;

use BlueChip\Security\Tests\Integration\Constants;
use PHPUnit\Framework\Attributes\Group;

/**
* Test hardening with all options on.
*/
class ActiveTest extends TestCase
final class ActiveTest extends TestCase
{
protected function prepareTest(): void
{
Expand Down Expand Up @@ -40,9 +41,8 @@ public function testHardeningActive(): void

/**
* Test user editation with password change.
*
* @group external
*/
#[Group('external')]
public function testPasswordChange(): void
{
// Test strong password - should pass.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
namespace BlueChip\Security\Tests\Integration\Cases\Modules\Hardening;

use BlueChip\Security\Tests\Integration\Constants;
use PHPUnit\Framework\Attributes\Group;

/**
* Test hardening with all options off.
*/
class InactiveTest extends TestCase
final class InactiveTest extends TestCase
{
protected function prepareTest(): void
{
Expand Down Expand Up @@ -40,9 +41,8 @@ public function testHardeningInactive(): void

/**
* Test user editation with password change.
*
* @group external
*/
#[Group('external')]
public function testPasswordChange(): void
{
// Test strong password - should pass.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use BlueChip\Security\Tests\Integration\Constants;
use BlueChip\Security\Tests\Integration\TestCase;

class GatekeeperTest extends TestCase
final class GatekeeperTest extends TestCase
{
/**
* @internal WP test suite already includes user with username `admin`, so there is no need to explicitly create it.
Expand Down
11 changes: 11 additions & 0 deletions tests/integration/src/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@
*/
abstract class TestCase extends \WP_UnitTestCase
{
/**
* @internal Overriding this method from \WP_UnitTestCase_Base class allows our tests to run on PHPUnit 10.
*
* @link https://core.trac.wordpress.org/ticket/59486#comment:6
*/
public function expectDeprecated(): void
{
return;
}


/**
* Allow to load the plugin with context customised for particular test suite.
*/
Expand Down

0 comments on commit 4a702d2

Please sign in to comment.