Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
10d22fd
Merge remote-tracking branch 'origin/develop-10' into ECP-9682
candemiralp May 13, 2025
28dd99a
[ECP-9682] Replace removed `withConsecutive()` method
candemiralp May 13, 2025
ca01ae0
[ECP-9682] Fix unit tests and support PhpUnit V10
candemiralp May 13, 2025
7111b99
[ECP-9682] Merge main and phpstan workflows
candemiralp May 13, 2025
10a646e
[ECP-9682] Update the name and temp. disabled CS
candemiralp May 13, 2025
cafda4e
[ECP-9682] Update unit tests
candemiralp May 14, 2025
3f13451
[ECP-9682] Enable xDebug for unit test coverage report
candemiralp May 14, 2025
b9857ef
[ECP-9682] Set xDebug coverage mode
candemiralp May 14, 2025
b80dfa1
[ECP-9682] Enable SonarCloud
candemiralp May 14, 2025
864ba7f
[ECP-9682] Adjust Make command
candemiralp May 14, 2025
9cabba9
[ECP-9682] Apply Allure test framework related fix
candemiralp May 14, 2025
657ad02
[ECP-9682] Adjust coverage report path
candemiralp May 14, 2025
5e8a8dd
[ECP-9682] Enable PHPCS
candemiralp May 14, 2025
ca1ffd6
[ECP-9682] Configure PHPCS
candemiralp May 14, 2025
2ad1c42
[ECP-9682] Configure PHPCS
candemiralp May 14, 2025
d2d561b
[ECP-9682] Configure PHPCS
candemiralp May 14, 2025
8c5084f
Merge remote-tracking branch 'origin/develop-10' into ECP-9682
candemiralp May 14, 2025
f7fefac
[ECP-9682] Fix SonarCloud report path
candemiralp May 14, 2025
80b44a7
[ECP-9682] Fix SonarCloud report path
candemiralp May 14, 2025
0d8b118
[ECP-9682] Fix SonarCloud report path
candemiralp May 14, 2025
6842267
[ECP-9682] Fix SonarCloud report path
candemiralp May 14, 2025
bd0bd2a
[ECP-9682] Update phpunit config
candemiralp May 14, 2025
30dc4ef
[ECP-9682] Update phpunit config
candemiralp May 14, 2025
5cf0549
[ECP-9682] Formatting
candemiralp May 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .github/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ MAGENTO_LANGUAGE=en_US \
MAGENTO_CURRENCY=EUR \
MAGENTO_TZ=Europe/Amsterdam \
DEPLOY_SAMPLEDATA=0 \
USE_SSL=1
USE_SSL=1 \
XDEBUG_MODE=coverage

RUN apt-get update \
&& apt-get install -y libjpeg62-turbo-dev \
Expand All @@ -42,9 +43,13 @@ RUN apt-get update \
RUN docker-php-ext-configure gd --with-freetype --with-jpeg
RUN docker-php-ext-configure ftp --with-openssl-dir=/usr
RUN docker-php-ext-install -j$(nproc) bcmath gd intl pdo_mysql simplexml soap sockets xsl zip ftp
RUN pecl install xdebug && docker-php-ext-enable xdebug

RUN a2enmod ssl
RUN a2ensite default-ssl.conf #can be removed if not needed
RUN a2ensite default-ssl.conf

WORKDIR /var/www/html

COPY config/php.ini /usr/local/etc/php/
COPY scripts/install_magento.sh /tmp/install_magento.sh

Expand Down
18 changes: 17 additions & 1 deletion .github/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ magento:
install:
composer config --json repositories.local '{"type": "path", "url": "/data/extensions/workdir", "options": { "symlink": false } }'
composer require "adyen/module-payment:*"
vendor/bin/phpcs --standard=Magento2 --extensions=php,phtml --error-severity=10 -n -p vendor/adyen/module-payment
bin/magento module:enable Adyen_Payment
bin/magento setup:upgrade
bin/magento setup:di:compile
Expand Down Expand Up @@ -132,3 +131,20 @@ mftf:

phpstan-run:
vendor/bin/phpstan analyse -c vendor/adyen/module-payment/phpstan.neon

phpunit-run:
cp vendor/adyen/module-payment/Test/phpunit.xml.dist dev/tests/unit/phpunit.xml
cd dev/tests/unit; \
../../../vendor/bin/phpunit \
--coverage-clover=../../../build/clover.xml \
--log-junit=../../../build/tests-log.xml \
-c phpunit.xml \
../../../vendor/adyen/module-payment/Test/Unit

codesniffer-run:
vendor/bin/phpcs --standard=Magento2 \
--extensions=php,phtml \
--error-severity=10 \
--warning-severity=0 \
--ignore-annotations \
-p vendor/adyen/module-payment
1 change: 1 addition & 0 deletions .github/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ services:
- ./Makefile:/var/www/html/Makefile
- composer:/usr/local/bin
- magento:/var/www/html
- ../build:/var/www/html/build
networks:
backend:
volumes:
Expand Down
69 changes: 43 additions & 26 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,70 @@
name: Main CI workflow
name: Main
run-name: Main

on:
pull_request:
branches: [main, develop-10]
pull_request_target:
workflow_dispatch:
branches: [main, develop-10]

jobs:
build:
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')
environment: ${{ (github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository) && 'external' || 'internal' }}
runs-on: ubuntu-latest
timeout-minutes: 25
strategy:
matrix:
php-version: [8.2,8.3]

php-version: ["8.3"]
magento-version: ["2.4.8"]
runs-on: ubuntu-latest
timeout-minutes: 15
env:
PHP_VERSION: ${{ matrix.php-version }}
MAGENTO_VERSION: ${{ matrix.magento-version }}
ADYEN_API_KEY: ${{secrets.ADYEN_API_KEY}}
ADYEN_CLIENT_KEY: ${{secrets.ADYEN_CLIENT_KEY}}
ADYEN_MERCHANT: ${{secrets.ADYEN_MERCHANT}}
ADMIN_USERNAME: ${{secrets.MAGENTO_ADMIN_USERNAME}}
ADMIN_PASSWORD: ${{secrets.MAGENTO_ADMIN_PASSWORD}}
DONATION_ACCOUNT: ${{secrets.DONATION_ACCOUNT}}
DEPLOY_SAMPLEDATA: 1
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
fetch-depth: 0

- name: Use PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
tools: composer:v2
- name: Install Magento
run: docker compose -f .github/docker-compose.yml run --rm web make magento

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

- name: Code Sniffer
run: vendor/bin/phpcs .
- name: Setup permissions
run: docker exec magento2-container make fs

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

- name: Fix code coverage paths
run: sed -i "s;`pwd`/;;g" build/*.xml
- name: Install plugin
run: docker exec -u www-data magento2-container make plugin

- name: Kill Cron Jobs
run: docker exec magento2-container /etc/init.d/cron stop

- name: Setup permissions
run: docker exec magento2-container make fs

- name: Run PHP_Codesniffer
run: docker exec magento2-container make codesniffer-run

- name: Run PHPUnit
run: docker exec magento2-container make phpunit-run

- name: SonarCloud Scan
if: ${{ env.SONAR_TOKEN }}
uses: SonarSource/sonarqube-scan-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

- name: Run PHPStan
run: docker exec magento2-container make phpstan-run
59 changes: 0 additions & 59 deletions .github/workflows/phpstan.yml

This file was deleted.

2 changes: 2 additions & 0 deletions Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -1247,6 +1247,8 @@ public function createAdyenRecurringService($client)
}

/**
* @deprecated
*
* @param string $date
* @param string $format
* @return mixed
Expand Down
3 changes: 2 additions & 1 deletion Helper/Vault.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ public function getPaymentMethodRecurringProcessingModel(string $paymentMethodCo
{
$recurringConfiguration = $this->config->getConfigData(
Config::XML_RECURRING_CONFIGURATION,
Config::XML_ADYEN_ABSTRACT_PREFIX, $storeId
Config::XML_ADYEN_ABSTRACT_PREFIX,
$storeId
);

if (!isset($recurringConfiguration)) {
Expand Down
24 changes: 16 additions & 8 deletions Test/Unit/AbstractAdyenTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,28 @@ protected function createMockWithMethods(string $originalClassName, array $exist
}

/**
* Mock a class dynamically generated by Magento. In future additionalMethods have to be split
* similar to createMockWithMethods since setMethods is deprecated
*
* @psalm-template RealInstanceType of object
*
* @psalm-param class-string<RealInstanceType> $originalClassName
*
* @psalm-return MockObject&RealInstanceType
*/
protected function createGeneratedMock(string $originalClassName, array $additionalMethods = []): MockObject
{
return $this->getMockBuilder($originalClassName)
->setMethods($additionalMethods)
->disableOriginalConstructor()
protected function createGeneratedMock(
string $originalClassName,
array $existingMethods = [],
array $nonExistingMethods = []
): MockObject {
$mockBuilder = $this->getMockBuilder($originalClassName);

if (!empty($existingMethods)) {
$mockBuilder = $mockBuilder->onlyMethods($existingMethods);
}

if (!empty($nonExistingMethods)) {
$mockBuilder = $mockBuilder->addMethods($nonExistingMethods);
}

return $mockBuilder->disableOriginalConstructor()
->disableOriginalClone()
->disableArgumentCloning()
->getMock();
Expand Down
4 changes: 1 addition & 3 deletions Test/Unit/Block/Checkout/Multishipping/SuccessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ class SuccessTest extends AbstractAdyenTestCase

protected function setUp(): void
{
$this->sessionMock = $this->createGeneratedMock(SessionManager::class, [
'getOrderIds'
]);
$this->sessionMock = $this->createGeneratedMock(SessionManager::class, [], ['getOrderIds']);
$this->sessionMock->method('getOrderIds')->willReturn(['1' => 1, '2' => 2]);

$this->contextMock = $this->createMock(Context::class);
Expand Down
1 change: 1 addition & 0 deletions Test/Unit/Block/Checkout/SuccessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ protected function setUp(): void
{
$this->checkoutSessionMock = $this->createGeneratedMock(
CheckoutSession::class,
[],
['getLastOrderId']
);
$this->customerSessionMock = $this->createGeneratedMock(
Expand Down
31 changes: 7 additions & 24 deletions Test/Unit/Block/Form/PayByLinkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,45 +13,28 @@

use Adyen\Payment\Block\Form\PayByLink;
use Adyen\Payment\Model\Ui\AdyenPayByLinkConfigProvider;
use Adyen\Payment\Test\Unit\AbstractAdyenTestCase;
use Magento\Framework\App\Config;
use Magento\Framework\View\Element\Template\Context;
use Magento\Payment\Gateway\Validator\ResultInterfaceFactory;
use Magento\Store\Model\Store;
use Magento\Store\Model\StoreManager;
use PHPUnit\Framework\TestCase;

class PayByLinkTest extends TestCase
class PayByLinkTest extends AbstractAdyenTestCase
{
/**
* @var PayByLink
*/
private $payByLink;
private PayByLink $payByLink;

protected function setUp(): void
{

$scopeConfig = $this->getMockBuilder(Config::class)
->disableOriginalConstructor()
->setMethods(['getValue'])
->getMock();
$scopeConfig = $this->createMock(Config::class);
$scopeConfig->method('getValue')->willReturn(AdyenPayByLinkConfigProvider::MIN_EXPIRY_DAYS);

$store = $this->getMockBuilder(Store::class)
->disableOriginalConstructor()
->setMethods(['getId'])
->getMock();
$store = $this->createMock(Store::class);
$store->method('getId')->willReturn(1);

$storeManager = $this->getMockBuilder(StoreManager::class)
->disableOriginalConstructor()
->setMethods(['getStore'])
->getMock();
$storeManager = $this->createMock(StoreManager::class);
$storeManager->method('getStore')->willReturn($store);

$context = $this->getMockBuilder(Context::class)
->disableOriginalConstructor()
->setMethods(['getScopeConfig', 'getStoreManager'])
->getMock();
$context = $this->createMock(Context::class);
$context->method('getScopeConfig')->willReturn($scopeConfig);
$context->method('getStoreManager')->willReturn($storeManager);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ public function testExecute(): void
$requestMock = $this->createMock(RequestInterface::class);
$requestMock->expects($this->exactly(2))
->method('getParam')
->withConsecutive(['apiKey', ''], ['demoMode'])
->willReturnOnConsecutiveCalls($apiKey, $demoMode);
->willReturnMap([['apiKey', '', $apiKey], ['demoMode', '', $demoMode]]);

$contextMock = $this->createConfiguredMock(Context::class,
[
Expand Down
Loading
Loading