/** * {@inheritdoc} */ public function setUp() { if (!module_exists('nexteuropa_data_export_test')) { throw new \Exception('nexteuropa_data_export_test module must be enabled.'); } // Setup Mink. $this->mink = new Mink(array('goutte' => new Session(new GoutteDriver(new GoutteClient())))); $this->mink->setDefaultSessionName('goutte'); // Setup Drupal driver. $this->driver = new DrupalDriver(DRUPAL_ROOT, BASE_URL); $this->driver->setCoreFromVersion(); }
<?php use Drupal\Driver\DrupalDriver; use Drupal\Driver\Cores\Drupal8; require 'vendor/autoload.php'; // Path to Drupal. $path = './drupal-8'; // Host. $uri = 'http://d8.devl'; $driver = new DrupalDriver($path, $uri); $driver->setCoreFromVersion(); // Bootstrap Drupal. $driver->bootstrap(); // Create a node. $node = (object) array('type' => 'article', 'uid' => 1, 'title' => $driver->getRandom()->name()); $driver->createNode($node);
<?php /** * @file * Bootstraps Drupal 7 site. */ use Drupal\Driver\DrupalDriver; use Drupal\Driver\Cores\Drupal7; require 'vendor/autoload.php'; $dir = explode('/sites/', getcwd()); // No split may mean we are in a profiles folder: if (count($dir) == 1) { $dir = explode('/profiles/', getcwd()); } // Path to Drupal. $path = $dir[0]; // Host. $uri = 'http://localhost'; $driver = new DrupalDriver($path, $uri); $driver->setCoreFromVersion(); // Bootstrap Drupal. $driver->bootstrap();