X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fdrupal%2Fdrupal-driver%2Fdoc%2F_static%2Fsnippets%2FphpunitDrupalDriver.php;fp=vendor%2Fdrupal%2Fdrupal-driver%2Fdoc%2F_static%2Fsnippets%2FphpunitDrupalDriver.php;h=3c700680898e670bb84f1af8569409ad1eaf3109;hp=0000000000000000000000000000000000000000;hb=1270d9129ce8f27c9b28b10518e32132c58e0aca;hpb=c27c0f0cdaa3f354b1fe54a56ae7e854be6e3f68 diff --git a/vendor/drupal/drupal-driver/doc/_static/snippets/phpunitDrupalDriver.php b/vendor/drupal/drupal-driver/doc/_static/snippets/phpunitDrupalDriver.php new file mode 100644 index 000000000..3c7006808 --- /dev/null +++ b/vendor/drupal/drupal-driver/doc/_static/snippets/phpunitDrupalDriver.php @@ -0,0 +1,72 @@ + 'localhost', + 'port' => 4444, + 'browserName' => 'firefox', + 'baseUrl' => 'http://d8.devl', + ), + ); + + public static function setUpBeforeClass() { + self::$driver = new DrupalDriver(static::$drupalRoot, static::$uri); + self::$driver->setCoreFromVersion(); + self::$driver->bootstrap(); + } + + public function testUsingSession() + { + // This is Mink's Session. + $session = $this->getSession(); + + // Go to a page. + $session->visit(static::$uri); + + // Validate text presence on a page. + $this->assertTrue($session->getPage()->hasContent('Site-Install')); + } + + public function testUsingBrowser() + { + // Prints the name of used browser. + echo sprintf( + "I'm executed using '%s' browser", + $this->getBrowser()->getBrowserName() + ); + } + + public function testNodeCreate() { + $drupal = self::$driver; + $node = (object) [ + 'title' => $drupal->getRandom()->string(), + 'type' => 'article', + ]; + $drupal->createNode($node); + + $session = $this->getSession(); + $session->visit(static::$uri . '/node/' . $node->nid); + + $this->assertTrue($session->getPage()->hasContent($node->title)); + } + +}