3 use aik099\PHPUnit\BrowserTestCase;
5 use Drupal\Driver\DrupalDriver;
7 class GeneralTest extends BrowserTestCase
11 * @var \Drupal\Driver\DriverInterface
13 protected static $driver;
15 // Path to a Drupal install. This example assumes the directory is in the same one as the `composer.json` file.
16 protected static $drupalRoot = './drupal';
18 // Url to the homepage of the Drupal install.
19 protected static $uri = 'http://d8.devl';
21 public static $browsers = array(
24 'host' => 'localhost',
26 'browserName' => 'firefox',
27 'baseUrl' => 'http://d8.devl',
31 public static function setUpBeforeClass() {
32 self::$driver = new DrupalDriver(static::$drupalRoot, static::$uri);
33 self::$driver->setCoreFromVersion();
34 self::$driver->bootstrap();
37 public function testUsingSession()
39 // This is Mink's Session.
40 $session = $this->getSession();
43 $session->visit(static::$uri);
45 // Validate text presence on a page.
46 $this->assertTrue($session->getPage()->hasContent('Site-Install'));
49 public function testUsingBrowser()
51 // Prints the name of used browser.
53 "I'm executed using '%s' browser",
54 $this->getBrowser()->getBrowserName()
58 public function testNodeCreate() {
59 $drupal = self::$driver;
61 'title' => $drupal->getRandom()->string(),
64 $drupal->createNode($node);
66 $session = $this->getSession();
67 $session->visit(static::$uri . '/node/' . $node->nid);
69 $this->assertTrue($session->getPage()->hasContent($node->title));