Skip to content

Commit dc966bd

Browse files
committed
feat: update dependencies for PHP 8.1
1 parent a9e4be5 commit dc966bd

9 files changed

+1022
-582
lines changed

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
"composer/installers": "~1.0 || ~2.0"
1111
},
1212
"require-dev": {
13-
"phpunit/phpunit": "^5.6",
14-
"brain/monkey": "1.*",
15-
"squizlabs/php_codesniffer": "~2.0"
13+
"phpunit/phpunit": "^9.6",
14+
"brain/monkey": "^2.6",
15+
"squizlabs/php_codesniffer": "^3.7"
1616
},
1717
"type": "wordpress-plugin",
1818
"autoload": {

composer.lock

Lines changed: 973 additions & 536 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpunit.xml.dist

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
1-
<phpunit
2-
bootstrap="tests/bootstrap.php"
3-
backupGlobals="false"
4-
colors="true"
5-
convertErrorsToExceptions="true"
6-
convertNoticesToExceptions="true"
7-
convertWarningsToExceptions="true"
8-
>
1+
<?xml version="1.0"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="tests/bootstrap.php" backupGlobals="false" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
3+
<coverage processUncoveredFiles="true">
4+
<include>
5+
<directory suffix=".php">./lib/</directory>
6+
</include>
7+
</coverage>
98
<testsuites>
10-
<testsuite>
9+
<testsuite name="main">
1110
<directory prefix="test-" suffix=".php">./tests/</directory>
1211
</testsuite>
1312
</testsuites>
14-
<filter>
15-
<whitelist processUncoveredFilesFromWhitelist="true">
16-
<directory suffix=".php">./lib/</directory>
17-
</whitelist>
18-
</filter>
1913
</phpunit>

tests/TestCase.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,22 @@
33
namespace ACFComposer\Tests;
44

55
use PHPUnit\Framework;
6+
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
67
use Brain\Monkey;
78

89
class TestCase extends Framework\TestCase
910
{
11+
use MockeryPHPUnitIntegration;
1012

11-
protected function setUp()
13+
protected function setUp() : void
1214
{
1315
parent::setUp();
14-
Monkey::setUpWP();
16+
Monkey\setUp();
1517
}
1618

17-
protected function tearDown()
19+
protected function tearDown() : void
1820
{
19-
Monkey::tearDownWP();
21+
Monkey\tearDown();
2022
parent::tearDown();
2123
}
2224
}

tests/test-acfComposer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class ACFComposerTest extends TestCase
2222
* @runInSeparateProcess
2323
* @preserveGlobalState disabled
2424
*/
25-
public function testRegisterFieldGroup()
25+
public function testRegisterFieldGroup() : void
2626
{
2727
$config = 'this is a config';
2828
$fieldGroup = 'this is a field group';
@@ -32,7 +32,7 @@ public function testRegisterFieldGroup()
3232
->with($config)
3333
->once()
3434
->andReturn($fieldGroup);
35-
Functions::expect('acf_add_local_field_group')
35+
Functions\expect('acf_add_local_field_group')
3636
->with($fieldGroup)
3737
->once()
3838
->andReturn($returnValue);

tests/test-resolveConfigForField.php

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
require_once dirname(__DIR__) . '/lib/ACFComposer/ResolveConfig.php';
66

77
use Exception;
8-
use Brain\Monkey\WP\Filters;
8+
use Brain\Monkey\Filters;
99
use ACFComposer\ResolveConfig;
1010

1111
class ResolveConfigForFieldTest extends TestCase
@@ -72,7 +72,7 @@ public function testForFieldGetConfigFromFilter()
7272
'label' => 'Some Field',
7373
'type' => 'someType'
7474
];
75-
Filters::expectApplied($config)
75+
Filters\expectApplied($config)
7676
->with(null)
7777
->once()
7878
->andReturn($someField);
@@ -90,7 +90,7 @@ public function testForFieldGetConfigFromFilterWithArgument()
9090
'label' => 'Some Field',
9191
'type' => 'someType'
9292
];
93-
Filters::expectApplied($filter)
93+
Filters\expectApplied($filter)
9494
->with(null, 'prefix')
9595
->once()
9696
->andReturn($someField);
@@ -116,7 +116,7 @@ public function testMultipleForFieldGetConfigFromFilterWithArgument()
116116
'type' => 'someType'
117117
]
118118
];
119-
Filters::expectApplied($filter)
119+
Filters\expectApplied($filter)
120120
->with(null, 'prefix')
121121
->once()
122122
->andReturn($someField);
@@ -141,7 +141,7 @@ public function testForFieldGetConfigFromFilterWithArgumentAndConditionalLogic()
141141
'label' => 'Some Field',
142142
'type' => 'someType'
143143
];
144-
Filters::expectApplied($filter)
144+
Filters\expectApplied($filter)
145145
->with(null, 'prefix')
146146
->once()
147147
->andReturn($someField);
@@ -161,7 +161,7 @@ public function testForFieldGetConfigFromFilterWithArgumentAndConditionalLogic()
161161
]
162162
]
163163
];
164-
Filters::expectApplied($filterConditional)
164+
Filters\expectApplied($filterConditional)
165165
->with(null, 'otherprefix')
166166
->once()
167167
->andReturn($someFieldWithConditional);
@@ -186,18 +186,26 @@ public function testForFieldGetConfigFromFilterWithArgumentAndConditionalLogic()
186186

187187
public function testForFieldTriggerErrorWithoutFilter()
188188
{
189+
set_error_handler(
190+
static function ($errno, $errstr) {
191+
restore_error_handler();
192+
throw new Exception($errstr, $errno);
193+
},
194+
E_ALL
195+
);
196+
189197
$config = 'ACFComposer/Fields/someField';
190-
Filters::expectApplied($config)
198+
Filters\expectApplied($config)
191199
->once()
192200
->andReturn(null);
193-
$this->expectException('PHPUnit_Framework_Error_Warning');
194-
$output = ResolveConfig::forField($config);
201+
$this->expectException(Exception::class);
202+
ResolveConfig::forField($config);
195203
}
196204

197205
public function testForFieldReturnEmptyArrayWithoutFilter()
198206
{
199207
$config = 'ACFComposer/Fields/someField';
200-
Filters::expectApplied($config)
208+
Filters\expectApplied($config)
201209
->once()
202210
->andReturn(null);
203211
$output = @ResolveConfig::forField($config);
@@ -264,7 +272,7 @@ public function testAppliesResolveFilterGeneric()
264272
];
265273
$resolvedConfig = $config;
266274
$resolvedConfig['key'] = 'field_someField';
267-
Filters::expectApplied('ACFComposer/resolveEntity')
275+
Filters\expectApplied('ACFComposer/resolveEntity')
268276
->once()
269277
->with($resolvedConfig)
270278
->andReturn(array_merge($resolvedConfig, ['foo' => 'bar']));
@@ -283,7 +291,7 @@ public function testAppliesResolveFilterByName()
283291
];
284292
$resolvedConfig = $config;
285293
$resolvedConfig['key'] = 'field_someField';
286-
Filters::expectApplied('ACFComposer/resolveEntity?name=someField')
294+
Filters\expectApplied('ACFComposer/resolveEntity?name=someField')
287295
->once()
288296
->with($resolvedConfig)
289297
->andReturn(array_merge($resolvedConfig, ['foo' => 'bar']));
@@ -302,7 +310,7 @@ public function testAppliesResolveFilterByKey()
302310
];
303311
$resolvedConfig = $config;
304312
$resolvedConfig['key'] = 'field_someField';
305-
Filters::expectApplied('ACFComposer/resolveEntity?key=field_someField')
313+
Filters\expectApplied('ACFComposer/resolveEntity?key=field_someField')
306314
->once()
307315
->with($resolvedConfig)
308316
->andReturn(array_merge($resolvedConfig, ['foo' => 'bar']));
@@ -470,7 +478,7 @@ public function testResolveMultipleFieldsFromFilter()
470478
'label' => 'Filter Field Two',
471479
'type' => 'someType',
472480
];
473-
Filters::expectApplied($filter)
481+
Filters\expectApplied($filter)
474482
->once()
475483
->andReturn([
476484
$filterFieldOne,

tests/test-resolveConfigForFieldGroup.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
require_once dirname(__DIR__) . '/lib/ACFComposer/ResolveConfig.php';
66

77
use Exception;
8-
use Brain\Monkey\WP\Filters;
8+
use Brain\Monkey\Filters;
99
use ACFComposer\ResolveConfig;
1010

1111
class ResolveConfigForFieldGroupTest extends TestCase
@@ -48,7 +48,7 @@ public function testForFieldGroupWithValidConfig()
4848
]
4949
];
5050

51-
Filters::expectApplied($filterName)
51+
Filters\expectApplied($filterName)
5252
->once()
5353
->andReturn($fieldConfig);
5454

@@ -142,10 +142,10 @@ public function testForFieldGroupWithNestedFilters()
142142
]
143143
]
144144
];
145-
Filters::expectApplied($subFieldFilter)
145+
Filters\expectApplied($subFieldFilter)
146146
->once()
147147
->andReturn($subFieldConfig);
148-
Filters::expectApplied($someLayoutFilter)
148+
Filters\expectApplied($someLayoutFilter)
149149
->once()
150150
->andReturn($someLayoutConfig);
151151
$output = ResolveConfig::forFieldGroup($masterLayout);

tests/test-resolveConfigForLayout.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
require_once dirname(__DIR__) . '/lib/ACFComposer/ResolveConfig.php';
66

77
use Exception;
8-
use Brain\Monkey\WP\Filters;
8+
use Brain\Monkey\Filters;
99
use ACFComposer\ResolveConfig;
1010

1111
class ResolveConfigForLayoutTest extends TestCase
@@ -57,7 +57,7 @@ public function testForLayoutGetConfigFromFilter()
5757
'name' => 'someLayout',
5858
'label' => 'Some Layout'
5959
];
60-
Filters::expectApplied($config)
60+
Filters\expectApplied($config)
6161
->once()
6262
->andReturn($someLayout);
6363
$output = ResolveConfig::forLayout($config);
@@ -133,7 +133,7 @@ public function testforLayoutGetConfigFromFilterWithArgumentAndNestedConditional
133133
]
134134
];
135135

136-
Filters::expectApplied($filter)
136+
Filters\expectApplied($filter)
137137
->with(null, 'prefix')
138138
->once()
139139
->andReturn($layout);

tests/test-resolveConfigForLocation.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
require_once dirname(__DIR__) . '/lib/ACFComposer/ResolveConfig.php';
66

77
use Exception;
8-
use Brain\Monkey\WP\Filters;
98
use ACFComposer\ResolveConfig;
109

11-
class ResolveConfigForLocationTest extends TestCase
10+
final class ResolveConfigForLocationTest extends TestCase
1211
{
1312
public function testForLocationWithValidConfig()
1413
{

0 commit comments

Comments
 (0)