diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 9b5976e..5170088 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -3,10 +3,10 @@ name: m2-actions-sequra-core-test
on: [push]
jobs:
- magento2-build:
+ magento2-test:
runs-on: ubuntu-latest
container: ubuntu
- name: 'm2 tests & build'
+ name: 'm2 unit and integration tests'
services:
mysql:
image: docker://mysql:8.0
@@ -21,53 +21,132 @@ jobs:
ports:
- 9200:9200
options: -e="discovery.type=single-node" -e "plugins.security.disabled=true" --health-cmd="curl http://localhost:9200/_cluster/health" --health-interval=10s --health-timeout=5s --health-retries=10
-
+ rabbitmq:
+ image: docker://rabbitmq:3.8-alpine
+ env:
+ RABBITMQ_DEFAULT_USER: "magento"
+ RABBITMQ_DEFAULT_PASS: "magento"
+ RABBITMQ_DEFAULT_VHOST: "/"
+ ports:
+ - 5672:5672
+ strategy:
+ matrix:
+ magento_version: [2.4.6]
steps:
- ### Download the third party code in custom dir###
- - uses: actions/checkout@v3
- with:
- path: Sequra_Core
+ - name: Extract branch name
+ shell: bash
+ run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
+ id: extract_branch
+
+ - name: Build composer auth
+ shell: bash
+ run: |
+ echo "auth={\"http-basic\": {\"repo.magento.com\": {\"username\": \"5310458a34d580de1700dfe826ff19a1\",\"password\":\"${{ secrets.REPO_MAGENTO_PASS }}\"} },\"github-oauth\":{\"github.com\":\"${{ github.token }}\"} }" >> $GITHUB_OUTPUT
+ id: composer_auth
- name: 'install fresh magento repo'
- uses: MAD-I-T/magento-actions@v3.20
+ uses: MAD-I-T/magento-actions@v3.25
env:
COMPOSER_AUTH: ${{secrets.COMPOSER_AUTH}}
with:
process: 'install-magento'
- magento_version: 2.4.6
+ magento_version: ${{ matrix.magento_version }}
no_push: 1 ## add this arg to not push to the repo ideal for quick test on specific version
- - name: 'launch magento2 unit test'
- if: always()
- uses: MAD-I-T/magento-actions@v3.20
+ ## Download our code in custom dir###
+ - uses: actions/checkout@v3
+ with:
+ path: magento/vendor/sequra/magento2-core
+
+ # - uses: "shivammathur/setup-php@v2"
+ # with:
+ # php-version: "8.2"
+
+ # - name: 'Prepare for unit test'
+ # working-directory: magento/vendor/sequra/magento2-core
+ # env:
+ # COMPOSER_AUTH: ${{ steps.composer_auth.outputs.auth }}
+ # run: |
+ # ../../../vendor/bin/composer install --no-interaction --no-progress --no-suggest --prefer-dist
+
+ # - name: 'launch magento2 unit test'
+ # if: always()
+ # uses: MAD-I-T/magento-actions@v3.25
+ # env:
+ # COMPOSER_AUTH: ${{ steps.composer_auth.outputs.auth }}
+ # with:
+ # process: 'unit-test'
+ # unit_test_subset_path: 'vendor/sequra/magento2-core/Test/Unit'
+ # unit_test_config: 'vendor/sequra/magento2-core/Test/Unit/phpunit.xml.dist'
+ # magento_version: ${{ matrix.magento_version }}
+
+ # Integrations tests
+ - name: "Run Integration tests"
+ working-directory: magento
+ run: |
+ cd dev/tests/integration && ../../../vendor/bin/phpunit vendor/sequra/magento2-core/Core/Test/Integration
+ - name: 'To run all test in copied phpunit.xml'
+ uses: MAD-I-T/magento-actions@master
env:
COMPOSER_AUTH: ${{secrets.COMPOSER_AUTH}}
with:
- process: 'unit-test'
- unit_test_config: 'dev/tests/unit/phpunit.xml.dist'
- unit_test_subset_path: '../Sequra_Core/'
-
- - name: 'phpstan'
- if: always()
- uses: MAD-I-T/magento-actions@v3.20
- with:
- process: 'phpstan'
- exec_path: '../Sequra_Core/'
+ process: 'integration-test'
+ unit_test_subset_path: "Sequra_Core Integration Tests"
+
+ # magento2-checks:
+ # runs-on: ubuntu-latest
+ # container: ubuntu
+ # name: 'm2 Standards, MD and PHPStan'
+ # strategy:
+ # matrix:
+ # magento_version: [2.4.6]
+ # steps:
+ # ### Download our code in custom dir###
+ # - uses: actions/checkout@v3
+ # with:
+ # path: Sequra_Core
+
+ # - name: 'install fresh magento repo'
+ # uses: MAD-I-T/magento-actions@v3.25
+ # env:
+ # COMPOSER_AUTH: ${{secrets.COMPOSER_AUTH}}
+ # with:
+ # process: 'install-magento'
+ # magento_version: ${{ matrix.magento_version }}
+ # no_push: 1 ## add this arg to not push to the repo ideal for quick test on specific version
+
+ # - uses: "shivammathur/setup-php@v2"
+ # with:
+ # php-version: "8.2"
+ # - name: 'unit test'
+ # run: |
+ # cd Sequra_Core
+ # ../magento/vendor/bin/composer install
+ # PAT="s/\/REAL-PATH-TO-MAGENTO-ROOT/..\/magento/g"
+ # sed -e $PAT Test/autoload_sample.php > Test/autoload.php
+ # ../magento/vendor/bin/phpunit -c Test/phpunit.xml Test/Unit
+
+ # - name: 'phpstan'
+ # if: always()
+ # uses: MAD-I-T/magento-actions@v3.25
+ # with:
+ # process: 'phpstan'
+ # exec_path: '../Sequra_Core'
- - name: 'mess detector'
- if: always()
- uses: MAD-I-T/magento-actions@v3.20
- with:
- process: 'mess-detector'
- md_src_path: '../Sequra_Core/'
+ # - name: 'mess detector'
+ # if: always()
+ # uses: MAD-I-T/magento-actions@v3.25
+ # with:
+ # process: 'mess-detector'
+ # md_src_path: '../Sequra_Core'
- - name: 'Magento coding standard checking'
- if: always()
- uses: MAD-I-T/magento-actions@v3.20
- with:
- process: 'phpcs-test'
- extension: 'Sequra_Core'
- severity: 10
- standard: 'Magento2'
+ # - name: 'Magento coding standard checking'
+ # if: always()
+ # uses: MAD-I-T/magento-actions@v3.25
+ # with:
+ # process: 'phpcs-test'
+ # extension: 'Sequra_Core'
+ # severity: 10
+ # standard: 'Magento2'
\ No newline at end of file
diff --git a/Test/Integration/Model/Api/Builders/CreateOrderRequestBuilderTest.php b/Test/Integration/Model/Api/Builders/CreateOrderRequestBuilderTest.php
new file mode 100644
index 0000000..8c0768c
--- /dev/null
+++ b/Test/Integration/Model/Api/Builders/CreateOrderRequestBuilderTest.php
@@ -0,0 +1,55 @@
+quote->load('test01', 'reserved_order_id');
+ // setShippingAddress in spain
+ $this->quote->getShippingAddress()->setCountryId('ES');
+ // setShippingMethod
+ $this->quote->getShippingAddress()
+ ->setShippingMethod('flatrate_flatrate')
+ ->setCollectShippingRates(true)
+ ->collectShippingRates()
+ ->save();
+ /** @var CreateOrderRequestBuilder $builder */
+ $builder = $this->createOrderRequestBuilderFactory->create([
+ 'cartId' => $this->quote->getId(),
+ 'storeId' => (string)$this->quote->getStore()->getId(),
+ ]);
+ $order = $builder->build()->toArray();
+ self::assertEquals($order['delivery_method']['name'],'flatrate_flatrate');
+ self::assertEquals($order['cart']['order_total_with_tax'], 1000);
+ }
+
+ public function setUp(): void
+ {
+ $objectManager = Bootstrap::getObjectManager();
+ $_SERVER['REMOTE_ADDR'] = "255.255.255.255";
+ $_SERVER['HTTP_USER_AGENT'] = "Integration tests";
+ $this->quote = $objectManager->create(Quote::class);
+ $this->createOrderRequestBuilderFactory = $objectManager->create(CreateOrderRequestBuilderFactory::class);
+ $this->bootstrap =$objectManager->create(\Sequra\Core\Services\Bootstrap::class);
+ $this->bootstrap->initInstance();
+ }
+}
diff --git a/Test/Integration/phpunit.xml.dist b/Test/Integration/phpunit.xml.dist
new file mode 100644
index 0000000..b3fe3bb
--- /dev/null
+++ b/Test/Integration/phpunit.xml.dist
@@ -0,0 +1,101 @@
+
+
+
+
+
+ ../../../app/code/Magento
+ ../../../lib/internal/Magento
+
+
+ ../../../app/code/*/*/Test
+ ../../../lib/internal/*/*/Test
+ ../../../lib/internal/*/*/*/Test
+ ../../../setup/src/*/*/Test
+
+
+
+
+
+ testsuite/Magento/IntegrationTest.php
+
+
+
+ testsuite/Magento/MemoryUsageTest.php
+
+
+ ../../../../Sequra_Core/Test/Integration
+
+
+
+
+
+ .
+ testsuite
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ allure/allure.config.php
+
+
+
+
diff --git a/Test/Unit/bootstrap.php b/Test/Unit/bootstrap.php
new file mode 100644
index 0000000..40a53ef
--- /dev/null
+++ b/Test/Unit/bootstrap.php
@@ -0,0 +1,12 @@
+createApplication(Cron::class);
diff --git a/Test/Unit/phpunit.xml.dist b/Test/Unit/phpunit.xml.dist
new file mode 100644
index 0000000..2ce40e1
--- /dev/null
+++ b/Test/Unit/phpunit.xml.dist
@@ -0,0 +1,8 @@
+
+
+
+
+ ./
+
+
+
\ No newline at end of file
diff --git a/Test/_files/sequra_configuration.php b/Test/_files/sequra_configuration.php
new file mode 100644
index 0000000..4a64072
--- /dev/null
+++ b/Test/_files/sequra_configuration.php
@@ -0,0 +1,55 @@
+quote->load('test01', 'reserved_order_id');
+ // setShippingAddress in spain
+ $this->quote->getShippingAddress()->setCountryId('ES');
+ // setShippingMethod
+ $this->quote->getShippingAddress()
+ ->setShippingMethod('flatrate_flatrate')
+ ->setCollectShippingRates(true)
+ ->collectShippingRates()
+ ->save();
+ /** @var CreateOrderRequestBuilder $builder */
+ $builder = $this->createOrderRequestBuilderFactory->create([
+ 'cartId' => $this->quote->getId(),
+ 'storeId' => (string)$this->quote->getStore()->getId(),
+ ]);
+ $order = $builder->build()->toArray();
+ assert($order['delivery_method']['name'] === 'flatrate_flatrate');
+ assert($order['cart']['order_total_with_tax'] === 1000);
+ }
+
+ public function setUp(): void
+ {
+ $objectManager = Bootstrap::getObjectManager();
+ $_SERVER['REMOTE_ADDR'] = "255.255.255.255";
+ $_SERVER['HTTP_USER_AGENT'] = "Integration tests";
+ $this->quote = $objectManager->create(Quote::class);
+ $this->createOrderRequestBuilderFactory = $objectManager->create(CreateOrderRequestBuilderFactory::class);
+ $this->bootstrap =$objectManager->create(\Sequra\Core\Services\Bootstrap::class);
+ $this->bootstrap->initInstance();
+ }
+}
diff --git a/composer.json b/composer.json
index 4d367de..1bc3f07 100644
--- a/composer.json
+++ b/composer.json
@@ -41,5 +41,12 @@
"SeQura\\Core\\Tests\\Infrastructure\\": "vendor/sequra/integration-core/tests/Infrastructure",
"SeQura\\Core\\Tests\\BusinessLogic\\": "vendor/sequra/integration-core/tests/BusinessLogic"
}
+ },
+ "archive": {
+ "exclude": [
+ "docs",
+ "scripts",
+ "Test"
+ ]
}
-}
+}
\ No newline at end of file