MultipleDistributionsProfileTest.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. namespace Drupal\FunctionalTests\Installer;
  3. use Drupal\Component\Serialization\Yaml;
  4. /**
  5. * Tests multiple distribution profile support.
  6. *
  7. * @group Installer
  8. */
  9. class MultipleDistributionsProfileTest extends InstallerTestBase {
  10. /**
  11. * The distribution profile info.
  12. *
  13. * @var array
  14. */
  15. protected $info;
  16. /**
  17. * {@inheritdoc}
  18. */
  19. protected function prepareEnvironment() {
  20. parent::prepareEnvironment();
  21. // Create two distributions.
  22. foreach (['distribution_one', 'distribution_two'] as $name) {
  23. $info = [
  24. 'type' => 'profile',
  25. 'core' => \Drupal::CORE_COMPATIBILITY,
  26. 'name' => $name . ' profile',
  27. 'distribution' => [
  28. 'name' => $name,
  29. 'install' => [
  30. 'theme' => 'bartik',
  31. ],
  32. ],
  33. ];
  34. // File API functions are not available yet.
  35. $path = $this->root . DIRECTORY_SEPARATOR . $this->siteDirectory . '/profiles/' . $name;
  36. mkdir($path, 0777, TRUE);
  37. file_put_contents("$path/$name.info.yml", Yaml::encode($info));
  38. }
  39. // Install the first distribution.
  40. $this->profile = 'distribution_one';
  41. }
  42. /**
  43. * {@inheritdoc}
  44. */
  45. protected function setUpLanguage() {
  46. // Verify that the distribution name appears.
  47. $this->assertRaw('distribution_one');
  48. // Verify that the requested theme is used.
  49. $this->assertRaw('bartik');
  50. // Verify that the "Choose profile" step does not appear.
  51. $this->assertNoText('profile');
  52. parent::setUpLanguage();
  53. }
  54. /**
  55. * {@inheritdoc}
  56. */
  57. protected function setUpProfile() {
  58. // This step is skipped, because there is a distribution profile.
  59. }
  60. /**
  61. * Confirms that the installation succeeded.
  62. */
  63. public function testInstalled() {
  64. $this->assertUrl('user/1');
  65. $this->assertResponse(200);
  66. // Confirm that we are logged-in after installation.
  67. $this->assertText($this->rootUser->getUsername());
  68. // Confirm that Drupal recognizes this distribution as the current profile.
  69. $this->assertEqual(\Drupal::installProfile(), 'distribution_one');
  70. $this->assertEqual($this->config('core.extension')->get('profile'), 'distribution_one', 'The install profile has been written to core.extension configuration.');
  71. $this->rebuildContainer();
  72. $this->pass('Container can be rebuilt as distribution is written to configuration.');
  73. $this->assertEqual(\Drupal::installProfile(), 'distribution_one');
  74. }
  75. }