Skip to content

Commit

Permalink
chore: Update dependencies like PHPUnit after official PHP 8.4 release (
Browse files Browse the repository at this point in the history
#201)

Signed-off-by: Christopher Klein <[email protected]>
  • Loading branch information
schakko committed Jan 9, 2025
1 parent 2274b34 commit 2f2f42b
Show file tree
Hide file tree
Showing 100 changed files with 1,234 additions and 1,182 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ jobs:
name: Run unit tests
strategy:
matrix:
php: [ "8.1", "8.2", "8.3" ]
phpunit: [ "9.6.20" ]
php: [ "8.1", "8.2", "8.3", "8.4" ]
phpunit: [ "10.5.40" ]

steps:
- uses: actions/checkout@v2
Expand All @@ -37,5 +37,4 @@ jobs:
php_version: ${{ matrix.php }}
version: ${{ matrix.phpunit }}
php_extensions: ldap mbstring
configuration: phpunit.xml
args: --coverage-text --verbose
configuration: phpunit.xml
7 changes: 4 additions & 3 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ on:
tags-ignore:
- '[2-3].[0-9]+.[0-9]+'



jobs:
testing:
runs-on: ubuntu-latest
name: Run unit tests
strategy:
matrix:
php: [ "8.1", "8.2", "8.3" ]
phpunit: [ "9.6.20" ]
php: [ "8.1", "8.2", "8.3", "8.4" ]
phpunit: [ "10.5.40" ]

steps:
- uses: actions/checkout@v2
Expand All @@ -36,7 +38,6 @@ jobs:
version: ${{ matrix.phpunit }}
php_extensions: ldap mbstring
configuration: phpunit.xml
args: --coverage-text --verbose

prerelease:
runs-on: ubuntu-latest
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ on:
# only when an official tag is defined for v3
- '3.[0-9]+.[0-9]+'


jobs:
testing:
runs-on: ubuntu-latest
name: Run unit tests
strategy:
matrix:
php: [ "8.1", "8.2", "8.3" ]
phpunit: [ "9.6.20" ]
php: [ "8.1", "8.2", "8.3", "8.4" ]
phpunit: [ "10.5.40" ]

steps:
- uses: actions/checkout@v2
Expand All @@ -37,7 +38,6 @@ jobs:
version: ${{ matrix.phpunit }}
php_extensions: ldap mbstring
configuration: phpunit.xml
args: --coverage-text --verbose

release:
runs-on: ubuntu-latest
Expand Down
72 changes: 36 additions & 36 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
{
"require-dev": {
"10up/wp_mock": "1.0.1",
"phpunit/phpunit": "9.6.20",
"overtrue/phplint": "^2.3",
"brianhenryie/strauss": "^0.11.1",
"php-mock/php-mock-phpunit": "^2.10"
},
"require": {
"twig/twig": "3.18.0",
"symfony/polyfill-mbstring": "1.20",
"defuse/php-encryption": "2.0.3",
"monolog/monolog": "^2.8.0"
},
"scripts": {
"strauss": [
"vendor/bin/strauss"
],
"twig-patcher": [
"php twig-patcher.php"
],
"post-install-cmd": [
"@strauss",
"@twig-patcher"
],
"post-update-cmd": [
"@strauss",
"@twig-patcher"
]
},
"extra": {
"strauss": {
"target_directory": "vendor-repackaged",
"namespace_prefix": "Dreitier\\Nadi\\Vendor",
"classmap_prefix": "Dreitier_Nadi_Vendor_",
"constant_prefix": "DREITIER_NADI_VENDOR_"
"require-dev": {
"10up/wp_mock": "1.0.1",
"phpunit/phpunit": "10.5.40 as 9.6.20",
"overtrue/phplint": "^2.3",
"brianhenryie/strauss": "^0.11.1",
"php-mock/php-mock-phpunit": "^2.10"
},
"require": {
"twig/twig": "3.18.0",
"symfony/polyfill-mbstring": "1.20",
"defuse/php-encryption": "2.0.3",
"monolog/monolog": "^2.8.0"
},
"scripts": {
"strauss": [
"vendor/bin/strauss"
],
"twig-patcher": [
"php twig-patcher.php"
],
"post-install-cmd": [
"@strauss",
"@twig-patcher"
],
"post-update-cmd": [
"@strauss",
"@twig-patcher"
]
},
"extra": {
"strauss": {
"target_directory": "vendor-repackaged",
"namespace_prefix": "Dreitier\\Nadi\\Vendor",
"classmap_prefix": "Dreitier_Nadi_Vendor_",
"constant_prefix": "DREITIER_NADI_VENDOR_"
}
}
}
}
4 changes: 2 additions & 2 deletions test/ActiveDirectory/ContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

namespace Dreitier\ActiveDirectory;

use Dreitier\Test\BasicTest;
use Dreitier\Test\BasicTestCase;

/**
* @author Christopher Klein <ckl[at]dreitier[dot]com>
* @access private
*/
class ContextTest extends BasicTest
class ContextTest extends BasicTestCase
{
public function setUp(): void
{
Expand Down
4 changes: 2 additions & 2 deletions test/ActiveDirectory/SidTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

namespace Dreitier\ActiveDirectory;

use Dreitier\Test\BasicTest;
use Dreitier\Test\BasicTestCase;

/**
* @author Christopher Klein <ckl[at]dreitier[dot]com>
* @access private
*/
class SidTest extends BasicTest
class SidTest extends BasicTestCase
{

public function setUp(): void
Expand Down
25 changes: 14 additions & 11 deletions test/AdLdap/AdLdapTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
namespace Dreitier\AdLdap;

use Dreitier\Test\PHPUnitHelper;
use PHPUnit\Framework\TestCase;

/**
Expand All @@ -14,10 +15,12 @@ public function __construct(array $options = []) {
class AdLdapTest extends TestCase
{
use \phpmock\phpunit\PHPMock;
private function sut($methods = null, $options = array())
use PHPUnitHelper;

private function sut($methods = [], $options = [])
{
$r = $this->getMockBuilder(AdLdapTestAdapter::class)
->setMethods($methods)
->onlyMethods($methods)
->getMock();

if (!empty($options)) {
Expand Down Expand Up @@ -48,12 +51,12 @@ public function GH_153_inADForestTheUpperDNsAreSearched_whenResolvingTheConfigur

$sut->expects($this->atLeast(2))
->method('_ldap_search')
->withConsecutive(
->with(...self::withConsecutive(
// first call is on deepest level
[adLDAP::PARTITIONS_PREFIX . $baseDn, adLDAP::NETBIOS_MATCHER, []],
// second call is on top level
[adLDAP::PARTITIONS_PREFIX . $topDn, adLDAP::NETBIOS_MATCHER, []]
)
))
->willReturnOnConsecutiveCalls(
// on deepest level, we don't find anything
FALSE,
Expand All @@ -63,10 +66,10 @@ public function GH_153_inADForestTheUpperDNsAreSearched_whenResolvingTheConfigur

$sut->expects($this->once())
->method('_ldap_get_entries')
->withConsecutive(
->with(...self::withConsecutive(
// with the first call, we don't do any further search as we simulate error code 32
[TRUE]
)
[true]
))
->willReturnOnConsecutiveCalls(
// on DC=test,DC=ad we'll find the partition
[
Expand Down Expand Up @@ -97,20 +100,20 @@ public function GH_153_inSingleDomain_theNetbiosConfigurationIsReturned()

$sut->expects($this->once())
->method('_ldap_search')
->withConsecutive(
->with(...self::withConsecutive(
[adLDAP::PARTITIONS_PREFIX . $baseDn, adLDAP::NETBIOS_MATCHER, []],
)
))
->willReturnOnConsecutiveCalls(
// on deepest level, we don't find anything
TRUE,
);

$sut->expects($this->once())
->method('_ldap_get_entries')
->withConsecutive(
->with(...self::withConsecutive(
// find something on top level
[TRUE]
)
))
->willReturnOnConsecutiveCalls(
// on DC=test,DC=ad we'll find the partition
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @author Danny Meißner <[email protected]>
* @access
*/
abstract class BasicIntegrationTest extends BasicTest
class BasicIntegrationTestCase extends BasicTestCase
{
// AD Connection Details
/* @var Connection $connectionDetails */
Expand Down Expand Up @@ -268,7 +268,7 @@ protected function rollbackAdAfterConnectionIt($adLDAP)
*/
protected function createSyncToWordpressItUsersAttributes($numberOfUsers)
{
$attributeCollector = array();
$attributeCollector = [];

for ($i = 0; $i < $numberOfUsers; $i++) {
$attributes = $this->attributes;
Expand Down
14 changes: 8 additions & 6 deletions test/BasicTest.php → test/BasicTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
* @author Tobias Hellmann <[email protected]>
* @access private
*/
abstract class BasicTest extends TestCase
class BasicTestCase extends TestCase
{
use PHPUnitHelper;

public static function setUpBeforeClass(): void
{
NadiLog::$isTestmode = true;
Expand Down Expand Up @@ -73,7 +75,7 @@ public function createMockWithMethods($className, $methods)
return $this->getMockBuilder($className)
->disableOriginalConstructor()
->disableProxyingToOriginalMethods()
->setMethods($methods)
->addMethods($methods)
->getMock();
}

Expand Down Expand Up @@ -130,7 +132,7 @@ public function expects($class, $time, $method, $with, $will)
public function createAnonymousMock($methods)
{
return $this->getMockBuilder('stdClass')
->setMethods($methods)
->addMethods($methods)
->getMock();
}

Expand All @@ -147,7 +149,7 @@ public function createMockedObject($class, $constructor, $methods)
{
return $this->getMockBuilder($class)
->setConstructorArgs($constructor)
->setMethods($methods)
->onlyMethods($methods)
->getMock();
}

Expand All @@ -160,7 +162,7 @@ public function createMockedObject($class, $constructor, $methods)
*
* @return mixed
*/
protected function invokeMethod(&$object, $methodName, $parameters = array())
protected function invokeMethod(&$object, $methodName, $parameters = [])
{
$reflector = new \ReflectionClass(get_class($object));
$method = $reflector->getMethod($methodName);
Expand All @@ -175,7 +177,7 @@ protected function invokeMethod(&$object, $methodName, $parameters = array())
* @param $name
* @param array $parameters
*/
protected function mockWordpressFunction($name, $parameters = array())
protected function mockWordpressFunction($name, $parameters = [])
{
\WP_Mock::userFunction($name, $parameters);
}
Expand Down
15 changes: 5 additions & 10 deletions test/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class WP_Error
public function __construct()
{
$this->value = func_get_args();
$this->errors = array();
$this->errors = [];
}

public function getConstructorArgs()
Expand Down Expand Up @@ -138,13 +138,6 @@ class WP_MS_Sites_List_Table
{

}

// now we can mock this empty class instead of creating a mock from an non existing class
// this is a workaround for a bug https://github.com/sebastianbergmann/phpunit-mock-objects/issues/321
class BlueprintClass
{

}
}

// these three functions are copied from wp-includes/formatting.php
Expand Down Expand Up @@ -181,5 +174,7 @@ function map_deep($value, $callback)
require_once __DIR__ . '/../autoload.php';
require_once __DIR__ . '/../vendor/autoload.php';

require_once NEXT_ACTIVE_DIRECTORY_INTEGRATION_PLUGIN_PATH . "/test/BasicTest.php";
require_once NEXT_ACTIVE_DIRECTORY_INTEGRATION_PLUGIN_PATH . "/test/BasicIntegrationTest.php";
require_once NEXT_ACTIVE_DIRECTORY_INTEGRATION_PLUGIN_PATH . "/test/PHPUnitHelper.php";
require_once NEXT_ACTIVE_DIRECTORY_INTEGRATION_PLUGIN_PATH . "/test/CallableMock.php";
require_once NEXT_ACTIVE_DIRECTORY_INTEGRATION_PLUGIN_PATH . "/test/BasicTestCase.php";
require_once NEXT_ACTIVE_DIRECTORY_INTEGRATION_PLUGIN_PATH . "/test/BasicIntegrationTestCase.php";
20 changes: 20 additions & 0 deletions test/CallableMock.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
namespace Dreitier\Test;

/**
* @see https://github.com/sebastianbergmann/phpunit/issues/5320
*
* @template T
*/
interface CallableMock
{
/**
* @return T
*/
public function __invoke();

/**
* @return T
*/
public function __call(string $name, array $arguments);
}
Loading

0 comments on commit 2f2f42b

Please sign in to comment.