1. Go to this page and download the library: Download oxid-esales/testing-library library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
oxid-esales / testing-library example snippets
public function testCase_forSubShops()
{
$this->markTestSkippedIfSubShop();
...
}
public function testCase_forNoSubShops()
{
$this->markTestSkippedIfNoSubShop();
...
}
Rest of the methods can be found in class: ``OxidEsales\TestingLibrary\UnitTestCase``.
Writing acceptance tests
~~~~~~~~~~~~~~~~~~~~~~~~
Currently for acceptance testing Mink library and selenium driver is used.
**Note:**
selenium-server-standalone-jar 2.47.1 is used for testing.
There might be some issues with older versions `issue #13 <https://github.com/OXID-eSales/testing_library/issues/13>`__
Acceptance tests should be placed under
``tests/acceptance`` directory and extend
``OxidEsales\TestingLibrary\AcceptanceTestCase``.
Tested module will be activated by default.
Some data might be also added by extending
``AcceptanceTestCase::addTestData()`` method and activating module
manually. This method will be run before any test and before database
dump creation, once per tests suite.
For acceptance testing
shop is installed with default demodata. Additional demodata can be
added to ``testSql`` directory by the name of ``demodata_EE.sql``,
``demodata_PE_CE.sql`` or ``demodata_EE_mall.sql`` (when subshop
functionality is enabled in test\_config). These files will be loaded on
top of the database depending on the shop edition. Any additional files,
needed for testing can be placed under ``testData`` directory - all
content will be copied onto the shop source before running tests.
A useful method for preparing the shop is
``AcceptanceTestCase::callShopSC()``. With this method
you can e.g. insert a new article or modify config variables. For detailed
usage examples have a look at the OXID eShop acceptance tests.
Methods usage
^^^^^^^^^^^^^
Testing library provides methods which allows write tests easier. Some methods usages are described bellow:
Activating theme:
.. code:: php
// This will activate azure theme.
$this->activateTheme('azure')
// This will add article with ID 1001 to basket.
$this->addToBasket("1001")
// This will update article with ID 1001 in basket to have 2 items.
$this->changeBasket("1001", 2)
// This will remove an item from basket.
$this->changeBasket("1001", 0)