Skip to content

Commit

Permalink
Merge pull request #11 from magento-amigos/CCENG-125
Browse files Browse the repository at this point in the history
Test fixes + compatibility with PHP 8.2
  • Loading branch information
sidolov authored Feb 13, 2023
2 parents 8528f21 + af2cd89 commit 6d8cfef
Show file tree
Hide file tree
Showing 9 changed files with 123 additions and 6 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This is a basic workflow to help you get started with Actions

name: Integration Tests

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
pull_request:
types: [opened, reopened,synchronize]
branches:
- develop

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

- name: Setup PHP with PECL extension
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'

# Runs a single command using the runners shell
- name: Run composer install
run: composer install

# Runs a single command using the runners shell
- name: Run unit tests
run: php vendor/bin/phpunit tests/Integration
40 changes: 40 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This is a basic workflow to help you get started with Actions

name: Unit Tests

# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
pull_request:
types: [opened, reopened,synchronize]
branches:
- develop

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

- name: Setup PHP with PECL extension
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'

# Runs a single command using the runners shell
- name: Run composer install
run: composer install

# Runs a single command using the runners shell
- name: Run unit tests
run: php vendor/bin/phpunit tests/Unit
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ class RequireCommerceCommand extends ExtendableRequireCommand
*/
protected $console;

/**
* @var array
*/
protected $repos;

/**
* Use the native RequireCommand config with options/doc additions for the root project composer.json update
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public function getEditionLabel(string $packageEdition): ?string
public function findRequire(Composer $composer, string $packageMatcher)
{
$requires = array_values($composer->getPackage()->getRequires());
if (@preg_match($packageMatcher, null) === false) {
if (@preg_match($packageMatcher, '') === false) {
foreach ($requires as $link) {
if ($packageMatcher == $link->getTarget()) {
return $link;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
"vendor1/different-conflicting2": "2.0.0",
"vendor1/different-conflicting3": "3.0.0"
},
"config": {
"allow-plugins": true
},
"extra": {
"extra-key1": "install1",
"extra-key2": "target2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
"Magento\\Sniffs\\": "dev/tests/framework/Magento/Sniffs/"
}
},
"config": {
"allow-plugins": true
},
"conflict": {
"vendor1/conflicting1": "1.0.0",
"vendor1/conflicting2": "2.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,8 @@
"sample-data": "Suggested Sample Data 1.0.0",
"vendor/suggested": "Another Suggested Package"
},
"config": {
"allow-plugins": true
},
"minimum-stability": "dev"
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use Composer\Package\RootPackageInterface;
use Composer\Plugin\PluginInterface;
use Composer\Repository\ComposerRepository;
use Composer\Repository\RepositoryInterface;
use Composer\Repository\LockArrayRepository;
use Composer\Repository\RepositoryManager;
use Composer\Util\RemoteFilesystem;
use Magento\ComposerRootUpdatePlugin\Utils\Console;
Expand Down Expand Up @@ -153,7 +153,7 @@ public function testGetOriginalRootNotOnRepo_NoConfirm()

public function testGetTargetRootFromRepo()
{
$this->repo->expects($this->any())->method('loadPackages')->willReturn(
$this->repo->expects($this->atLeast(1))->method('loadPackages')->willReturn(
[
'namesFound' => [$this->originalRoot->getName()],
'packages' => [
Expand Down Expand Up @@ -210,7 +210,16 @@ protected function setUp(): void
'isLocked',
'getLockedRepository'
]);
$lockedRepo = $this->getMockForAbstractClass(RepositoryInterface::class);
$lockedRepo = $this->getMockForAbstractClass(
LockArrayRepository::class,
[],
'',
true,
true,
true,
['getPackages'],
false
);
$originalProduct = $this->getMockForAbstractClass(PackageInterface::class);
$originalProduct->method('getName')->willReturn('magento/product-enterprise-edition');
$originalProduct->method('getVersion')->willReturn('1.1.0.0');
Expand All @@ -232,11 +241,15 @@ protected function setUp(): void
$this->originalRoot->method('getVersion')->willReturn('1.1.0.0');
$this->originalRoot->method('getStabilityPriority')->willReturn(0);

$this->targetRoot = $this->createPartialMock(Package::class, ['getName', 'getVersion', 'getStabilityPriority']);
$this->targetRoot = $this->createPartialMock(
Package::class,
['getName', 'getVersion', 'getStabilityPriority', 'getPrettyVersion']
);
$this->targetRoot->id = 2;
$this->targetRoot->method('getName')->willReturn('magento/project-enterprise-edition');
$this->targetRoot->method('getVersion')->willReturn('2.0.0.0');
$this->targetRoot->method('getStabilityPriority')->willReturn(0);
$this->targetRoot->method('getPrettyVersion')->willReturn('');

$repoManager = $this->createPartialMock(RepositoryManager::class, ['getRepositories']);
if ($apiMajorVersion == '1') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Composer\Package\Package;
use Composer\Package\RootPackage;
use Composer\Repository\ComposerRepository;
use Composer\Repository\LockArrayRepository;
use Composer\Repository\RepositoryInterface;
use Composer\Repository\RepositoryManager;
use Composer\Semver\Constraint\Constraint;
Expand Down Expand Up @@ -273,7 +274,16 @@ public function setUp(): void
$repo = $this->createPartialMock(ComposerRepository::class, []);
$repoManager = $this->createPartialMock(RepositoryManager::class, ['getRepositories']);
$repoManager->method('getRepositories')->willReturn([$repo]);
$lockedRepo = $this->getMockForAbstractClass(RepositoryInterface::class);
$lockedRepo = $this->getMockForAbstractClass(
LockArrayRepository::class,
[],
'',
true,
true,
true,
['getPackages'],
false
);
$lockedRepo->method('getPackages')->willReturn([
new Package('magento/product-community-edition', '1.0.0.0', '1.0.0')
]);
Expand Down

0 comments on commit 6d8cfef

Please sign in to comment.