ConfigProfileOverridesTest.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. namespace Drupal\Tests\config_update_ui\Functional;
  3. use Drupal\Tests\BrowserTestBase;
  4. /**
  5. * Verify config reports, reverts, and diffs with profile overrides.
  6. *
  7. * @group config_update
  8. */
  9. class ConfigProfileOverridesTest extends BrowserTestBase {
  10. /**
  11. * Use the Standard profile, so that there are profile config overrides.
  12. *
  13. * @var string
  14. */
  15. protected $profile = 'standard';
  16. /**
  17. * Modules to enable.
  18. *
  19. * @var array
  20. */
  21. public static $modules = [
  22. 'config',
  23. 'config_update',
  24. 'config_update_ui',
  25. ];
  26. /**
  27. * The admin user that will be created.
  28. *
  29. * @var object
  30. */
  31. protected $adminUser;
  32. /**
  33. * {@inheritdoc}
  34. */
  35. protected function setUp() {
  36. parent::setUp();
  37. // Create user and log in.
  38. $this->adminUser = $this->createUser([
  39. 'access administration pages',
  40. 'administer themes',
  41. 'view config updates report',
  42. 'synchronize configuration',
  43. 'export configuration',
  44. 'import configuration',
  45. 'revert configuration',
  46. 'delete configuration',
  47. ]);
  48. $this->drupalLogin($this->adminUser);
  49. }
  50. /**
  51. * Tests that config overrides work as expected.
  52. */
  53. public function testConfigOverrides() {
  54. // The Standard install profile contains a system.theme.yml file that
  55. // sets up bartik/seven as the default/admin theme. The default config
  56. // from the System module has no admin theme and stark as the default
  57. // theme. So first, run the report on simple configuration and verify
  58. // that system.theme is not shown (it should not be missing, or added,
  59. // or overridden).
  60. $this->drupalGet('admin/config/development/configuration/report/type/system.simple');
  61. $session = $this->assertSession();
  62. $session->responseNotContains('system.theme');
  63. // Go to the Appearance page and change the theme to whatever is currently
  64. // disabled. Return to the report and verify that system.theme is there,
  65. // since it is now overridden.
  66. $this->drupalGet('admin/appearance');
  67. $this->clickLink('Install and set as default');
  68. $this->drupalGet('admin/config/development/configuration/report/type/system.simple');
  69. $session = $this->assertSession();
  70. $session->pageTextContains('system.theme');
  71. // Look at the differences for system.theme and verify it's against
  72. // the standard profile version, not default version. The line for
  73. // default should show bartik as the source; if it's against the system
  74. // version, the word bartik would not be there.
  75. $this->drupalGet('admin/config/development/configuration/report/diff/system.simple/system.theme');
  76. $session = $this->assertSession();
  77. $session->pageTextContains('bartik');
  78. // Revert and verify that it reverted to the profile version, not the
  79. // system module version.
  80. $this->drupalGet('admin/config/development/configuration/report/revert/system.simple/system.theme');
  81. $this->drupalPostForm(NULL, [], 'Revert');
  82. $this->drupalGet('admin/config/development/configuration/single/export/system.simple/system.theme');
  83. $session = $this->assertSession();
  84. $session->pageTextContains('admin: seven');
  85. $session->pageTextContains('default: bartik');
  86. }
  87. }