Skip to content

Commit 0297b45

Browse files
Merge branch 'develop-10' into ECP-9387
2 parents 51a27ff + 9056277 commit 0297b45

38 files changed

+420
-502
lines changed

.github/Dockerfile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ MAGENTO_LANGUAGE=en_US \
2323
MAGENTO_CURRENCY=EUR \
2424
MAGENTO_TZ=Europe/Amsterdam \
2525
DEPLOY_SAMPLEDATA=0 \
26-
USE_SSL=1
26+
USE_SSL=1 \
27+
XDEBUG_MODE=coverage
2728

2829
RUN apt-get update \
2930
&& apt-get install -y libjpeg62-turbo-dev \
@@ -42,9 +43,13 @@ RUN apt-get update \
4243
RUN docker-php-ext-configure gd --with-freetype --with-jpeg
4344
RUN docker-php-ext-configure ftp --with-openssl-dir=/usr
4445
RUN docker-php-ext-install -j$(nproc) bcmath gd intl pdo_mysql simplexml soap sockets xsl zip ftp
46+
RUN pecl install xdebug && docker-php-ext-enable xdebug
47+
4548
RUN a2enmod ssl
46-
RUN a2ensite default-ssl.conf #can be removed if not needed
49+
RUN a2ensite default-ssl.conf
50+
4751
WORKDIR /var/www/html
52+
4853
COPY config/php.ini /usr/local/etc/php/
4954
COPY scripts/install_magento.sh /tmp/install_magento.sh
5055

.github/Makefile

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ magento:
1515
install:
1616
composer config --json repositories.local '{"type": "path", "url": "/data/extensions/workdir", "options": { "symlink": false } }'
1717
composer require "adyen/module-payment:*"
18-
vendor/bin/phpcs --standard=Magento2 --extensions=php,phtml --error-severity=10 -n -p vendor/adyen/module-payment
1918
bin/magento module:enable Adyen_Payment
2019
bin/magento setup:upgrade
2120
bin/magento setup:di:compile
@@ -127,3 +126,20 @@ mftf:
127126

128127
phpstan-run:
129128
vendor/bin/phpstan analyse -c vendor/adyen/module-payment/phpstan.neon
129+
130+
phpunit-run:
131+
cp vendor/adyen/module-payment/Test/phpunit.xml.dist dev/tests/unit/phpunit.xml
132+
cd dev/tests/unit; \
133+
../../../vendor/bin/phpunit \
134+
--coverage-clover=../../../build/clover.xml \
135+
--log-junit=../../../build/tests-log.xml \
136+
-c phpunit.xml \
137+
../../../vendor/adyen/module-payment/Test/Unit
138+
139+
codesniffer-run:
140+
vendor/bin/phpcs --standard=Magento2 \
141+
--extensions=php,phtml \
142+
--error-severity=10 \
143+
--warning-severity=0 \
144+
--ignore-annotations \
145+
-p vendor/adyen/module-payment

.github/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ services:
5858
- ./Makefile:/var/www/html/Makefile
5959
- composer:/usr/local/bin
6060
- magento:/var/www/html
61+
- ../build:/var/www/html/build
6162
networks:
6263
backend:
6364
volumes:

.github/workflows/main.yml

Lines changed: 43 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,70 @@
1-
name: Main CI workflow
1+
name: Main
2+
run-name: Main
23

34
on:
45
pull_request:
6+
branches: [main, develop-10]
57
pull_request_target:
6-
workflow_dispatch:
8+
branches: [main, develop-10]
79

810
jobs:
911
build:
1012
if: (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) || (github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository) || (github.event_name == 'workflow_dispatch')
1113
environment: ${{ (github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository) && 'external' || 'internal' }}
12-
runs-on: ubuntu-latest
13-
timeout-minutes: 25
1414
strategy:
1515
matrix:
16-
php-version: [8.2,8.3]
17-
16+
php-version: ["8.3"]
17+
magento-version: ["2.4.8"]
18+
runs-on: ubuntu-latest
19+
timeout-minutes: 15
20+
env:
21+
PHP_VERSION: ${{ matrix.php-version }}
22+
MAGENTO_VERSION: ${{ matrix.magento-version }}
23+
ADYEN_API_KEY: ${{secrets.ADYEN_API_KEY}}
24+
ADYEN_CLIENT_KEY: ${{secrets.ADYEN_CLIENT_KEY}}
25+
ADYEN_MERCHANT: ${{secrets.ADYEN_MERCHANT}}
26+
ADMIN_USERNAME: ${{secrets.MAGENTO_ADMIN_USERNAME}}
27+
ADMIN_PASSWORD: ${{secrets.MAGENTO_ADMIN_PASSWORD}}
28+
DONATION_ACCOUNT: ${{secrets.DONATION_ACCOUNT}}
29+
DEPLOY_SAMPLEDATA: 1
1830
steps:
1931
- uses: actions/checkout@v3
2032
with:
2133
ref: ${{ github.event.pull_request.head.sha || github.ref }}
22-
fetch-depth: 0
2334

24-
- name: Use PHP ${{ matrix.php-version }}
25-
uses: shivammathur/setup-php@v2
26-
with:
27-
php-version: ${{ matrix.php-version }}
28-
tools: composer:v2
35+
- name: Install Magento
36+
run: docker compose -f .github/docker-compose.yml run --rm web make magento
2937

30-
- name: Test plugin installation
31-
run: |
32-
echo "{\"http-basic\":{\"repo.magento.com\":{\"username\":\"${MAGENTO_USERNAME}\",\"password\":\"${MAGENTO_PASSWORD}\"}}}" > auth.json
33-
composer install --prefer-dist
34-
env:
35-
CI: true
36-
MAGENTO_USERNAME: ${{ secrets.MAGENTO_USERNAME }}
37-
MAGENTO_PASSWORD: ${{ secrets.MAGENTO_PASSWORD }}
38+
- name: Start web server in background
39+
run: docker compose -f .github/docker-compose.yml up -d web
3840

39-
- name: Code Sniffer
40-
run: vendor/bin/phpcs .
41+
- name: Setup permissions
42+
run: docker exec magento2-container make fs
4143

42-
- name: Run PHPUnit
43-
run: vendor/bin/phpunit --coverage-clover=build/clover.xml --log-junit=build/tests-log.xml -c Test/phpunit.xml Test/Unit
44+
- name: Check install
45+
run: docker exec magento2-container make sys-check
4446

45-
- name: Fix code coverage paths
46-
run: sed -i "s;`pwd`/;;g" build/*.xml
47+
- name: Install plugin
48+
run: docker exec -u www-data magento2-container make plugin
49+
50+
- name: Kill Cron Jobs
51+
run: docker exec magento2-container /etc/init.d/cron stop
52+
53+
- name: Setup permissions
54+
run: docker exec magento2-container make fs
55+
56+
- name: Run PHP_Codesniffer
57+
run: docker exec magento2-container make codesniffer-run
58+
59+
- name: Run PHPUnit
60+
run: docker exec magento2-container make phpunit-run
4761

4862
- name: SonarCloud Scan
4963
if: ${{ env.SONAR_TOKEN }}
5064
uses: SonarSource/sonarqube-scan-action@master
5165
env:
5266
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5367
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
68+
69+
- name: Run PHPStan
70+
run: docker exec magento2-container make phpstan-run

.github/workflows/phpstan.yml

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

Helper/Data.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,6 +1253,8 @@ public function createAdyenRecurringService($client)
12531253
}
12541254

12551255
/**
1256+
* @deprecated
1257+
*
12561258
* @param string $date
12571259
* @param string $format
12581260
* @return mixed

Helper/Vault.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ public function getPaymentMethodRecurringProcessingModel(string $paymentMethodCo
113113
{
114114
$recurringConfiguration = $this->config->getConfigData(
115115
Config::XML_RECURRING_CONFIGURATION,
116-
Config::XML_ADYEN_ABSTRACT_PREFIX, $storeId
116+
Config::XML_ADYEN_ABSTRACT_PREFIX,
117+
$storeId
117118
);
118119

119120
if (!isset($recurringConfiguration)) {

Test/Unit/AbstractAdyenTestCase.php

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ abstract class AbstractAdyenTestCase extends TestCase
2424
{
2525
/**
2626
* Create a mock with a mix of methods that already exist and others that do not exist.
27-
* If conditions are required so that MockBuilder does not set $this->emptyMethodsArray = 1
27+
* If conditions are requireed so that MockBuilder does not set $this->emptyMethodsArray = 1
2828
* This was done since setMethods is deprecated
2929
*/
3030
protected function createMockWithMethods(string $originalClassName, array $existingMethods, array $nonExistingMethods): MockObject
@@ -43,36 +43,33 @@ protected function createMockWithMethods(string $originalClassName, array $exist
4343
}
4444

4545
/**
46-
* Mock a class dynamically generated by Magento. In future additionalMethods have to be split
47-
* similar to createMockWithMethods since setMethods is deprecated
48-
*
4946
* @psalm-template RealInstanceType of object
5047
*
5148
* @psalm-param class-string<RealInstanceType> $originalClassName
5249
*
5350
* @psalm-return MockObject&RealInstanceType
5451
*/
55-
protected function createGeneratedMock(string $originalClassName, array $existingMethods = [], array $virtualMethods = []): MockObject
56-
{
57-
$builder = $this->getMockBuilder($originalClassName)
58-
->disableOriginalConstructor()
59-
->disableOriginalClone()
60-
->disableArgumentCloning();
52+
protected function createGeneratedMock(
53+
string $originalClassName,
54+
array $existingMethods = [],
55+
array $nonExistingMethods = []
56+
): MockObject {
57+
$mockBuilder = $this->getMockBuilder($originalClassName);
6158

6259
if (!empty($existingMethods)) {
63-
$builder->onlyMethods($existingMethods);
60+
$mockBuilder = $mockBuilder->onlyMethods($existingMethods);
6461
}
6562

66-
if (!empty($virtualMethods)) {
67-
$builder->addMethods($virtualMethods);
63+
if (!empty($nonExistingMethods)) {
64+
$mockBuilder = $mockBuilder->addMethods($nonExistingMethods);
6865
}
6966

70-
return $builder->getMock();
67+
return $mockBuilder->disableOriginalConstructor()
68+
->disableOriginalClone()
69+
->disableArgumentCloning()
70+
->getMock();
7171
}
7272

73-
74-
75-
7673
protected function createOrder(?string $status = null)
7774
{
7875
$orderPaymentMock = $this->createConfiguredMock(MagentoOrder\Payment::class, ['getMethod' => 'adyen_cc']);
@@ -137,4 +134,4 @@ protected function invokeMethod(&$object, $methodName, array $parameters = [])
137134

138135
return $method->invokeArgs($object, $parameters);
139136
}
140-
}
137+
}

Test/Unit/Block/Checkout/Multishipping/SuccessTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ class SuccessTest extends AbstractAdyenTestCase
4040

4141
protected function setUp(): void
4242
{
43-
$this->sessionMock = $this->createGeneratedMock(SessionManager::class, [
44-
'getOrderIds'
45-
]);
43+
$this->sessionMock = $this->createGeneratedMock(SessionManager::class, [], ['getOrderIds']);
4644
$this->sessionMock->method('getOrderIds')->willReturn(['1' => 1, '2' => 2]);
4745

4846
$this->contextMock = $this->createMock(Context::class);

Test/Unit/Block/Checkout/SuccessTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ protected function setUp(): void
5656
$this->objectManager = new ObjectManager($this);
5757
$this->checkoutSessionMock = $this->createGeneratedMock(
5858
CheckoutSession::class,
59+
[],
5960
['getLastOrderId']
6061
);
6162
$this->customerSessionMock = $this->createGeneratedMock(

0 commit comments

Comments
 (0)