Tag Archives: Magento

Magento functional testing with CasperJS


via Functional testing for Magento.

Testing can be boring and time consuming task. So why don’t we use some tools and make our lives easier? In Magento there are numerous “boring” tasks that need to be done after the first install and then again when you test a new functionality. For example, create a test account, add product to cart, go trough checkout process, add product to wishlist, compare etc.Casper.js seems like the right tool for these “repeated” tasks. So, what is casper.js!?

CasperJS is an open source navigation scripting & testing utility written in Javascript for the PhantomJS WebKit headless browser and SlimerJS (Gecko). It eases the process of defining a full navigation scenario and provides useful high-level functions, methods & syntactic sugar for doing common tasks

We will skip the installation process as it is very straightforward. So let’s jump into testing right away.

We will create two scenarios for demo purpose

Welcome to Magento 2 installation


Welcome to Magento 2 installation! We’re glad you chose to install Magento 2, a cutting edge, feature-rich eCommerce solution that gets results. Click to Read>>

Contents

A Magento Development Environment Made of Docker Containers


data Sleepy Data Container 4 days ago
fs Preparing for Automated Builds on Docker.com 28 days ago
nginx Enable Remote Debugging with XDebug 18 hours ago
php Enable Remote Debugging with XDebug 18 hours ago
tools Don’t Require MAGENTO_HOST to Install Magento a day ago
.gitignore Organize per container a month ago
LICENSE.md Fix markdown 29 days ago
README.md Sleepy Data Container 4 days ago
browse Clean Up a month ago
fig.yml Enable Remote Debugging with XDebug 18 hours ago

Docker for Magento 1 Extension Development

Tl;dr How do I use this?

  1. Clone it.
  2. Type fig up -d.
  3. Install a Magento
  4. Mount your file share.
  5. Develop
  6. Profit!!!

How should we build this?

Normally with Magento you get a plain LAMP stack; Apache with mod_php. That’s fine, but since Docker containers are so nicely isolated, I want this approach:

 ---------------------       -------------       -------
| HTTPD/FastCGI Proxy | <-> | FastCGI PHP | <-> | MySQL |
 ---------------------       -------------       -------
                                    \               /
              ------------       -----------------------
             | File Share | <-> | Data Volume Container |
              ------------       -----------------------

Separating the HTTP server from the PHP process gives us a more true-to-form web architecture where the web application server is distinct from the web server. It means we can scale and reconfigure the different server layers independently. It means we can destroy or replace a component without destroying the other containers or their data.

What do we need to get started?

  1. A container for the HTTPD. We’ll build from nginx and try to configure it for FastCGI.
  2. A container for MySQL. mysql:5 should do.
  3. A container for PHP. Magento requires mcrypt, which unfortunately isn’t in the Docker official PHP image, so we’ll build ours from debian.
  4. A container for data volumes. The simplest docker container needs a no-op executable like trueand some files. We’ll start from scratch and add on from there.
  5. A container for humans to touch data volumes.

How do we set it up?

Docker has a nice tool for orchestrating multiple containers for dev environments called fig. I defined a fig file that builds and connects the aforementioned containers from its Dockerfile in each of the directories named after the service: nginx, php, mysql, data, fs. So just run fig up.

How do I get to my data?

How Docker actually houses live data is a little confusing, particularly if you’re viewing it from a workstation instead of the Docker daemon host, where the volume actually resides. It might help to review Docker’s own documentation on the subject. Anyway, the tl;dr version is that’s what the file share container is for.

How do I use the file share container?

The file share container creates a CIFS share for the Magento directory.

  • OS X: mkdir -p <mountpoint> && mount_smbfs -N //guest@<docker host ip>/magento_data_1 <mountpoint>
  • Windows: net use <drive letter>: \\guest@<docker host ip>\magento_data_1
  • Linux: Similar to the OS X one, probably uses mount -t cifs. I didn’t try it. Alternatively, you can run docker directly on the linux machine and access its volumes directly.

Known issues

  • Speed: The CIFS share is a little slow. I tried to set up an NFS share, but couldn’t get it working. Taking pull requests for faster shares.
  • Disappearing data: Don’t panic – if you try something like docker cp or docker export on the datacontainer it will appear unchanged. The data is safe (in fact, the data is still on the host machine even if you delete the container, as long as you don’t docker rm -v it.) Try something like docker run --volumes-from magento_data_1 debian tar x /srv/magento > export.tar to get a snapshot of your data. (Although it might be easier just to use the share.)