Otherwise, review and use the appropriate steps to install PhantomJS.
If you are running Mac OS X and have Homebrew, you can just run brew install phantomjs. You will need to setup PhantomJS to test the FunctionalJavascript test suite tests. modules/contrib/commerce.) Then change the configuration to be base on the one you created previously, such as core/phpunit.xml. You will want to have it configured to look for tests inside of modules/commerce (or wherever you put Drupal Commerce, e.g. Visit Run -> Edit Configurations and create a new PHPUnit runner. The first step is to create a PHPUnit Runner. Below is a sample of what the configuration changes would look for the environment settings. You can use SQLite for testing, which is my primary use case for setting SIMPLETEST_DB. BROWSERTEST_OUTPUT_DIRECTORY: Specifying this path will save Functional and FunctionalJavascript HTML output.SIMPLETEST_DB: If the site is not installed, or is different than the default database connection.SIMPLETEST_BASE_URL: The URL the Drupal site can be viewed at.There are three values you will want to adjust in the section of the configuration file. The first step is to copy the shipped with Drupal. If you are new to all of this, you will also want to check out the Running PHPUnit tests handbook page on : Configure phpunit.xml PhpStorm professional? Here's the tl dr configurations to put in your project: This allows you to run tests with a minimal environment setup. I run my tests using PHP's built-in server and SQLite. PhpStorm provides a PHPUnit test runner and lets you stay within your workbench to run tests.
We will cover how to setup PhpStorm to run Drupal Commerce's tests. When working with robust field widgets, such as Address' you'll need to use a FunctionalJavascript test. Note: Simpletest had the ability to render Drupal's AJAX Form API operations manually. Drupal\Tests\commerce\Kernel) and tests/src/$type folder (e.g. Tests live in the Drupal\Tests\$module\$type namespace (e.g. A great example is our AddToCartMultipleTest. FunctionalJavascript: These tests have Mink configured to talk to PhantomJS to run JavaScript.This test type will look familiar to those who have worked with Simpletest. Functional: Functional tests are tests which require a fully bootstrapped Drupal and provide browser emulation via Mink.See ProductTest (covers product entity.) as an example You do not need to mock service objects when using a Kernel test. Kernel: Think of a Kernel test as a being a Unit test which has the ability to install schema and config to the database.See DefaultStoreResolverTest as an example. Unit: You are testing class functionality, and mock other required services.In Drupal 8 we now have four different test suites, each with specific purposes. However, I do not recall seeing any of the latter in the wild because it could not communicate with the database. With Simpletest, there were two test suites (kind of): web test and unit test. Unit, Kernel, Functional, and FunctionalJavascript what? Shawn McCabe at Acro Media for working on the product tests and the other remaining tests.ThinkBean for sponsoring my Commerce 2.x, which helped get this initiative wrapped up.Shout out to those who helped ensure we have a well tested project: However, the EntitySelectWidgetTest is probably the most straightforward and shows how easy it is to migrate. We have plenty of commits with examples of porting our tests from Simpletest to Kernel or BrowserTest tests. Within the first few days of work, our TravisCI build was updated to run PhantomJS, and we had our first JavaScript tests running. No longer are we limited to the functionalities of Simpletest and our community to develop it.
Testing JavaScript is done by pointing PhantomJS configuration to Mink. The browser tests use the Mink browser emulator, which anyone working with Behat should be somewhat familiar. We now have PHPUnit as our test framework, the choice of the greater PHP community. Death to Simpletest, Long Live PHPUnit, Mink, and PhantomJS Soon more test types were to follow, such as browser tests and JavaScript testing. With the KernelTestBaseTNG™ issue, Drupal core officially moved to being based on top of PHPUnit for Kernel and Unit tests. Why? Simpletest is a test framework within Drupal and not used by the PHP community at large. At the end of May, I made an initiative to move all of the Drupal Commerce tests away from Simpletest and to use the available test classes built off of PHPUnit.