Skip to content

Commit e9c6905

Browse files
authored
Merge pull request #294 from bigcommerce/phpmnt-69-upgrade-phpunit
Upgrade php & phpunit
2 parents 68ccc74 + df5703b commit e9c6905

37 files changed

+329
-470
lines changed

.circleci/config.yml

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,35 @@ orbs:
44
ci: bigcommerce/internal@volatile
55
php: bigcommerce/internal-php@volatile
66

7-
default_matrix: &default_matrix
7+
define: &php_min "8.1"
8+
9+
jobs_default: &jobs_default
10+
e:
11+
name: php/php
12+
php-version: << matrix.php-version >>
813
matrix:
914
parameters:
10-
php-version: [ "8.0", "8.1", "8.2" ]
15+
php-version: [ *php_min, "8.2" ]
16+
17+
jobs:
18+
cs-fixer:
19+
executor:
20+
name: php/php
21+
php-version: *php_min
22+
steps:
23+
- ci/pre-setup
24+
- php/composer-install
25+
- run: ./vendor/bin/php-cs-fixer fix --diff --dry-run -v
1126

1227
workflows:
1328
version: 2
1429
full:
1530
jobs:
1631
- php/phpunit-tests:
17-
<<: *default_matrix
18-
configuration: "phpunit.xml.dist"
32+
<<: *jobs_default
33+
minimum_coverage: 60
1934
- php/static-analysis:
20-
<<: *default_matrix
35+
<<: *jobs_default
2136
generate_ide_helper: false
37+
- cs-fixer
38+

.gitignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ composer.lock
44
script/*
55

66
# Testing
7-
/phpunit.xml
87
/build
98
/test/reports
109
.env
1110
.idea
1211
/.php_cs
13-
/.php_cs.cache
14-
/.phpunit.result.cache
12+
/*.cache

.php-cs-fixer.dist.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
return (new PhpCsFixer\Config())
3+
->setFinder(
4+
PhpCsFixer\Finder::create()
5+
->files()
6+
->in(__DIR__)
7+
->name("*.php")
8+
->ignoreVCSIgnored(true)
9+
)
10+
->setRules([
11+
'@PSR2' => true,
12+
]);

.php_cs.dist

Lines changed: 0 additions & 11 deletions
This file was deleted.

composer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,16 @@
1818
}
1919
],
2020
"require": {
21-
"php": ">=8.0",
21+
"php": ">=8.1",
2222
"firebase/php-jwt": "~5.0 || ~6.0",
2323
"ext-curl": "*"
2424
},
2525
"require-dev": {
2626
"friendsofphp/php-cs-fixer": "^3.13",
2727
"php-coveralls/php-coveralls": "2.5",
28-
"phpunit/phpunit": "^9.5",
29-
"phpstan/phpstan": "^1.10"
28+
"phpunit/phpunit": "^10.0",
29+
"phpstan/phpstan": "^1.10",
30+
"rector/rector": "^0.19.0"
3031
},
3132
"autoload": {
3233
"psr-0": {

phpunit.xml.dist renamed to phpunit.xml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" backupGlobals="true" backupStaticAttributes="true" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" forceCoversAnnotation="false" processIsolation="false" bootstrap="vendor/autoload.php">
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" backupGlobals="true" colors="true" bootstrap="vendor/autoload.php" cacheDirectory=".phpunit.cache" backupStaticProperties="true" requireCoverageMetadata="false">
33
<coverage>
4-
<include>
5-
<directory suffix=".php">src/</directory>
6-
</include>
74
<report>
85
<clover outputFile="build/logs/clover.xml"/>
96
<html outputDirectory="test/reports/coverage/"/>
@@ -19,4 +16,9 @@
1916
<directory>test/</directory>
2017
</testsuite>
2118
</testsuites>
19+
<source>
20+
<include>
21+
<directory suffix=".php">src/</directory>
22+
</include>
23+
</source>
2224
</phpunit>

rector.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
6+
use Rector\Config\RectorConfig;
7+
use Rector\PHPUnit\Set\PHPUnitSetList;
8+
use Rector\Set\ValueObject\LevelSetList;
9+
10+
return static function (RectorConfig $rectorConfig): void {
11+
$rectorConfig->paths([__DIR__ . '/test']);
12+
$rectorConfig->sets([
13+
PHPUnitSetList::PHPUNIT_100
14+
]);
15+
};

src/Bigcommerce/Api/Connection.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,8 @@ public function getHeaders()
609609
*/
610610
public function __destruct()
611611
{
612-
curl_close($this->curl);
612+
if ($this->curl !== null) {
613+
curl_close($this->curl);
614+
}
613615
}
614616
}

0 commit comments

Comments
 (0)