Skip to content

Initial experiment into how we can create doubles for Mage::getModel() at runtime

Notifications You must be signed in to change notification settings

MageTest/MagentoTestDoubles

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

Magento Test Doubles

One of the big obstacles that developers face when attempting to write tests for Magento is the untestability of the Magento core; no better example other than the Magento god class, Mage.

The god class in magento is used for all sort of operations, from model factory methods like Mage::getModel() to retrieval of configuration values from the database using Mage::getConfig().

Unfortunately the use of this God class makes the code untestable for several reasons:

  • Tightly coupled code.
  • Highly dependent of the database.

MagentoTestDoubles is a PHPSpec extension intended to provide a way to mock the Magento god class using the Patchwork library.

Patchwork allows to redefine user-defined functions during runtime. For a quick proof of concept example please look here

Installation

Prerequisites

About

Initial experiment into how we can create doubles for Mage::getModel() at runtime

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published