Skip to main content

Testing your e-commerce PHP application


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 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.


Post a Comment

Popular posts from this blog

PHP Arrays - Associative Arrays or Hash Maps

Associative array or hash maps are listings of key and value pairs with a posibility to nest additional keys and values. An associative array is a very powerful construct within PHP.

In our previous article we discussed simple arrays, which in their turn are indexed associative arrays under the hood. Take the following example:

$array = [

Is in fact an indexed associative array under the hood:

$array = [
0 => 'apple',
1 => 'banana',
2 => 'chocolate',

But associative arrays can be so much more than just an indexed array, and you will find many database operations returning arrays where the fields of a table are the keys in the array while their values are also the values within the array.

$productRowData = [
'product_id' => 1234,
'brand_id' => 321,
'product_name' => 'Our awesome product',
'prodcut_description' => 'This is our most awesome product.&#…

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-…

Practical example: building a social sharing platform

Documenting your project upfront requires time and research, but gives enormous amount of insights and knowledge for the whole team to advance with.

In this article we're continuing where we left off my previous article "Documentation of a project" by providing examples for the documentation focus areas I explained and we're also making sure that we're not tumbling down a rabbit hole where specs are written in stone and we're building this project in a waterfall way.

The Hotbrewd project For this particular example I've chosen a project that has a couple of interesting challenges. It's a social media platform (lots of users) where people can check in their beverage at a specific location or establishment (geolocation), upload photos or videos of their drink (moderation) and share with friends (personal information, profiling). To make it a little entertaining, the more people share and tag, the more stickers they can unlock. Also brands and establishm…