Creating unit tests

This chapter assumes that we have PHPUnit configured and available on the command line. If this is not the case, PHPUnit can be installed using instructions from the website.

To build and run tests using the PHPUnit testing framework, we need to define test locations and other configuration options via an XML file. Magento defines this XML configuration file under dev/tests/unit/phpunit.xml.dist. Let's make a copy of that file under dev/tests/unit/phpunit-foggyline-helpdesk.xml, with adjustments as follows:

<?xml version="1.0" encoding="UTF-8"?> <phpunit xmlns:xsi="" xsi:noNamespaceSchemaLocation=" /phpunit.xsd" colors="true" bootstrap="./framework/bootstrap.php" ...

Get Magento 2 Developer's Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.