Skip to main content

Testing your e-commerce PHP application

#30daysoftesting

I'm participating (as much as possible) in the #30daysoftesting challenge organised by Ministry of Testing and SauceLabs. If you're interested, read the full 30 Days of E-Commerce Testing article and join this fun and educational challenge.

The 2nd challenge on the list was to read and share interesting blog articles about E-commerce testing. Since I'm working as a PHP professional I thought it would be great if I oriented my focus on testing PHP based E-commerce platforms. I picked WooCommerce as it's an easy to install and use E-commerce solution. For Magento, PrestaShop and others I've added useful links at the bottom of this article.

WooCommerce

WooCommerce Homepage

WooCommerce is an add-on for WordPress, allowing you to integrate E-commerce functionality directly within your blog. This ensures you can be up-and-running in no-time. Even though WooCommerce and WordPress are very active community-driven projects, they both suffer from legacy that has been carried along with WordPress since it's origin: it wasn't build with testing in mind.

Don't get me wrong, the latest versions of WooCommerce and WordPress have unit tests, but their users and integration community was never engaged to automate tests or have taken on a habit of testing. Both platforms come equipped with all the tools required for automated testing when you check out the development code. Production code for the general public do not include these tests. Maybe that's why there's not such a testing culture on these projects.

WordPress PHPUnit tests
Running PHPUnit tests on WordPress Core


If you like to know more about testing WordPress (and fixing bugs), check out their "Make WordPress Core Handbook" as it will give you step-by-step instructions how to get started testing WordPress.

On top of WordPress sits WooCommerce as a plugin (or add-on). Where WordPress offers a step-by-step guide to prepare for testing, WooCommerce offers a Core Testing Guide on their GitHub Wiki. Setting your environment up for testing WooCommerce is a little bit tricky following their guide only, but luckily Jon Moore has a detailed blog article written for unit and end-to-end testing WooCommerce that you can use as a guide to automatically test your WooCommerce application.

WooCommerce PHPUnit tests
Running PHPUnit tests on WooCommerce


Other PHP E-commerce platforms

As mentioned earlier, there are several other E-commerce platforms besides WooCommerce on WordPress: Magento, PrestaShop, OpenCart, Sylius, Aimeos and many more. I'm not going in detail about their functionality and features, instead I'm more interested in their testing culture and how they allow developers and users to automate their tests.

Magento Testing Resources


PrestaShop Testing Resources

We see that these mentioned E-commerce projects are seeing the importance of testing and are working hard to improve their code coverage. After all, it's in their best interest to ensure that their users can sell and ship products and get paid in return for their products and/or services. Nobody wants to loose money.

But we also see that the adaption of tests by users, integrators or hosting companies is not their primary focus. Doing research to get started with testing a commercial web application is not easy, articles are often out-dated or incomplete. 

Hopefully with this #30daysoftesting initiative by Ministry of Testing and SauceLabs we can get more involvement from the community in testing their E-commerce solutions and make these platforms more robust and resilient.

What are your thoughts? Leave your comments and thoughts below or when communicating over social media use the hashtag #30daysoftesting.

Comments

Popular posts from this blog

PHP 7 and Apache on macOS Sierra

I posted several talks about compiling PHP from source, but everyone was trying to convince me that a package manager like Homebrew was a more convenient way to install. The purpose of Homebrew is simple: a package manager for macOS that will allow you to set up and install common packages easily and allows you to update frequently using simple commands. I used a clean installation of macOS Sierra to ensure all steps could be recorded and tested. In most cases you already have done work on your Mac, so chances are you can skip a few steps in this tutorial. APACHE AND PHP WITH HOMEBREW I’ve made this according to the installation instructions given on GetGrav. The installation procedures These installation procedures will set up your macOS Sierra with PHP 7.1 and Apache 2.4. Install Xcode command line tools (if not done yet)xcode-select --install Install Homebrew/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" Set up for in…

Speeding up database calls with PDO and iterators

When you review lots of code, you often wonder why things were written the way they were. Especially when making expensive calls to a database, I still see things that could and should be improved.
No framework development When working with a framework, mostly these database calls are optimized for the developer and abstract the complex logic to improve and optimize the retrieval and usage of data. But then developers need to build something without a framework and end up using the basics of PHP in a sub-optimal way.

$pdo = new \PDO( $config['db']['dsn'], $config['db']['username'], $config['db']['password'] ); $sql = 'SELECT * FROM `gen_contact` ORDER BY `contact_modified` DESC'; $stmt = $pdo->prepare($sql); $stmt->execute(); $data = $stmt->fetchAll(\PDO::FETCH_OBJ); echo 'Getting the contacts that changed the last 3 months' . PHP_EOL; foreach ($data as $row) { $dt = new \DateTime('2015-04-…

Sessions in PHP 7.1 and Redis

In case you have missed it, PHP 7.1.0 has been released recently. Now you can’t wait to upgrade your servers to the latest and greatest PHP version ever. But hold that thought a second… With PHP 7 lots of things have changed underneath the hood. But these changed features can also put unexpected challenges on your path. Our challenge One of these challenges that we faced was getting PHP 7.1 to play nice storing sessions in our Redis storage. In order to store sessions in Redis, we needed to install the Redis PHP extension that not only provides PHP functions for Redis, but also installs the PHP session handler for Redis. Because we upgraded our servers to PHP 7.1, we were looking to use the latest provided version for this Redis extension: redis-3.1.0. Once installed, we bumped against a nasty problem. Warning: session_start(): Failed to read session data: redis (path: tcp://127.0.0.1:6379) Searching the internet for this error, we didn’t got many hits that could point us into a dire…