comparison core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php @ 0:c75dbcec494b

Initial commit from drush-created site
author Chris Cannam
date Thu, 05 Jul 2018 14:24:15 +0000
parents
children a9cd425dd02b
comparison
equal deleted inserted replaced
-1:000000000000 0:c75dbcec494b
1 <?php
2
3 namespace Drupal\FunctionalTests;
4
5 use Behat\Mink\Exception\ExpectationException;
6 use Drupal\Component\Serialization\Json;
7 use Drupal\Component\Utility\Html;
8 use Drupal\Core\Url;
9 use Drupal\Tests\BrowserTestBase;
10 use Drupal\Tests\Traits\Core\CronRunTrait;
11
12 /**
13 * Tests BrowserTestBase functionality.
14 *
15 * @group browsertestbase
16 */
17 class BrowserTestBaseTest extends BrowserTestBase {
18
19 use CronRunTrait;
20
21 /**
22 * Modules to enable.
23 *
24 * @var array
25 */
26 public static $modules = ['test_page_test', 'form_test', 'system_test'];
27
28 /**
29 * Tests basic page test.
30 */
31 public function testGoTo() {
32 $account = $this->drupalCreateUser();
33 $this->drupalLogin($account);
34
35 // Visit a Drupal page that requires login.
36 $this->drupalGet('test-page');
37 $this->assertSession()->statusCodeEquals(200);
38
39 // Test page contains some text.
40 $this->assertSession()->pageTextContains('Test page text.');
41
42 // Check that returned plain text is correct.
43 $text = $this->getTextContent();
44 $this->assertContains('Test page text.', $text);
45 $this->assertNotContains('</html>', $text);
46
47 // Response includes cache tags that we can assert.
48 $this->assertSession()->responseHeaderEquals('X-Drupal-Cache-Tags', 'http_response rendered');
49
50 // Test that we can read the JS settings.
51 $js_settings = $this->getDrupalSettings();
52 $this->assertSame('azAZ09();.,\\\/-_{}', $js_settings['test-setting']);
53
54 // Test drupalGet with a url object.
55 $url = Url::fromRoute('test_page_test.render_title');
56 $this->drupalGet($url);
57 $this->assertSession()->statusCodeEquals(200);
58
59 // Test page contains some text.
60 $this->assertSession()->pageTextContains('Hello Drupal');
61
62 // Test that setting headers with drupalGet() works.
63 $this->drupalGet('system-test/header', [], [
64 'Test-Header' => 'header value',
65 ]);
66 $returned_header = $this->getSession()->getResponseHeader('Test-Header');
67 $this->assertSame('header value', $returned_header);
68 }
69
70 /**
71 * Tests drupalGet().
72 */
73 public function testDrupalGet() {
74 $this->drupalGet('test-page');
75 $this->assertSession()->statusCodeEquals(200);
76 $this->assertSession()->addressEquals('test-page');
77 $this->drupalGet('/test-page');
78 $this->assertSession()->statusCodeEquals(200);
79 $this->assertSession()->addressEquals('test-page');
80 $this->drupalGet('/test-page/');
81 $this->assertSession()->statusCodeEquals(200);
82 $this->assertSession()->addressEquals('/test-page/');
83 }
84
85 /**
86 * Tests basic form functionality.
87 */
88 public function testForm() {
89 // Ensure the proper response code for a _form route.
90 $this->drupalGet('form-test/object-builder');
91 $this->assertSession()->statusCodeEquals(200);
92
93 // Ensure the form and text field exist.
94 $this->assertSession()->elementExists('css', 'form#form-test-form-test-object');
95 $this->assertSession()->fieldExists('bananas');
96
97 // Check that the hidden field exists and has a specific value.
98 $this->assertSession()->hiddenFieldExists('strawberry');
99 $this->assertSession()->hiddenFieldExists('red');
100 $this->assertSession()->hiddenFieldExists('redstrawberryhiddenfield');
101 $this->assertSession()->hiddenFieldValueNotEquals('strawberry', 'brown');
102 $this->assertSession()->hiddenFieldValueEquals('strawberry', 'red');
103
104 // Check that a hidden field does not exist.
105 $this->assertSession()->hiddenFieldNotExists('bananas');
106 $this->assertSession()->hiddenFieldNotExists('pineapple');
107
108 $edit = ['bananas' => 'green'];
109 $this->submitForm($edit, 'Save', 'form-test-form-test-object');
110
111 $config_factory = $this->container->get('config.factory');
112 $value = $config_factory->get('form_test.object')->get('bananas');
113 $this->assertSame('green', $value);
114
115 // Test drupalPostForm().
116 $edit = ['bananas' => 'red'];
117 $result = $this->drupalPostForm('form-test/object-builder', $edit, 'Save');
118 $this->assertSame($this->getSession()->getPage()->getContent(), $result);
119 $value = $config_factory->get('form_test.object')->get('bananas');
120 $this->assertSame('red', $value);
121
122 $this->drupalPostForm('form-test/object-builder', NULL, 'Save');
123 $value = $config_factory->get('form_test.object')->get('bananas');
124 $this->assertSame('', $value);
125
126 // Test drupalPostForm() with no-html response.
127 $values = Json::decode($this->drupalPostForm('form_test/form-state-values-clean', [], t('Submit')));
128 $this->assertTrue(1000, $values['beer']);
129 }
130
131 /**
132 * Tests clickLink() functionality.
133 */
134 public function testClickLink() {
135 $this->drupalGet('test-page');
136 $this->clickLink('Visually identical test links');
137 $this->assertContains('user/login', $this->getSession()->getCurrentUrl());
138 $this->drupalGet('test-page');
139 $this->clickLink('Visually identical test links', 0);
140 $this->assertContains('user/login', $this->getSession()->getCurrentUrl());
141 $this->drupalGet('test-page');
142 $this->clickLink('Visually identical test links', 1);
143 $this->assertContains('user/register', $this->getSession()->getCurrentUrl());
144 }
145
146 public function testError() {
147 $this->setExpectedException('\Exception', 'User notice: foo');
148 $this->drupalGet('test-error');
149 }
150
151 /**
152 * Tests linkExists() with pipe character (|) in locator.
153 *
154 * @see \Drupal\Tests\WebAssert::linkExists()
155 */
156 public function testPipeCharInLocator() {
157 $this->drupalGet('test-pipe-char');
158 $this->assertSession()->linkExists('foo|bar|baz');
159 }
160
161 /**
162 * Tests linkExistsExact() functionality.
163 *
164 * @see \Drupal\Tests\WebAssert::linkExistsExact()
165 */
166 public function testLinkExistsExact() {
167 $this->drupalGet('test-pipe-char');
168 $this->assertSession()->linkExistsExact('foo|bar|baz');
169 }
170
171 /**
172 * Tests linkExistsExact() functionality fail.
173 *
174 * @see \Drupal\Tests\WebAssert::linkExistsExact()
175 */
176 public function testInvalidLinkExistsExact() {
177 $this->drupalGet('test-pipe-char');
178 $this->setExpectedException(ExpectationException::class, 'Link with label foo|bar found');
179 $this->assertSession()->linkExistsExact('foo|bar');
180 }
181
182 /**
183 * Tests linkNotExistsExact() functionality.
184 *
185 * @see \Drupal\Tests\WebAssert::linkNotExistsExact()
186 */
187 public function testLinkNotExistsExact() {
188 $this->drupalGet('test-pipe-char');
189 $this->assertSession()->linkNotExistsExact('foo|bar');
190 }
191
192 /**
193 * Tests linkNotExistsExact() functionality fail.
194 *
195 * @see \Drupal\Tests\WebAssert::linkNotExistsExact()
196 */
197 public function testInvalidLinkNotExistsExact() {
198 $this->drupalGet('test-pipe-char');
199 $this->setExpectedException(ExpectationException::class, 'Link with label foo|bar|baz not found');
200 $this->assertSession()->linkNotExistsExact('foo|bar|baz');
201 }
202
203 /**
204 * Tests legacy text asserts.
205 */
206 public function testTextAsserts() {
207 $this->drupalGet('test-encoded');
208 $dangerous = 'Bad html <script>alert(123);</script>';
209 $sanitized = Html::escape($dangerous);
210 $this->assertNoText($dangerous);
211 $this->assertText($sanitized);
212
213 // Test getRawContent().
214 $this->assertSame($this->getSession()->getPage()->getContent(), $this->getRawContent());
215 }
216
217 /**
218 * Tests legacy field asserts which use xpath directly.
219 */
220 public function testXpathAsserts() {
221 $this->drupalGet('test-field-xpath');
222 $this->assertFieldsByValue($this->xpath("//h1[@class = 'page-title']"), NULL);
223 $this->assertFieldsByValue($this->xpath('//table/tbody/tr[2]/td[1]'), 'one');
224 $this->assertFieldByXPath('//table/tbody/tr[2]/td[1]', 'one');
225
226 $this->assertFieldsByValue($this->xpath("//input[@id = 'edit-name']"), 'Test name');
227 $this->assertFieldByXPath("//input[@id = 'edit-name']", 'Test name');
228 $this->assertFieldsByValue($this->xpath("//select[@id = 'edit-options']"), '2');
229 $this->assertFieldByXPath("//select[@id = 'edit-options']", '2');
230
231 $this->assertNoFieldByXPath('//notexisting');
232 $this->assertNoFieldByXPath("//input[@id = 'edit-name']", 'wrong value');
233
234 // Test that the assertion fails correctly.
235 try {
236 $this->assertFieldByXPath("//input[@id = 'notexisting']");
237 $this->fail('The "notexisting" field was found.');
238 }
239 catch (\PHPUnit_Framework_ExpectationFailedException $e) {
240 $this->pass('assertFieldByXPath correctly failed. The "notexisting" field was not found.');
241 }
242
243 try {
244 $this->assertNoFieldByXPath("//input[@id = 'edit-name']");
245 $this->fail('The "edit-name" field was not found.');
246 }
247 catch (ExpectationException $e) {
248 $this->pass('assertNoFieldByXPath correctly failed. The "edit-name" field was found.');
249 }
250
251 try {
252 $this->assertFieldsByValue($this->xpath("//input[@id = 'edit-name']"), 'not the value');
253 $this->fail('The "edit-name" field is found with the value "not the value".');
254 }
255 catch (\PHPUnit_Framework_ExpectationFailedException $e) {
256 $this->pass('The "edit-name" field is not found with the value "not the value".');
257 }
258 }
259
260 /**
261 * Tests legacy field asserts using textfields.
262 */
263 public function testFieldAssertsForTextfields() {
264 $this->drupalGet('test-field-xpath');
265
266 // *** 1. assertNoField().
267 $this->assertNoField('invalid_name_and_id');
268
269 // Test that the assertion fails correctly when searching by name.
270 try {
271 $this->assertNoField('name');
272 $this->fail('The "name" field was not found based on name.');
273 }
274 catch (ExpectationException $e) {
275 $this->pass('assertNoField correctly failed. The "name" field was found by name.');
276 }
277
278 // Test that the assertion fails correctly when searching by id.
279 try {
280 $this->assertNoField('edit-name');
281 $this->fail('The "name" field was not found based on id.');
282 }
283 catch (ExpectationException $e) {
284 $this->pass('assertNoField correctly failed. The "name" field was found by id.');
285 }
286
287 // *** 2. assertField().
288 $this->assertField('name');
289 $this->assertField('edit-name');
290
291 // Test that the assertion fails correctly if the field does not exist.
292 try {
293 $this->assertField('invalid_name_and_id');
294 $this->fail('The "invalid_name_and_id" field was found.');
295 }
296 catch (\PHPUnit_Framework_ExpectationFailedException $e) {
297 $this->pass('assertField correctly failed. The "invalid_name_and_id" field was not found.');
298 }
299
300 // *** 3. assertNoFieldById().
301 $this->assertNoFieldById('name');
302 $this->assertNoFieldById('name', 'not the value');
303 $this->assertNoFieldById('notexisting');
304 $this->assertNoFieldById('notexisting', NULL);
305
306 // Test that the assertion fails correctly if no value is passed in.
307 try {
308 $this->assertNoFieldById('edit-description');
309 $this->fail('The "description" field, with no value was not found.');
310 }
311 catch (ExpectationException $e) {
312 $this->pass('The "description" field, with no value was found.');
313 }
314
315 // Test that the assertion fails correctly if a NULL value is passed in.
316 try {
317 $this->assertNoFieldById('edit-name', NULL);
318 $this->fail('The "name" field was not found.');
319 }
320 catch (ExpectationException $e) {
321 $this->pass('The "name" field was found.');
322 }
323
324 // *** 4. assertFieldById().
325 $this->assertFieldById('edit-name', NULL);
326 $this->assertFieldById('edit-name', 'Test name');
327 $this->assertFieldById('edit-description', NULL);
328 $this->assertFieldById('edit-description');
329
330 // Test that the assertion fails correctly if no value is passed in.
331 try {
332 $this->assertFieldById('edit-name');
333 $this->fail('The "edit-name" field with no value was found.');
334 }
335 catch (\PHPUnit_Framework_ExpectationFailedException $e) {
336 $this->pass('The "edit-name" field with no value was not found.');
337 }
338
339 // Test that the assertion fails correctly if the wrong value is passed in.
340 try {
341 $this->assertFieldById('edit-name', 'not the value');
342 $this->fail('The "name" field was found, using the wrong value.');
343 }
344 catch (\PHPUnit_Framework_ExpectationFailedException $e) {
345 $this->pass('The "name" field was not found, using the wrong value.');
346 }
347
348 // *** 5. assertNoFieldByName().
349 $this->assertNoFieldByName('name');
350 $this->assertNoFieldByName('name', 'not the value');
351 $this->assertNoFieldByName('notexisting');
352 $this->assertNoFieldByName('notexisting', NULL);
353
354 // Test that the assertion fails correctly if no value is passed in.
355 try {
356 $this->assertNoFieldByName('description');
357 $this->fail('The "description" field, with no value was not found.');
358 }
359 catch (ExpectationException $e) {
360 $this->pass('The "description" field, with no value was found.');
361 }
362
363 // Test that the assertion fails correctly if a NULL value is passed in.
364 try {
365 $this->assertNoFieldByName('name', NULL);
366 $this->fail('The "name" field was not found.');
367 }
368 catch (ExpectationException $e) {
369 $this->pass('The "name" field was found.');
370 }
371
372 // *** 6. assertFieldByName().
373 $this->assertFieldByName('name');
374 $this->assertFieldByName('name', NULL);
375 $this->assertFieldByName('name', 'Test name');
376 $this->assertFieldByName('description');
377 $this->assertFieldByName('description', '');
378 $this->assertFieldByName('description', NULL);
379
380 // Test that the assertion fails correctly if given the wrong name.
381 try {
382 $this->assertFieldByName('non-existing-name');
383 $this->fail('The "non-existing-name" field was found.');
384 }
385 catch (\PHPUnit_Framework_ExpectationFailedException $e) {
386 $this->pass('The "non-existing-name" field was not found');
387 }
388
389 // Test that the assertion fails correctly if given the wrong value.
390 try {
391 $this->assertFieldByName('name', 'not the value');
392 $this->fail('The "name" field with incorrect value was found.');
393 }
394 catch (\PHPUnit_Framework_ExpectationFailedException $e) {
395 $this->pass('assertFieldByName correctly failed. The "name" field with incorrect value was not found.');
396 }
397
398 // Test that text areas can contain new lines.
399 $this->assertFieldsByValue($this->xpath("//textarea[@id = 'edit-test-textarea-with-newline']"), "Test text with\nnewline");
400 }
401
402 /**
403 * Tests legacy field asserts for options field type.
404 */
405 public function testFieldAssertsForOptions() {
406 $this->drupalGet('test-field-xpath');
407
408 // Option field type.
409 $this->assertOptionByText('options', 'one');
410 try {
411 $this->assertOptionByText('options', 'four');
412 $this->fail('The select option "four" was found.');
413 }
414 catch (ExpectationException $e) {
415 $this->pass($e->getMessage());
416 }
417
418 $this->assertOption('options', 1);
419 try {
420 $this->assertOption('options', 4);
421 $this->fail('The select option "4" was found.');
422 }
423 catch (ExpectationException $e) {
424 $this->pass($e->getMessage());
425 }
426
427 $this->assertNoOption('options', 'non-existing');
428 try {
429 $this->assertNoOption('options', 'one');
430 $this->fail('The select option "one" was not found.');
431 }
432 catch (ExpectationException $e) {
433 $this->pass($e->getMessage());
434 }
435
436 $this->assertOptionSelected('options', 2);
437 try {
438 $this->assertOptionSelected('options', 4);
439 $this->fail('The select option "4" was selected.');
440 }
441 catch (ExpectationException $e) {
442 $this->pass($e->getMessage());
443 }
444
445 try {
446 $this->assertOptionSelected('options', 1);
447 $this->fail('The select option "1" was selected.');
448 }
449 catch (\PHPUnit_Framework_ExpectationFailedException $e) {
450 $this->pass($e->getMessage());
451 }
452
453 // Test \Drupal\FunctionalTests\AssertLegacyTrait::getAllOptions.
454 $this->drupalGet('/form-test/select');
455 $this->assertCount(6, $this->getAllOptions($this->cssSelect('select[name="opt_groups"]')[0]));
456 }
457
458 /**
459 * Tests legacy field asserts for button field type.
460 */
461 public function testFieldAssertsForButton() {
462 $this->drupalGet('test-field-xpath');
463
464 $this->assertFieldById('edit-save', NULL);
465 // Test that the assertion fails correctly if the field value is passed in
466 // rather than the id.
467 try {
468 $this->assertFieldById('Save', NULL);
469 $this->fail('The field with id of "Save" was found.');
470 }
471 catch (\PHPUnit_Framework_ExpectationFailedException $e) {
472 $this->pass($e->getMessage());
473 }
474
475 $this->assertNoFieldById('Save', NULL);
476 // Test that the assertion fails correctly if the id of an actual field is
477 // passed in.
478 try {
479 $this->assertNoFieldById('edit-save', NULL);
480 $this->fail('The field with id of "edit-save" was not found.');
481 }
482 catch (ExpectationException $e) {
483 $this->pass($e->getMessage());
484 }
485
486 // Test that multiple fields with the same name are validated correctly.
487 $this->assertFieldByName('duplicate_button', 'Duplicate button 1');
488 $this->assertFieldByName('duplicate_button', 'Duplicate button 2');
489 $this->assertNoFieldByName('duplicate_button', 'Rabbit');
490
491 try {
492 $this->assertNoFieldByName('duplicate_button', 'Duplicate button 2');
493 $this->fail('The "duplicate_button" field with the value Duplicate button 2 was not found.');
494 }
495 catch (ExpectationException $e) {
496 $this->pass('assertNoFieldByName correctly failed. The "duplicate_button" field with the value Duplicate button 2 was found.');
497 }
498 }
499
500 /**
501 * Tests legacy field asserts for checkbox field type.
502 */
503 public function testFieldAssertsForCheckbox() {
504 $this->drupalGet('test-field-xpath');
505
506 // Part 1 - Test by name.
507 // Test that checkboxes are found/not found correctly by name, when using
508 // TRUE or FALSE to match their 'checked' state.
509 $this->assertFieldByName('checkbox_enabled', TRUE);
510 $this->assertFieldByName('checkbox_disabled', FALSE);
511 $this->assertNoFieldByName('checkbox_enabled', FALSE);
512 $this->assertNoFieldByName('checkbox_disabled', TRUE);
513
514 // Test that checkboxes are found by name when using NULL to ignore the
515 // 'checked' state.
516 $this->assertFieldByName('checkbox_enabled', NULL);
517 $this->assertFieldByName('checkbox_disabled', NULL);
518
519 // Test that checkboxes are found by name when passing no second parameter.
520 $this->assertFieldByName('checkbox_enabled');
521 $this->assertFieldByName('checkbox_disabled');
522
523 // Test that we have legacy support.
524 $this->assertFieldByName('checkbox_enabled', '1');
525 $this->assertFieldByName('checkbox_disabled', '');
526
527 // Test that the assertion fails correctly when using NULL to ignore state.
528 try {
529 $this->assertNoFieldByName('checkbox_enabled', NULL);
530 $this->fail('The "checkbox_enabled" field was not found by name, using NULL value.');
531 }
532 catch (ExpectationException $e) {
533 $this->pass('assertNoFieldByName failed correctly. The "checkbox_enabled" field was found using NULL value.');
534 }
535
536 // Part 2 - Test by ID.
537 // Test that checkboxes are found/not found correctly by ID, when using
538 // TRUE or FALSE to match their 'checked' state.
539 $this->assertFieldById('edit-checkbox-enabled', TRUE);
540 $this->assertFieldById('edit-checkbox-disabled', FALSE);
541 $this->assertNoFieldById('edit-checkbox-enabled', FALSE);
542 $this->assertNoFieldById('edit-checkbox-disabled', TRUE);
543
544 // Test that checkboxes are found by ID, when using NULL to ignore the
545 // 'checked' state.
546 $this->assertFieldById('edit-checkbox-enabled', NULL);
547 $this->assertFieldById('edit-checkbox-disabled', NULL);
548
549 // Test that checkboxes are found by ID when passing no second parameter.
550 $this->assertFieldById('edit-checkbox-enabled');
551 $this->assertFieldById('edit-checkbox-disabled');
552
553 // Test that we have legacy support.
554 $this->assertFieldById('edit-checkbox-enabled', '1');
555 $this->assertFieldById('edit-checkbox-disabled', '');
556
557 // Test that the assertion fails correctly when using NULL to ignore state.
558 try {
559 $this->assertNoFieldById('edit-checkbox-disabled', NULL);
560 $this->fail('The "edit-checkbox-disabled" field was not found by ID, using NULL value.');
561 }
562 catch (ExpectationException $e) {
563 $this->pass('assertNoFieldById failed correctly. The "edit-checkbox-disabled" field was found by ID using NULL value.');
564 }
565
566 // Part 3 - Test the specific 'checked' assertions.
567 $this->assertFieldChecked('edit-checkbox-enabled');
568 $this->assertNoFieldChecked('edit-checkbox-disabled');
569
570 // Test that the assertion fails correctly with non-existant field id.
571 try {
572 $this->assertNoFieldChecked('incorrect_checkbox_id');
573 $this->fail('The "incorrect_checkbox_id" field was found');
574 }
575 catch (ExpectationException $e) {
576 $this->pass('assertNoFieldChecked correctly failed. The "incorrect_checkbox_id" field was not found.');
577 }
578
579 // Test that the assertion fails correctly for a checkbox that is checked.
580 try {
581 $this->assertNoFieldChecked('edit-checkbox-enabled');
582 $this->fail('The "edit-checkbox-enabled" field was not found in a checked state.');
583 }
584 catch (ExpectationException $e) {
585 $this->pass('assertNoFieldChecked correctly failed. The "edit-checkbox-enabled" field was found in a checked state.');
586 }
587
588 // Test that the assertion fails correctly for a checkbox that is not
589 // checked.
590 try {
591 $this->assertFieldChecked('edit-checkbox-disabled');
592 $this->fail('The "edit-checkbox-disabled" field was found and checked.');
593 }
594 catch (ExpectationException $e) {
595 $this->pass('assertFieldChecked correctly failed. The "edit-checkbox-disabled" field was not found in a checked state.');
596 }
597 }
598
599 /**
600 * Tests the ::cronRun() method.
601 */
602 public function testCronRun() {
603 $last_cron_time = \Drupal::state()->get('system.cron_last');
604 $this->cronRun();
605 $this->assertSession()->statusCodeEquals(204);
606 $next_cron_time = \Drupal::state()->get('system.cron_last');
607
608 $this->assertGreaterThan($last_cron_time, $next_cron_time);
609 }
610
611 /**
612 * Tests the Drupal install done in \Drupal\Tests\BrowserTestBase::setUp().
613 */
614 public function testInstall() {
615 $htaccess_filename = $this->tempFilesDirectory . '/.htaccess';
616 $this->assertTrue(file_exists($htaccess_filename), "$htaccess_filename exists");
617 }
618
619 /**
620 * Tests the assumption that local time is in 'Australia/Sydney'.
621 */
622 public function testLocalTimeZone() {
623 // The 'Australia/Sydney' time zone is set in core/tests/bootstrap.php
624 $this->assertEquals('Australia/Sydney', date_default_timezone_get());
625
626 // The 'Australia/Sydney' time zone is also set in
627 // FunctionalTestSetupTrait::initConfig().
628 $config_factory = $this->container->get('config.factory');
629 $value = $config_factory->get('system.date')->get('timezone.default');
630 $this->assertEquals('Australia/Sydney', $value);
631 }
632
633 /**
634 * Tests the ::checkForMetaRefresh() method.
635 */
636 public function testCheckForMetaRefresh() {
637 // Disable following redirects in the client.
638 $this->getSession()->getDriver()->getClient()->followRedirects(FALSE);
639 // Set the maximumMetaRefreshCount to zero to make sure the redirect doesn't
640 // happen when doing a drupalGet.
641 $this->maximumMetaRefreshCount = 0;
642 $this->drupalGet('test-meta-refresh');
643 $this->assertNotEmpty($this->cssSelect('meta[http-equiv="refresh"]'));
644 // Allow one redirect to happen.
645 $this->maximumMetaRefreshCount = 1;
646 $this->checkForMetaRefresh();
647 // Check that we are now on the test page.
648 $this->assertSession()->pageTextContains('Test page text.');
649 }
650
651 public function testGetDefaultDriveInstance() {
652 putenv('MINK_DRIVER_ARGS=' . json_encode([NULL, ['key1' => ['key2' => ['key3' => 3, 'key3.1' => 3.1]]]]));
653 $this->getDefaultDriverInstance();
654 $this->assertEquals([NULL, ['key1' => ['key2' => ['key3' => 3, 'key3.1' => 3.1]]]], $this->minkDefaultDriverArgs);
655 }
656
657 }