Mercurial > hg > isophonics-drupal-site
diff core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | c2387f117808 |
children | af1871eacc83 |
line wrap: on
line diff
--- a/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php Tue Jul 10 15:07:59 2018 +0100 +++ b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php Thu Feb 28 13:21:36 2019 +0000 @@ -23,7 +23,7 @@ * * @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. @@ -114,6 +114,7 @@ // Test drupalPostForm(). $edit = ['bananas' => 'red']; + // Submit the form using the button label. $result = $this->drupalPostForm('form-test/object-builder', $edit, 'Save'); $this->assertSame($this->getSession()->getPage()->getContent(), $result); $value = $config_factory->get('form_test.object')->get('bananas'); @@ -123,9 +124,32 @@ $value = $config_factory->get('form_test.object')->get('bananas'); $this->assertSame('', $value); + // Submit the form using the button id. + $edit = ['bananas' => 'blue']; + $result = $this->drupalPostForm('form-test/object-builder', $edit, 'edit-submit'); + $this->assertSame($this->getSession()->getPage()->getContent(), $result); + $value = $config_factory->get('form_test.object')->get('bananas'); + $this->assertSame('blue', $value); + + // Submit the form using the button name. + $edit = ['bananas' => 'purple']; + $result = $this->drupalPostForm('form-test/object-builder', $edit, 'op'); + $this->assertSame($this->getSession()->getPage()->getContent(), $result); + $value = $config_factory->get('form_test.object')->get('bananas'); + $this->assertSame('purple', $value); + // 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.'); } /** @@ -211,7 +235,7 @@ $this->assertText($sanitized); // Test getRawContent(). - $this->assertSame($this->getSession()->getPage()->getContent(), $this->getRawContent()); + $this->assertSame($this->getSession()->getPage()->getContent(), $this->getSession()->getPage()->getContent()); } /** @@ -567,7 +591,7 @@ $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'); @@ -654,4 +678,13 @@ $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'); + } + }