Mercurial > hg > isophonics-drupal-site
comparison core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | 4c8ae668cc8c |
children | c2387f117808 |
comparison
equal
deleted
inserted
replaced
13:5fb285c0d0e3 | 14:1fec387a4317 |
---|---|
13 */ | 13 */ |
14 abstract class JavascriptTestBase extends BrowserTestBase { | 14 abstract class JavascriptTestBase extends BrowserTestBase { |
15 | 15 |
16 /** | 16 /** |
17 * {@inheritdoc} | 17 * {@inheritdoc} |
18 * | |
19 * To use a webdriver based approach, please use DrupalSelenium2Driver::class. | |
20 * We will switch the default later. | |
18 */ | 21 */ |
19 protected $minkDefaultDriverClass = PhantomJSDriver::class; | 22 protected $minkDefaultDriverClass = PhantomJSDriver::class; |
20 | 23 |
21 /** | 24 /** |
22 * {@inheritdoc} | 25 * {@inheritdoc} |
23 */ | 26 */ |
24 protected function initMink() { | 27 protected function initMink() { |
25 // Set up the template cache used by the PhantomJS mink driver. | 28 if ($this->minkDefaultDriverClass === DrupalSelenium2Driver::class) { |
26 $path = $this->tempFilesDirectory . DIRECTORY_SEPARATOR . 'browsertestbase-templatecache'; | 29 $this->minkDefaultDriverArgs = ['chrome', NULL, 'http://localhost:4444/']; |
27 $this->minkDefaultDriverArgs = [ | 30 } |
28 'http://127.0.0.1:8510', | 31 elseif ($this->minkDefaultDriverClass === PhantomJSDriver::class) { |
29 $path, | 32 // Set up the template cache used by the PhantomJS mink driver. |
30 ]; | 33 $path = $this->tempFilesDirectory . DIRECTORY_SEPARATOR . 'browsertestbase-templatecache'; |
31 if (!file_exists($path)) { | 34 $this->minkDefaultDriverArgs = [ |
32 mkdir($path); | 35 'http://127.0.0.1:8510', |
36 $path, | |
37 ]; | |
38 if (!file_exists($path)) { | |
39 mkdir($path); | |
40 } | |
33 } | 41 } |
34 | 42 |
35 try { | 43 try { |
36 return parent::initMink(); | 44 return parent::initMink(); |
37 } | 45 } |
62 } | 70 } |
63 parent::tearDown(); | 71 parent::tearDown(); |
64 } | 72 } |
65 | 73 |
66 /** | 74 /** |
75 * {@inheritdoc} | |
76 */ | |
77 protected function getMinkDriverArgs() { | |
78 if ($this->minkDefaultDriverClass === DrupalSelenium2Driver::class) { | |
79 return getenv('MINK_DRIVER_ARGS_WEBDRIVER') ?: getenv('MINK_DRIVER_ARGS_PHANTOMJS') ?: parent::getMinkDriverArgs(); | |
80 } | |
81 elseif ($this->minkDefaultDriverClass === PhantomJSDriver::class) { | |
82 return getenv('MINK_DRIVER_ARGS_PHANTOMJS') ?: parent::getMinkDriverArgs(); | |
83 } | |
84 return parent::getMinkDriverArgs(); | |
85 } | |
86 | |
87 /** | |
67 * Asserts that the element with the given CSS selector is visible. | 88 * Asserts that the element with the given CSS selector is visible. |
68 * | 89 * |
69 * @param string $css_selector | 90 * @param string $css_selector |
70 * The CSS selector identifying the element to check. | 91 * The CSS selector identifying the element to check. |
71 * @param string $message | 92 * @param string $message |
167 EndOfScript; | 188 EndOfScript; |
168 | 189 |
169 return $this->getSession()->evaluateScript($script) ?: []; | 190 return $this->getSession()->evaluateScript($script) ?: []; |
170 } | 191 } |
171 | 192 |
193 /** | |
194 * {@inheritdoc} | |
195 */ | |
196 protected function getHtmlOutputHeaders() { | |
197 // The webdriver API does not support fetching headers. | |
198 return ''; | |
199 } | |
200 | |
172 } | 201 } |