X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Ftests%2FDrupal%2FFunctionalTests%2FBrowserTestBaseTest.php;fp=web%2Fcore%2Ftests%2FDrupal%2FFunctionalTests%2FBrowserTestBaseTest.php;h=fb564450b966650400259f8a5c061052e555c647;hp=38e610c3b56611a7546dd66a764551c2066b60ff;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/web/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php b/web/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php index 38e610c3b..fb564450b 100644 --- a/web/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php +++ b/web/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php @@ -23,7 +23,7 @@ class BrowserTestBaseTest extends BrowserTestBase { * * @var array */ - public static $modules = ['test_page_test', 'form_test', 'system_test']; + public static $modules = ['test_page_test', 'form_test', 'system_test', 'node']; /** * Tests basic page test. @@ -67,6 +67,21 @@ class BrowserTestBaseTest extends BrowserTestBase { $this->assertSame('header value', $returned_header); } + /** + * Tests drupalGet(). + */ + public function testDrupalGet() { + $this->drupalGet('test-page'); + $this->assertSession()->statusCodeEquals(200); + $this->assertSession()->addressEquals('test-page'); + $this->drupalGet('/test-page'); + $this->assertSession()->statusCodeEquals(200); + $this->assertSession()->addressEquals('test-page'); + $this->drupalGet('/test-page/'); + $this->assertSession()->statusCodeEquals(200); + $this->assertSession()->addressEquals('/test-page/'); + } + /** * Tests basic form functionality. */ @@ -111,6 +126,15 @@ class BrowserTestBaseTest extends BrowserTestBase { // Test drupalPostForm() with no-html response. $values = Json::decode($this->drupalPostForm('form_test/form-state-values-clean', [], t('Submit'))); $this->assertTrue(1000, $values['beer']); + + // Test drupalPostForm() with form by HTML id. + $this->drupalCreateContentType(['type' => 'page']); + $this->drupalLogin($this->drupalCreateUser(['create page content'])); + $this->drupalGet('form-test/two-instances-of-same-form'); + $this->getSession()->getPage()->fillField('edit-title-0-value', 'form1'); + $this->getSession()->getPage()->fillField('edit-title-0-value--2', 'form2'); + $this->drupalPostForm(NULL, [], 'Save', [], 'node-page-form--2'); + $this->assertSession()->pageTextContains('Page form2 has been created.'); } /** @@ -196,7 +220,7 @@ class BrowserTestBaseTest extends BrowserTestBase { $this->assertText($sanitized); // Test getRawContent(). - $this->assertSame($this->getSession()->getPage()->getContent(), $this->getRawContent()); + $this->assertSame($this->getSession()->getPage()->getContent(), $this->getSession()->getPage()->getContent()); } /** @@ -552,7 +576,7 @@ class BrowserTestBaseTest extends BrowserTestBase { $this->assertFieldChecked('edit-checkbox-enabled'); $this->assertNoFieldChecked('edit-checkbox-disabled'); - // Test that the assertion fails correctly with non-existant field id. + // Test that the assertion fails correctly with non-existent field id. try { $this->assertNoFieldChecked('incorrect_checkbox_id'); $this->fail('The "incorrect_checkbox_id" field was found'); @@ -639,4 +663,13 @@ class BrowserTestBaseTest extends BrowserTestBase { $this->assertEquals([NULL, ['key1' => ['key2' => ['key3' => 3, 'key3.1' => 3.1]]]], $this->minkDefaultDriverArgs); } + /** + * Ensures we can't access modules we shouldn't be able to after install. + */ + public function testProfileModules() { + $this->setExpectedException(\InvalidArgumentException::class, 'The module demo_umami_content does not exist.'); + $this->assertFileExists('core/profiles/demo_umami/modules/demo_umami_content/demo_umami_content.info.yml'); + \Drupal::service('extension.list.module')->getPathname('demo_umami_content'); + } + }