comparison core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php @ 18:af1871eacc83

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:33:08 +0100
parents 129ea1e6d783
children
comparison
equal deleted inserted replaced
17:129ea1e6d783 18:af1871eacc83
472 } 472 }
473 catch (\PHPUnit_Framework_ExpectationFailedException $e) { 473 catch (\PHPUnit_Framework_ExpectationFailedException $e) {
474 $this->pass($e->getMessage()); 474 $this->pass($e->getMessage());
475 } 475 }
476 476
477 // Test \Drupal\FunctionalTests\AssertLegacyTrait::getAllOptions.
478 $this->drupalGet('/form-test/select');
479 $this->assertCount(6, $this->getAllOptions($this->cssSelect('select[name="opt_groups"]')[0]));
480 } 477 }
481 478
482 /** 479 /**
483 * Tests legacy field asserts for button field type. 480 * Tests legacy field asserts for button field type.
484 */ 481 */
642 639
643 /** 640 /**
644 * Tests the assumption that local time is in 'Australia/Sydney'. 641 * Tests the assumption that local time is in 'Australia/Sydney'.
645 */ 642 */
646 public function testLocalTimeZone() { 643 public function testLocalTimeZone() {
644 $expected = 'Australia/Sydney';
647 // The 'Australia/Sydney' time zone is set in core/tests/bootstrap.php 645 // The 'Australia/Sydney' time zone is set in core/tests/bootstrap.php
648 $this->assertEquals('Australia/Sydney', date_default_timezone_get()); 646 $this->assertEquals($expected, date_default_timezone_get());
649 647
650 // The 'Australia/Sydney' time zone is also set in 648 // The 'Australia/Sydney' time zone is also set in
651 // FunctionalTestSetupTrait::initConfig(). 649 // FunctionalTestSetupTrait::initConfig().
652 $config_factory = $this->container->get('config.factory'); 650 $config_factory = $this->container->get('config.factory');
653 $value = $config_factory->get('system.date')->get('timezone.default'); 651 $value = $config_factory->get('system.date')->get('timezone.default');
654 $this->assertEquals('Australia/Sydney', $value); 652 $this->assertEquals($expected, $value);
653
654 // Test that users have the correct time zone set.
655 $this->assertEquals($expected, $this->rootUser->getTimeZone());
656 $admin_user = $this->drupalCreateUser(['administer site configuration']);
657 $this->assertEquals($expected, $admin_user->getTimeZone());
655 } 658 }
656 659
657 /** 660 /**
658 * Tests the ::checkForMetaRefresh() method. 661 * Tests the ::checkForMetaRefresh() method.
659 */ 662 */
685 $this->setExpectedException(\InvalidArgumentException::class, 'The module demo_umami_content does not exist.'); 688 $this->setExpectedException(\InvalidArgumentException::class, 'The module demo_umami_content does not exist.');
686 $this->assertFileExists('core/profiles/demo_umami/modules/demo_umami_content/demo_umami_content.info.yml'); 689 $this->assertFileExists('core/profiles/demo_umami/modules/demo_umami_content/demo_umami_content.info.yml');
687 \Drupal::service('extension.list.module')->getPathname('demo_umami_content'); 690 \Drupal::service('extension.list.module')->getPathname('demo_umami_content');
688 } 691 }
689 692
693 /**
694 * Test the protections provided by .htkey.
695 */
696 public function testHtkey() {
697 // Remove the Simpletest private key file so we can test the protection
698 // against requests that forge a valid testing user agent to gain access
699 // to the installer.
700 // @see drupal_valid_test_ua()
701 // Not using File API; a potential error must trigger a PHP warning.
702 $install_url = Url::fromUri('base:core/install.php', ['external' => TRUE, 'absolute' => TRUE])->toString();
703 $this->drupalGet($install_url);
704 $this->assertSession()->statusCodeEquals(200);
705 unlink($this->siteDirectory . '/.htkey');
706 $this->drupalGet($install_url);
707 $this->assertSession()->statusCodeEquals(403);
708 }
709
690 } 710 }