Run tests for OXID eShop 6

Nice thing about OXID eShop, they provide a development environment. Without big effort you can get have the shop up and running on a virtual machine. The current blog post will give some hints for how to run the shop tests that come with the shop. We will cover how to run module tests in a follow up post.

NOTE: my host is a Macbook Pro with macOS High Sierra 10.13.2.

Get the vm up and running

First have a look at
Get vagrant (Vagrant 2.0.1 was used in my case) and all that stuff installed on your machine
as described in section Dependencies.
Then do

git clone -b b-6.0 --recursive

Inside directory oxvm_eshop create a file personal.yml with the following content:

php: version: 5.6 composer: github_token: selenium: install: true
vagrant_local: vm: name: oxideshop_201712_PHP56

The github token prevents you from running into trouble with rate limits. Selenium is needed to run acceptance tests and PHP version can be adjusted as you need it. I prefer to have multiple virtual machines so it’s better to name them individually. Switching PHP versions in one vm is PITA, much easier to create different ones for each PHP version you need and switch between VMs.

Now run vagrant up to create and provision the virtual machine. Once you got the virtual machine up and running, there are two ways to get the shop installed.

NOTE: the OXID VM has a shared folder oxvm_eshop/oxideshop where the shop code needs to be installed. This folder points to /var/www/oxideshop/ inside the vm. The shop can be accessed at once it is installed.
You can try to install the shop in another directory but the paths might be hardcoded by accident on some tests so if anything weird happens better stick to the defaults.

Install the shop, git clone way

When you want to develop something for the shop core, this is the best way to go. In case you are
not a contributor to OXID eShop CE repository you will have to use a fork and send in changes to shop core via pull requests.

Inside oxvm_eshop directory on your host call vagrant ssh to connect to VM console.
You end up in /home/vagrant, so first change to /var/www directory. Then git clone (oxid repo or your fork) directly into /var/www/oxideshop in vm, in host you find the files in oxvm_eshop/oxideshop directory.

git clone oxideshop

You can switch the branch/tag as you like if you do not want the master but a specific release.

Then you need to run composer install, so run

cd oxideshop
composer install

When this is done (takes a while on first run) you get asked in the end about some paths, as we do the default installation no need to enter anything.

Creating the "test_config.yml" file
Some parameters are missing. Please provide them.
shop_path (source):
shop_tests_path (tests):
partial_module_paths (null):

What we no still need is the infamous source/ file, so

cd source (cd /var/www/oxideshop/source)

And change the placeholders in to

$this->dbType = 'pdo_mysql';
$this->dbHost = ''; // database host name
$this->dbPort = 3306; // tcp port to which the database is bound
$this->dbName = 'oxid'; // database name
$this->dbUser = 'oxid'; // database user name
$this->dbPwd = 'oxid'; // database user password
$this->sShopURL = ''; // eShop base url, required
$this->sSSLShopURL = null; // eShop SSL url, optional
$this->sAdminSSLURL = null; // eShop Admin SSL url, optional
$this->sShopDir = '/var/www/oxideshop/source';
$this->sCompileDir = '/var/www/oxideshop/source/tmp';

Alternately you could run the web setup, but this will delete the Setup directory if you are
not careful.

Check if you installation is ok:

cd /var/www/oxideshop

No output is a good sign here . Open a browser, open and you should see the shop start page.

Install the shop, compilation way

This is the way to would install a ‘real life’ shop. Structure of shop installation is different than the ‘git clone’ way because now you have all the ship sources inside the vendor folder
and only necessary stuff is copied to source directory.

vagrant ssh
composer create-project oxid-esales/oxideshop-project /var/www/oxideshop dev-b-6.0-ce

Again at the end of installation you get asked for

Creating the "test_config.yml" file
Some parameters are missing. Please provide them.
shop_path (source):
shop_tests_path (tests): /var/www/oxideshop/vendor/oxid-esales/oxideshop-ce/tests
partial_module_paths (null):

The composer project does create a source/ file but you still need to either run shop web setup or modify that file manually. Enter the values same as above. Now also edit the test_config.yml file, you need to explicitly enter the shop_setup_path:

shop_setup_path: /var/www/oxideshop/vendor/oxid-esales/oxideshop-ce

Run shop tests

When you run acceptance tests it’s nice to see what actually is going on. The OXID vm is headless, but you can use VNC viewer for remote desktop.

There are some scripts in vendor/bin directory that are used for running tests:

  • vendor/bin/reset-shop resets the shop to default database and demodata (admin/admin). In case you did add your own test data, dump the database before reset.
  • vendor/bin/runtests runs the tests as defined in test_config.yml.
    NOTE: before tests start, shop unified namespace classes are regenerated so it might take some time before the actual output starts. If the script gives no output at all you should check the test_config.yml for misconfiguration (no tests available) and source/log/EXCEPTION_LOG.txt.
  • vendor/bin/runtests-selenium runs the acceptance tests as defined in test_config.yml.
    NOTE: atm shop acceptance tests run with selenium and still need azure theme.

Call vendor/bin/reset-shop followed by vendor/bin/runtests. All tests (more than 8000 for CE) should pass locally.

Troubleshooting composer
In case you changed something in composer.json and want a clean state or composer gets a hiccup, try to do

composer clear-cache
rm composer.lock
rm -r vendor

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published.