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 https://github.com/OXID-eSales/oxvm_eshop/.
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

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

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 http://www.oxideshop.dev 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.

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

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.

What we no still need is the infamous source/config.inc.php file, so

And change the placeholders in config.inc.php to

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:

No output is a good sign here . Open a browser, open http://www.oxideshop.dev 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.

Again at the end of installation you get asked for

The composer project does create a source/config.inc.php 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:

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

 

0.00 avg. rating (0% score) - 0 votes


Replies

  1. tabsl says:

    Hat irgendwer die Tests auch schon mal außerhalb der oxvom (docker) zum Laufen gebracht?

Continue the discussion at --> OXID forums

Participants