Integrations Testing
In this article
Integration testing scripts are used to test the interaction between the module and other components of the Magento system, as well as with external systems such as payment gateways or shipping providers. This helps identify and fix issues related to compatibility, data exchange, and performance.
Environment:
- Magento Version: 2.4.7-p3.
- Pipeline: Azure DevOps CI/CD Pipeline.
- Custom Module: LS Magento Extension.
To run the integration tests provided in the LS Magento extension, specific configurations are required for each module. We recommend running tests for each module separately to quickly identify any modules that may cause failures or errors.
These integration tests must be executed using a dedicated test database, which should only be used for testing purposes. It is important to run these tests in staging, development, or cloned production environments to ensure that live data is not impacted.
Additionally, you will need to copy the dev/tests/integration/etc/install-config-mysql.php file from the LS Magento module to the dev/tests/integration/etc folder within the Magento root directory. After copying the file, make sure to update it with the correct database credentials and Elasticsearch configuration.
For more information on setting up Magento 2 integration tests, refer to the official documentation Magento 2 Integration Testing Guide.
Integration tests are included in these LS Magento modules:
- Ls_Customer
- Ls_CustomerGraphQl
- Ls_Omni
- Ls_OmniGraphQl
- Ls_Replication
- Ls_Webhooks
Integration tests corresponding to each module must have a specific set of environment variables to be configured before running the scripts. The details are mentioned below.
Customer Module
These variables are crucial for configuring and running integration tests for the Customer Module. They enable the system to interact with the LS Central and Magento environments during testing.
If you are running tests manually without using a pipeline, you can copy the file from LS Magento extension dev/tests/integration/azure-pipelines-phpunit-customer.xml to the dev/tests/integration/ folder in the Magento root directory.
<env name="PASSWORD" value="Nmswer123@" />
<env name="EMAIL" value="pipeline_retail@test.com" />
<env name="FIRST_NAME" value="Umar" />
<env name="LAST_NAME" value="Yousaf" />
<env name="CUSTOMER_ID" value="1" />
<env name="CS_URL" value="http://test.com/commerceservice" />
<env name="CS_VERSION" value="2024.4.1" />
<env name="LS_VERSION" value="25.0.0.0" />
<env name="CS_STORE" value="S0013" />
<env name="ENABLED" value="1" />
<env name="USERNAME_1" value="mc_57745" />
<env name="LSR_ID" value="MSO000012" />
<env name="LSR_CARD_ID" value="10051" />
Once the update is done, run this command from Magento project root to execute integration test through CLI:
vendor/bin/phpunit -c dev/tests/integration/azure-pipelines-phpunit-customer.xml
Omni Module
These variables are crucial for configuring and running integration tests for the Omni Module, allowing the system to interact smoothly with the LS Central and Magento environments during testing.
For manual testing without a pipeline, copy the file from LS Magento extension /dev/tests/integration/azure-pipelines-phpunit-omni.xml to the dev/tests/integration/ folder in the Magento root directory.
<env name="PASSWORD" value="Nmswer123@" />
<env name="EMAIL" value="pipeline_retail@test.com" />
<env name="USERNAME" value="mc_61422" />
<env name="FIRST_NAME" value="John" />
<env name="LAST_NAME" value="Doe" />
<env name="CUSTOMER_ID" value="1" />
<env name="CS_URL" value="http://test.com/CommerceService" />
<env name="CS_VERSION" value="2024.10.0" />
<env name="CS_STORE" value="S0013" />
<env name="LS_MAG_ENABLE" value="1" />
<env name="LS_MAG_DISABLE" value="0" />
<env name="ENABLED" value="1" />
<env name="LSR_ID" value="MSO000012" />
<env name="LSR_CARD_ID" value="10051" />
<env name="LSR_LOY_POINTS" value="2" />
<env name="STORE_PICKUP" value="S0001" />
<env name="VALID_COUPON_CODE" value="COUP0119" />
<env name="INVALID_COUPON_CODE" value="COUPON_CODE" />
<env name="GIFTCARD" value="10000000" />
<env name="GIFTCARD_EXPIRED" value="10000002" />
<env name="GIFTCARD_PIN" value="0" />
<env name="GIFTCARD_EXPIRED_PIN" value="2979" />
<env name="GIFTCARD_AMOUNT" value="1" />
<env name="LOY_POINTS" value="2" />
<env name="LICENSE" value="25.0.0.0 (25.0.0.0 [18056] CL:True EL:True)" />
<env name="LS_CENTRAL_VERSION" value="25.0.0.0 (25.0.0.0 [conf])" />
<env name="RETAIL_INDUSTRY" value="retail" />
<env name="LSR_ORDER_EDIT" value="1" />
<env name="ENABLE_COUPON_ELEMENTS" value="1" />
<env name="COUPONS_SHOW_ON_CHECKOUT" value="1" />
<env name="ENABLE_LOY_ELEMENTS" value="1" />
<env name="LOY_SHOW_ON_CHECKOUT" value="1" />
<env name="ENABLE_GC_ELEMENTS" value="1" />
<env name="GC_SHOW_ON_CHECKOUT" value="1" />
<env name="DISCOUNT_VALIDATION_ACTIVE" value="1" />
<env name="PICKUP_TIMESLOTS_ENABLED" value="1" />
<env name="SC_CLICKCOLLECT_ENABLED" value="1" />
<env name="TENDER_TYPE_MAPPINGS" value='{"item1":{"payment_method":"checkmo","tender_type":"2"},"item2":{"payment_method":"giftcard","tender_type":"8"},"item3":{"payment_method":"loypoints","tender_type":"4"},"_1724121642612_612":{"payment_method":"braintree","tender_type":"3"}}' />
<env name="ADYEN_RESPONSE" value='{"pspReference":"pspreference","paymentMethod":"adyen_cc","authResult":true}' />
Once the update is done, run this command from Magento project root to execute integration test through CLI:
vendor/bin/phpunit -c dev/tests/integration/azure-pipelines-phpunit-omni.xml
Replication Module
These variables are vital for setting up and running integration tests for the Replication Module, enabling seamless interaction between the LS Central and Magento environments during testing.
For manual testing without using a pipeline, copy the files from LS Magento extension /dev/tests/integration/azure-pipelines-phpunit-replication*.xml to the dev/tests/integration/ folder in the Magento root directory.
The replication tests are separated to minimize memory consumption. You can copy all the required files and run the tests individually for better resource management.
<env name="CS_URL" value="http://test.com/CommerceService" />
<env name="CS_VERSION" value="2024.10.0" />
<env name="LS_VERSION" value="25.1.0.0" />
<env name="CS_STORE" value="S0013" />
<env name="ENABLED" value="1" />
<env name="SAMPLE_FLAT_REPLICATION_CRON_URL" value="Ls\Replication\Cron\ReplEcommItemsTask" />
<env name="SAMPLE_FLAT_REPLICATION_CRON_NAME" value="repl_item" />
<env name="SAMPLE_MAGENTO_REPLICATION_CRON_NAME" value="repl_products" />
<env name="DEFAULT_BATCH_SIZE" value="5000" />
<env name="SAMPLE_SIMPLE_ITEM_ID" value="40000" />
<env name="SAMPLE_DISCOUNTED_CONFIGURABLE_ITEM_ID" value="40015" />
<env name="SAMPLE_CONFIGURABLE_ITEM_ID" value="40020" />
<env name="SAMPLE_CONFIGURABLE_VARIANT_ID" value="000" />
<env name="SAMPLE_ATTRIBUTE_CODE" value="FABRIC" />
<env name="SAMPLE_COUNTRY_CODE" value="IS" />
<env name="SAMPLE_OFFER_NO" value="P1001" />
<env name="SAMPLE_VALIDATION_PERIOD_ID" value="16" />
<env name="SAMPLE_HIERARCHY_NAV_ID" value="FASHIONCOSMETICS" />
<env name="SAMPLE_UOM" value="PCS" />
<env name="SAMPLE_UOM_2" value="PACK" />
<env name="SAMPLE_VENDOR_ID" value="44010" />
<env name="SAMPLE_BUSINESS_TAX_GROUP" value="DOMESTIC" />
<env name="SAMPLE_CASH_TENDER_TYPE_ID" value="1" />
<env name="SAMPLE_STORE_ID" value="S0001" />
<env name="SAMPLE_LANGUAGE_CDOE" value="ENG" />
<env name="SAMPLE_LOG_FILE_NAME" value="omniclient.log" />
<env name="SAMPLE_HARD_ATTRIBUTE" value="SIZE" />
<env name="SAMPLE_VARIANT_ATTRIBUTE" value="COLOUR" />
<env name="SAMPLE_VISUAL_SWATCH_ATTRIBUTE_CODE" value="ls_colour" />
<env name="SAMPLE_HIERARCHY_NODE_NAV_ID" value="ACCESSORIES" />
<env name="SAMPLE_HIERARCHY_NODE_NAV_ID_2" value="BAGS" />
<env name="SAMPLE_UPDATE_HIERARCHY_NODE_NAV_ID" value="MAKEUP" />
<env name="SAMPLE_CONFIGURABLE_UOM_ITEM_ID" value="20020" />
<env name="SAMPLE_CONFIGURABLE_VARIANT_ITEM_ID" value="40500" />
<env name="SAMPLE_CONFIGURABLE2_VARIANT_ITEM_ID" value="43130" />
<env name="SAMPLE_STANDARD_VARIANT_ITEM_ID" value="40190" />
<env name="SAMPLE_HIERARCHY_LEAF" value="DAVI" />
<env name="SAMPLE_CURRENCY_CODE" value="GBP" />
<env name="SAMPLE_OFFER_CATEGORY_1" value="P1065" />
<env name="SAMPLE_OFFER_CATEGORY_2" value="P1016" />
<env name="SAMPLE_OFFER_ITEM_1" value="P1060" />
<env name="SAMPLE_VALID_VALIDATION_PERIOD_ID" value="16" />
<env name="SAMPLE_STORE_GROUP_CODES" value="EASYBURGER;ECOMMERCE;" />
<env name="SAMPLE_PRICE_GROUP" value="ALL" />
<env name="SAMPLE_LANGUAGE_CODE" value="ENG" />
Once the update is done, run this command from Magento project root to execute integration test through CLI:
vendor/bin/phpunit -c dev/tests/integration/azure-pipelines-phpunit-replication1.xml
vendor/bin/phpunit -c dev/tests/integration/azure-pipelines-phpunit-replication2.xml
vendor/bin/phpunit -c dev/tests/integration/azure-pipelines-phpunit-replication3.xml
vendor/bin/phpunit -c dev/tests/integration/azure-pipelines-phpunit-replication4.xml
Webhooks Module
These variables need to be defined in azure-pipelines-phpunit-customer.xml if you are running tests manually. In case you are using Azure pipeline, these environment variables need to be defined in Azure pipeline variables. These variables are essential for configuring and executing integration tests for the Webhooks Module.
If you are running tests manually without using pipeline, you can copy the file from LS Magento extension dev/tests/api-functional/azure-pipelines-phpunit_rest.xml to Magento root folder dev/tests/api-functional/ folder.
<env name="EMAIL" value="pipeline_retail@test.com" />
<env name="SIMPLE_ITEM_ID" value="40180" />
<env name="BRAINTREE_PRIVATE_KEY" value=" " />
<env name="BRAINTREE_PUBLIC_KEY" value="" />
<env name="BRAINTREE_MERCHANT_ID" value="" />
Once the update is done, run this command from Magento project root to execute integration test through CLI:
vendor/bin/phpunit -c dev/tests/integration/azure-pipelines-phpunit_rest.xml
GraphQl Module
In case you are using Azure pipeline, these environment variables need to be defined in Azure pipeline variables. These variables are essential for configuring and executing integration tests for the GraphQl Module.
If you are running tests manually without using pipeline, you can copy the file from LS Magento extension dev/tests/api-functional/azure-pipelines-phpunit_graphql.xml to Magento root folder dev/tests/api-functional/ folder.
<env name="EMAIL" value="pipeline_retail@test.com" />
<env name="PASSWORD" value="Nmswer123@" />
Once the update is done, run this command from Magento project root to execute integration test through CLI:
vendor/bin/phpunit -c dev/tests/integration/azure-pipelines-phpunit_graphql.xml