A simple set of tools and files to make your Drupal Installation a Testable Drupal Installation. Based on Behat, Mink and using Selenium2, Phantomjs and CasperJs, Testable Drupal provide a basic structure to integrate with your tests.
At this time Testable Drupal has basic tests to
- verify Drupal installation. - using Mink and CasperJs
- to perform a screenshot when required or when a test fail (if you are not using Goutte). - Using Mink
- to perform a 'node create' and 'node update' with interface interaction (waiting for the appearance of the menu, then click... etc). - Using CasperJs
- Composer
- An installation of Drupal (your installation). I have worked with Drupal 7.22
- Drush
- drupal-extension - provided by composer
- Behat - provided by composer
- Mink with extension for Goutte, Mink and Selenium drivers - provided by composer
- Selenium2
- PhantomJs
- CasperJs
-
Install and configure your Drupal installation
-
Download Composer in the root of your project
curl -s https://getcomposer.org/installer | php
- If not present create in the root of your project a file with name composer.json with this content:
{
"require": {
"vincenzodibiaggio/testable-drupal": "*"
},
"minimum-stability": "dev",
"config": {
"bin-dir": "bin/"
}
}
- Download dependencies in your project directory
php composer.phar install
-
Download Selenium server
-
Download PhantomJs
-
Download CasperJs - Pay attention: to use all of feature the minimum version is 1.1-beta1 !
-
Puth both PhantomJs and CasperJs executables in your PATH
Now Testable Drupal support two test suite
- 'PHP': Behat/Mink/Selenium/PhantomJs using deep Drupal integration
- 'JS': PhantomJs/CasperJs to deep interface behavior testing
- Modify paths and host in
tests/behat_dist.yml
:wd_host
,root
,drupal_root
- If you want you can rename
behat_dist.yml
inbehat.yml
but if you launchbehat --init
you overwrite it!
(if you launch a behat --init
for error you can use the FeatureContext_dist.php
to replace the new file)
- Run Selenium2
java -jar selenium-server-standalone-YOUR_VERSION.jar -role hub
- Run PhantomJs
phantomjs --webdriver=8080 --webdriver-selenium-grid-hub=http://127.0.0.1:4444
- Run tests
cd vendor/vincenzodibiaggio/testable-drupal/tests
./../../../../bin/behat --config behat_dist.yml features/test.feature
- Modify values in
testable-drupal/jsTests/includes/includeCasper.js
- I'm working in a better integration with Drupal
I recommend to you: put both PhantomJs and CasperJs executables in your PATH. They work fine together without configuration ;)
- Just run the test: (if you respect the order of filenames you will create nodes and make other test on it... otherwise you will test a failure :D )
cd vendor/vincenzodibiaggio/testable-drupal/jsTests
casperjs test FILENAME