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.
git clone -b b-6.0 --recursive https://github.com/OXID-eSales/oxvm_eshop.git
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.
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
git clone https://github.com/OXID-eSales/oxideshop_ce.git 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/config.inc.php file, so
cd source (cd /var/www/oxideshop/source) cp config.inc.php.dist config.inc.php
And change the placeholders in config.inc.php to
$this->dbType = 'pdo_mysql'; $this->dbHost = '127.0.0.1'; // 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 = 'http://www.oxideshop.dev'; // 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
Check if you installation is ok:
cd /var/www/oxideshop vendor/bin/reset-shop
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.
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/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.
vendor/bin/reset-shop followed by
vendor/bin/runtests. All tests (more than 8000 for CE) should pass locally.
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