Magento Testing - London Magento User Group, December Meetup
Upcoming SlideShare
Loading in...5

Magento Testing - London Magento User Group, December Meetup



My presentation about Magento Testing, 4th of December 2013, London Magento User Group, December Meetup. ...

My presentation about Magento Testing, 4th of December 2013, London Magento User Group, December Meetup.

You can test any aspect of Magento. Having a continuous integration process in place and test coverage will give your development team confidence to release new functionality even on a Friday afternoon.

Florinel is currently co-founder and Chief Service Officer at Elastera (, a cloud-based Platform as a Service for Magento e-commerce sites.



Total Views
Views on SlideShare
Embed Views



4 Embeds 99 67 15 11 6



Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment

Magento Testing - London Magento User Group, December Meetup Magento Testing - London Magento User Group, December Meetup Presentation Transcript

  • Testing Magento Florinel Chis @florinelchis London Magento User Group – December Meetup
  • whoami Co-Founder and Chief Service Officer - Development Lead at Warner Music - 11 years in e-commerce - Magento since 2008
  • Magento Testing • Unit Testing – Tools – EcomDev_PHPUnit • Functional Testing (CasperJS) • Performance Testing – Web page performance testing – XHProf, Aoe_Profiler • Resources
  • Unit Testing • Available tools: – plain phpunit – MTAF – EcomDev_PHPUnit – TechDivision_MagentoUnitTesting – Mage-Test
  • Plain phpunit • Test API calls • Test libraries • Other basic tests • Any other aspect of Magento that is not dependent on things like session • Requires lots of effort in “setUp()”
  • EcomDev_PHPUnit • Integrated with Magento • Supports Fixtures • You can test pretty much any aspect of Magento (Controllers, Models, Layout, Config, etc)
  • Database settings • app/etc/local.xml.phpunit <phpunit> <allow_same_db>?</allow_same_db> </phpunit> • 0 – Requires a separate db for the tests • 1 – You can use the same db that Magento uses (local.xml) Note: Fixtures will delete all existing records (@see ::apply() function in Fixture/Processor/*)
  • Module Structure #Namespace/Module/etc/config.xml <phpunit> <suite> <modules> <Namespace_Module /> </modules> </suite> </phpunit> #Test files: Namespace/Module/Test/PathTo/Class.php Namespace/Module/Test/fixtures/*.yaml Namespace/Module/Test/expectations/*.yaml Namespace/Module/Test/providers/*.yaml
  • Testing Emails • Extend Mage_Core_Model_Email_Template • (+API)
  • Mage_Core_Model_Email_Template Mage::getConfig()->setNode( 'global/models/core/rewrite/email_template', 'Namespace_Test_Model_Email_Template' ); // This is a hack to get the runtime config changes to take effect Mage::getModel('core/email_template'); $mailTemplate = Mage::getModel('core/email_template'); //… do your stuff Note: is the inspiration for this approach
  • Mailcatcher configuration $ gem install mailcatcher $ mailcatcher php.ini: sendmail_path = /usr/bin/env catchmail -f #REST API: /messages /messages/1.plain /messages/1.json
  • Mailcatcher
  • CI Integration • • Book: Integrating PHP Projects with Jenkins by Sebastian Bergmann
  • Examples • Unit Test Demo
  • Functional Testing with CasperJS “CasperJS is an open source navigation scripting & testing utility” • Writtern for PhantomJS or SlimerJS • Good for “writing functional test suites, saving results as JUnit XML” • Other cool features: take screenshots, test remote DOM, scrape web documents
  • ‘No more CAPTCHAs, end robot discrimination’
  • Why CasperJS • Friendly • Javascript • Quick • Simple
  • Performance testing • Web Page – – PageSpeed – YSlow – other tools • Magento
  • • CI Integration – API – PhantomJS + YSlow
  • PhantomJS + YSlow phantomjs yslow.js phantomjs yslow.js -i grade -f xml phantomjs yslow.js --info all --format plain --ua "MSIE 9.0" phantomjs yslow.js -i basic --rulseset yslow1 -d phantomjs yslow.js -i grade -b -v phantomjs --load-plugins=yes yslow.js -vp 800x600 phantomjs yslow.js -i grade -f tap -t 85
  • CSS Testing • CSSLint • PhantomCSS
  • CSSLint • csslint --warnings=box-model,ids filename.css – [--format=junit-xml | checkstyle-xml]
  • PhantomCSS •
  • PhantomCSS Tips • Avoid dynamic data (homepage menu, banners) • Use version control for the base pictures (and make sure you update them when they should change) • Use the same OS/browser/viewport
  • Magento Performance - XHProf “XHProf is a function-level hierarchical profiler for PHP and has a simple HTML based user interface.” Magento modules: Demac_Xhprof and Liip_Xhprof
  • Aoe_Profiler
  • Where to go from here? • • • • • • • • •
  • Questions?
  • Thank you. @florinelchis