Drupal Drivers Documentation

Similar documents
PHPUnit-Mink Documentation

Behat BDD, FUNCTIONAL TESTS & SELENIUM (IN DRUPAL!)

Peter Sawczynec Engineer

Behat Kickstart. For Drupal 8 Developers. Stanford Drupal Camp 2016 Stanford, CA -- April 1-2, Peter Sawczynec Customer Success Engineer

the Drupal Extension to Behat and Mink Documentation

Behat Drupal Integration Documentation

Vijaya Chandran

Test all the things! Get productive with automated testing in Drupal 8. Sam Becker

Drupal Command Line Instructions Windows 7 List >>>CLICK HERE<<<

Magister 6 API Documentation

Magister 6 API Documentation

PHP XPDF Documentation

Using DRY (Don't Repeat Yourself) Principle in Drupal 8 Site Life Cycle

PHP-SwfTools Documentation

Drupal Command Line Instructions Windows 7 List All Users >>>CLICK HERE<<<

Blog site (cont.) theme, 202 view creations, 205 Browser tools, 196 Buytaert, Dries, 185

A Sweet Test Suite. DrupalCon NA A Sweet Test Suite

COMPOSER IN DRUPAL WORLD

CodeCeption. introduction and use in Yii. Yii London Meetup - 15 April 2014 by Matteo Peach Pescarin

Full Stack Web Developer

Drupal Command Line Instructions Windows 7 List All >>>CLICK HERE<<<

" Qué me estás container?" Docker for dummies

Drupal Command Line Instructions Windows 7 List All Files >>>CLICK HERE<<<

Creating an Online Catalogue Search for CD Collection with AJAX, XML, and PHP Using a Relational Database Server on WAMP/LAMP Server

Improving your Drupal 8 Development Workflow. by Jesus Manuel Olivas / WeKnow

Project Name Documentation

Practical Web Defense Course VIDEO-LAB XML-RPC LAB 1 WEB SERVICES MODULE 11

Recite CMS Web Services PHP Client Guide. Recite CMS Web Services Client

PHP-Einführung - Lesson 8 - Composer (Dependency manager) and JSON. Alexander Lichter June 27, 2017

Drupal 8 Migrations. Keith Dechant Metal 6/7. 1 Drupal 8 Migrations February 4, 2018

IBM Website Monitoring Response Time

Drupal Command Line Instructions Windows 7 List Files >>>CLICK HERE<<<

Building and Maintaining a Distribution in Drupal 7 with Features.

OHO Interactive 55 DAVIS SQUARE / SOMERVILLE, MA Content Entry Guide. Notre Dame of Maryland University Updated: November 1, 2016

Managed Make Project File Error Code Composer

TDD: TEST DRIVEN DRUPAL

Navigator Documentation

Technical Note. PegaCHAT 6.2 SP3. Installing and Configuring OpenFire

Firebase Admin SDK for PHP

Force Login USER GUIDE

Testing in Laravel. an introduction

Configuration Management in Drupal 8

Vitacress Group Cookie Policy

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Drupal

Configuration Management

CS637 Midterm Review

D, E I, J, K, L O, P, Q

Instagram PHP Documentation

UI Patterns Documentation

This tutorial introduces you to FuelPHP framework and makes you comfortable with its various components.

Using the Code Review Module

Using Tools for API Development and Testing

Drupal 7 - Symfony - Dependency Injection Documentation

For Starters: Creating CU Bear, a Drupal 8 Starter Kit

Con guration Management

Drupal Command Line Instructions Windows 7 Network Drive >>>CLICK HERE<<<

Easy Social Feeds with the Migrate API. DrupalCampNJ, Feb. 3, 2018

Hands-On Lab. Launching Contextual Conversations from the Lync Controls. Lab version: 1.0 Last updated: 12/17/2010

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Laravel

Application Deployment With Zend Server 5.5 Beta

Firebase Admin SDK for PHP. Release

If you do not have administrator privileges on your computer and are unable to install Java, please reach out to the ITC Help Desk at

METRANS Drupal Website Training for Content Editors Part 2

BUILDING A PLATFORM FOR NBA

WebDriver: Controlling your Web Browser

Drush User's Guide. Juan Pablo Novillo Requena. Chapter No. 3 "Customizing Drush"

You will get Access to the DDX Portal via Web Browser. Please use the following Address:

Drupal 8 Install Fest

Apache MySQL PHP PHPAdmin Install

BY: ATASHI SAMADDAR 1

Basic Selenium Scripting Tutorial

Jarvis Web Gateway. Installation Instructions. Jonathan Couper-Smartt

More Dev / Less Ops. Sean Dietrich DrupalCorn '18

Apache Mysql And Php Installation And Configuration

Testing the Unit Test Plan for the Media Manager

CCM Website toolkit. Version 1.2 working draft Author Bobby Kimutai. Change revisions. Video links updated

Payment Suite. Release

Web Security: Vulnerabilities & Attacks

Crazy Tricks with Views

4. Application Programming

For this walkthrough in Drupal I will be using the Office of Strategic Communications webpage. First, if you are off campus you must connect to the

Apache Mysql And Php Installation And Configuration

CMS and e-commerce Solutions. version 1.0. Please, visit us at: or contact directly by

Valkyrie REST Server

Export Table Schema To Excel Javascript Ie 10

Intro to. for Content Managers

Automated Installation Guide for CentOS (PHP 7.x)

Product Listing Module 2.0 for Corporate Websites on Drupal

The journey of a module from Drupal 7 to Drupal 8

ULTEO OPEN VIRTUAL DESKTOP CENTOS 6.0 SUPPORT

XTM Connect Drupal Connector. A Translation Management Tool Plugin

Phpmyadmin Error In Processing Request Error Code 200

Build & Launch Tools (BLT) Automating best practices for enterprise sites

Programming for the Web with PHP

Security Guide. Configuration of Permissions

Chargify SDK for PHP Documentation

Drupal Basics. for COS and CLASS site maintainers

European Commission SVN+WebDAV install documentation

How To Manually Edit Wordpress Theme Name And Author

Working with the Seagull Framework. By Demian Turner, Seagull Systems

Transcription:

Drupal Drivers Documentation Release 1.0 Jonathan Hedstrom September 03, 2015

Contents 1 Installation 3 2 Comparison of Drivers 5 3 Usage 7 3.1 Drupal API driver............................................ 7 3.2 Drush driver............................................... 7 3.3 Blackbox................................................. 8 3.4 Practical example with PHPUnit..................................... 8 i

ii

Drupal Drivers Documentation, Release 1.0 The Drupal Drivers are a collection of light-weight drivers with a common interface for interacting with Drupal. These are generally intended for testing, and are not meant to be API-complete. Contents: Contents 1

Drupal Drivers Documentation, Release 1.0 2 Contents

CHAPTER 1 Installation To utilize the Drupal Drivers in your own project, they are installed via composer. { } "require": { "drupal/drupal-driver": "~1.0" } and then install and run composer $> curl -ss http://getcomposer.org/installer php $> php composer.phar install 3

Drupal Drivers Documentation, Release 1.0 4 Chapter 1. Installation

CHAPTER 2 Comparison of Drivers The available drivers for interacting with your site, which are compatible with Drupal 7, and 8. Each driver has its own limitiations. Feature Blackbox Drush Drupal API Create users No Yes Yes Create nodes No No Yes Create vocabularies No No Yes Create taxonomy terms No No Yes Run tests and site on different servers Yes Yes No 5

Drupal Drivers Documentation, Release 1.0 6 Chapter 2. Comparison of Drivers

CHAPTER 3 Usage 3.1 Drupal API driver 1 <?php 2 3 use Drupal\Driver\DrupalDriver; 4 use Drupal\Driver\Cores\Drupal8; 5 6 require 'vendor/autoload.php'; 7 8 // Path to Drupal. 9 $path = './drupal-8'; 10 11 // Host. 12 $uri = 'http://d8.devl'; 13 14 $driver = new DrupalDriver($path, $uri); 15 $driver->setcorefromversion(); 16 17 // Bootstrap Drupal. 18 $driver->bootstrap(); 19 20 // Create a node. 21 $node = (object) array( 22 'type' => 'article', 23 'uid' => 1, 24 'title' => $driver->getrandom()->name(), 25 ); 26 $driver->createnode($node); 3.2 Drush driver 1 <?php 2 3 use Drupal\Driver\DrushDriver; 4 5... 6 7 $alias = '@mysite'; 8 $driver = new DrushDriver($alias); 7

Drupal Drivers Documentation, Release 1.0 9 10... 3.3 Blackbox Note, the blackbox driver has no ability to control Drupal, and is provided as a fallback for when some tests can run without such access. Any testing application should catch unsupported driver exceptions. 1 <?php 2 3 use Drupal\Driver\BlackboxDriver; 4 use Drupal\Driver\Exception\UnsupportedDriverActionException; 5 6... 7 8 $driver = new BlackboxDriver($alias); 9 10 try { 11 // Create a node. 12 $node = (object) array( 13 'type' => 'article', 14 'uid' => 1, 15 'title' => $driver->getrandom()->name(), 16 ); 17 $driver->createnode($node); 18 } 19 catch (UnsupportedDriverActionException $e) { 20 // Mark test as skipped. 21 } 3.4 Practical example with PHPUnit 1 { By using the phpunit/mink project in conjunction with the Drupal Driver, one can use PHPUnit to drive browser sessions and control Drupal. To install: 2 "require": { 3 "aik099/phpunit-mink": "~2.0", 4 "drupal/drupal-driver": "~1.0" 5 } 6 } and then, in the tests directory, a sample test: 1 <?php 2 3 use aik099\phpunit\browsertestcase; 4 5 use Drupal\Driver\DrupalDriver; 6 7 class GeneralTest extends BrowserTestCase 8 Chapter 3. Usage

Drupal Drivers Documentation, Release 1.0 8 { 9 10 /** 11 * @var \Drupal\Driver\DriverInterface 12 */ 13 protected $driver; 14 15 // Path to a Drupal install. This example assumes the directory is in the same one as the `compos 16 protected static $drupalroot = './drupal'; 17 18 // Url to the homepage of the Drupal install. 19 protected static $uri = 'http://d8.devl'; 20 21 public static $browsers = array( 22 // Selenium info. 23 array( 24 'host' => 'localhost', 25 'port' => 4444, 26 'browsername' => 'firefox', 27 'baseurl' => 'http://d8.devl', 28 ), 29 ); 30 31 public function setup() { 32 $this->driver = new DrupalDriver(static::$drupalRoot, static::$uri); 33 $this->driver->setcorefromversion(); 34 $this->driver->bootstrap(); 35 } 36 37 public function testusingsession() 38 { 39 // This is Mink's Session. 40 $session = $this->getsession(); 41 42 // Go to a page. 43 $session->visit(static::$uri); 44 45 // Validate text presence on a page. 46 $this->asserttrue($session->getpage()->hascontent('site-install')); 47 } 48 49 public function testusingbrowser() 50 { 51 // Prints the name of used browser. 52 echo sprintf( 53 "I'm executed using '%s' browser", 54 $this->getbrowser()->getbrowsername() 55 ); 56 } 57 58 public function testnodecreate() { 59 $node = (object) [ 60 'title' => $this->driver->getrandom()->string(), 61 'type' => 'article', 62 ]; 63 $this->driver->createnode($node); 64 65 $session = $this->getsession(); 3.4. Practical example with PHPUnit 9

Drupal Drivers Documentation, Release 1.0 66 $session->visit(static::$uri. '/node/'. $node->nid); 67 68 $this->asserttrue($session->getpage()->hascontent($node->title)); 69 } 70 71 } 10 Chapter 3. Usage