forked from drupal/drupal
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDebugTest.php
More file actions
76 lines (62 loc) · 2.01 KB
/
DebugTest.php
File metadata and controls
76 lines (62 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
namespace Drupal\Tests\system\FunctionalJavascript;
use Behat\Mink\Driver\Selenium2Driver;
use Drupal\FunctionalJavascriptTests\DrupalSelenium2Driver;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
/**
* Class DebugTest
*
* @group debug
*/
class DebugTest extends WebDriverTestBase {
/**
* Passes for ted and Peter?
*/
public function testXPath() {
$driver = $this->getSession()->getDriver();
$this->assertEquals('Drupal\FunctionalJavascriptTests\DrupalSelenium2Driver', get_class($driver));
$this->drupalGet('debug.html');
$assert_session = $this->assertSession();
$page = $this->getSession()->getPage();
$this->assertEquals('//html', $page->getXpath());
$this->assertNotEmpty($driver->getContent());
$this->drupalGet('user');
$page = $this->getSession()->getPage();
$this->assertEquals('//html', $page->getXpath());
$this->assertNotEmpty($driver->getContent());
}
/**
* works for ted, not Peter
*/
public function testDrupalGetDrupalHtml() {
$this->drupalGet('user');
$driver = $this->getSession()->getDriver();
$doc = new \DOMDocument();
$content = $driver->getContent();
// We got the actual page from Drupal.
$this->assertTrue(strstr($content, 'Username') !== FALSE);
$doc->loadXML($content);
// This doesn't work for Peter?
$xpath = new \DOMXPath($doc);
/** @var \DOMNodeList $elements */
$elements = $xpath->query("//html/body");
$this->assertNotEmpty($elements);
foreach ($elements as $element) {
$this->assertEquals('body', $element->nodeName);
}
}
/**
* Works for both Ted and peter.
*/
public function testDrupalGetValidHtml() {
$this->drupalGet('validxml.xml');
$driver = $this->getSession()->getDriver();
$doc = new \DOMDocument();
$content = $driver->getContent();
$doc->loadXML($content);
$xpath = new \DOMXPath($doc);
// example 1: for everything with an id
$elements = $xpath->query("//book");
$this->assertNotEmpty($elements);
}
}