PathNodeFormTest.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace Drupal\Tests\path\Functional;
  3. /**
  4. * Tests the Path Node form UI.
  5. *
  6. * @group path
  7. */
  8. class PathNodeFormTest extends PathTestBase {
  9. /**
  10. * Modules to enable.
  11. *
  12. * @var array
  13. */
  14. public static $modules = ['node', 'path'];
  15. protected function setUp() {
  16. parent::setUp();
  17. // Create test user and log in.
  18. $web_user = $this->drupalCreateUser(['create page content', 'create url aliases']);
  19. $this->drupalLogin($web_user);
  20. }
  21. /**
  22. * Tests the node form ui.
  23. */
  24. public function testNodeForm() {
  25. $assert_session = $this->assertSession();
  26. $this->drupalGet('node/add/page');
  27. // Make sure we have a vertical tab fieldset and 'Path' fields.
  28. $assert_session->elementContains('css', '.form-type-vertical-tabs #edit-path-0 summary', 'URL alias');
  29. $assert_session->fieldExists('path[0][alias]');
  30. // Disable the 'Path' field for this content type.
  31. entity_get_form_display('node', 'page', 'default')
  32. ->removeComponent('path')
  33. ->save();
  34. $this->drupalGet('node/add/page');
  35. // See if the whole fieldset is gone now.
  36. $assert_session->elementNotExists('css', '.form-type-vertical-tabs #edit-path-0');
  37. $assert_session->fieldNotExists('path[0][alias]');
  38. }
  39. }