Skip to content

Commit 6d8cfef

Browse files
authored
Merge pull request #11 from magento-amigos/CCENG-125
Test fixes + compatibility with PHP 8.2
2 parents 8528f21 + af2cd89 commit 6d8cfef

File tree

9 files changed

+123
-6
lines changed

9 files changed

+123
-6
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# This is a basic workflow to help you get started with Actions
2+
3+
name: Integration Tests
4+
5+
# Controls when the action will run.
6+
on:
7+
# Triggers the workflow on push or pull request events but only for the main branch
8+
push:
9+
pull_request:
10+
types: [opened, reopened,synchronize]
11+
branches:
12+
- develop
13+
14+
# Allows you to run this workflow manually from the Actions tab
15+
workflow_dispatch:
16+
17+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
18+
jobs:
19+
# This workflow contains a single job called "build"
20+
build:
21+
# The type of runner that the job will run on
22+
runs-on: ubuntu-latest
23+
24+
# Steps represent a sequence of tasks that will be executed as part of the job
25+
steps:
26+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
27+
- uses: actions/checkout@v2
28+
29+
- name: Setup PHP with PECL extension
30+
uses: shivammathur/setup-php@v2
31+
with:
32+
php-version: '8.2'
33+
34+
# Runs a single command using the runners shell
35+
- name: Run composer install
36+
run: composer install
37+
38+
# Runs a single command using the runners shell
39+
- name: Run unit tests
40+
run: php vendor/bin/phpunit tests/Integration

.github/workflows/unit-tests.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# This is a basic workflow to help you get started with Actions
2+
3+
name: Unit Tests
4+
5+
# Controls when the action will run.
6+
on:
7+
# Triggers the workflow on push or pull request events but only for the main branch
8+
push:
9+
pull_request:
10+
types: [opened, reopened,synchronize]
11+
branches:
12+
- develop
13+
14+
# Allows you to run this workflow manually from the Actions tab
15+
workflow_dispatch:
16+
17+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
18+
jobs:
19+
# This workflow contains a single job called "build"
20+
build:
21+
# The type of runner that the job will run on
22+
runs-on: ubuntu-latest
23+
24+
# Steps represent a sequence of tasks that will be executed as part of the job
25+
steps:
26+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
27+
- uses: actions/checkout@v2
28+
29+
- name: Setup PHP with PECL extension
30+
uses: shivammathur/setup-php@v2
31+
with:
32+
php-version: '8.2'
33+
34+
# Runs a single command using the runners shell
35+
- name: Run composer install
36+
run: composer install
37+
38+
# Runs a single command using the runners shell
39+
- name: Run unit tests
40+
run: php vendor/bin/phpunit tests/Unit

src/Magento/ComposerRootUpdatePlugin/Plugin/Commands/RequireCommerceCommand.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ class RequireCommerceCommand extends ExtendableRequireCommand
5151
*/
5252
protected $console;
5353

54+
/**
55+
* @var array
56+
*/
57+
protected $repos;
58+
5459
/**
5560
* Use the native RequireCommand config with options/doc additions for the root project composer.json update
5661
*

src/Magento/ComposerRootUpdatePlugin/Utils/PackageUtils.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public function getEditionLabel(string $packageEdition): ?string
125125
public function findRequire(Composer $composer, string $packageMatcher)
126126
{
127127
$requires = array_values($composer->getPackage()->getRequires());
128-
if (@preg_match($packageMatcher, null) === false) {
128+
if (@preg_match($packageMatcher, '') === false) {
129129
foreach ($requires as $link) {
130130
if ($packageMatcher == $link->getTarget()) {
131131
return $link;

tests/Integration/Magento/ComposerRootUpdatePlugin/_files/expected_no_override.composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
"vendor1/different-conflicting2": "2.0.0",
3131
"vendor1/different-conflicting3": "3.0.0"
3232
},
33+
"config": {
34+
"allow-plugins": true
35+
},
3336
"extra": {
3437
"extra-key1": "install1",
3538
"extra-key2": "target2",

tests/Integration/Magento/ComposerRootUpdatePlugin/_files/expected_override.composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
"Magento\\Sniffs\\": "dev/tests/framework/Magento/Sniffs/"
2323
}
2424
},
25+
"config": {
26+
"allow-plugins": true
27+
},
2528
"conflict": {
2629
"vendor1/conflicting1": "1.0.0",
2730
"vendor1/conflicting2": "2.1.0",

tests/Integration/Magento/ComposerRootUpdatePlugin/_files/test.composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,8 @@
3737
"sample-data": "Suggested Sample Data 1.0.0",
3838
"vendor/suggested": "Another Suggested Package"
3939
},
40+
"config": {
41+
"allow-plugins": true
42+
},
4043
"minimum-stability": "dev"
4144
}

tests/Unit/Magento/ComposerRootUpdatePlugin/Updater/RootPackageRetrieverTest.php

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use Composer\Package\RootPackageInterface;
1616
use Composer\Plugin\PluginInterface;
1717
use Composer\Repository\ComposerRepository;
18-
use Composer\Repository\RepositoryInterface;
18+
use Composer\Repository\LockArrayRepository;
1919
use Composer\Repository\RepositoryManager;
2020
use Composer\Util\RemoteFilesystem;
2121
use Magento\ComposerRootUpdatePlugin\Utils\Console;
@@ -153,7 +153,7 @@ public function testGetOriginalRootNotOnRepo_NoConfirm()
153153

154154
public function testGetTargetRootFromRepo()
155155
{
156-
$this->repo->expects($this->any())->method('loadPackages')->willReturn(
156+
$this->repo->expects($this->atLeast(1))->method('loadPackages')->willReturn(
157157
[
158158
'namesFound' => [$this->originalRoot->getName()],
159159
'packages' => [
@@ -210,7 +210,16 @@ protected function setUp(): void
210210
'isLocked',
211211
'getLockedRepository'
212212
]);
213-
$lockedRepo = $this->getMockForAbstractClass(RepositoryInterface::class);
213+
$lockedRepo = $this->getMockForAbstractClass(
214+
LockArrayRepository::class,
215+
[],
216+
'',
217+
true,
218+
true,
219+
true,
220+
['getPackages'],
221+
false
222+
);
214223
$originalProduct = $this->getMockForAbstractClass(PackageInterface::class);
215224
$originalProduct->method('getName')->willReturn('magento/product-enterprise-edition');
216225
$originalProduct->method('getVersion')->willReturn('1.1.0.0');
@@ -232,11 +241,15 @@ protected function setUp(): void
232241
$this->originalRoot->method('getVersion')->willReturn('1.1.0.0');
233242
$this->originalRoot->method('getStabilityPriority')->willReturn(0);
234243

235-
$this->targetRoot = $this->createPartialMock(Package::class, ['getName', 'getVersion', 'getStabilityPriority']);
244+
$this->targetRoot = $this->createPartialMock(
245+
Package::class,
246+
['getName', 'getVersion', 'getStabilityPriority', 'getPrettyVersion']
247+
);
236248
$this->targetRoot->id = 2;
237249
$this->targetRoot->method('getName')->willReturn('magento/project-enterprise-edition');
238250
$this->targetRoot->method('getVersion')->willReturn('2.0.0.0');
239251
$this->targetRoot->method('getStabilityPriority')->willReturn(0);
252+
$this->targetRoot->method('getPrettyVersion')->willReturn('');
240253

241254
$repoManager = $this->createPartialMock(RepositoryManager::class, ['getRepositories']);
242255
if ($apiMajorVersion == '1') {

tests/Unit/Magento/ComposerRootUpdatePlugin/Updater/RootProjectUpdaterTest.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Composer\Package\Package;
1717
use Composer\Package\RootPackage;
1818
use Composer\Repository\ComposerRepository;
19+
use Composer\Repository\LockArrayRepository;
1920
use Composer\Repository\RepositoryInterface;
2021
use Composer\Repository\RepositoryManager;
2122
use Composer\Semver\Constraint\Constraint;
@@ -273,7 +274,16 @@ public function setUp(): void
273274
$repo = $this->createPartialMock(ComposerRepository::class, []);
274275
$repoManager = $this->createPartialMock(RepositoryManager::class, ['getRepositories']);
275276
$repoManager->method('getRepositories')->willReturn([$repo]);
276-
$lockedRepo = $this->getMockForAbstractClass(RepositoryInterface::class);
277+
$lockedRepo = $this->getMockForAbstractClass(
278+
LockArrayRepository::class,
279+
[],
280+
'',
281+
true,
282+
true,
283+
true,
284+
['getPackages'],
285+
false
286+
);
277287
$lockedRepo->method('getPackages')->willReturn([
278288
new Package('magento/product-community-edition', '1.0.0.0', '1.0.0')
279289
]);

0 commit comments

Comments
 (0)