SingleVisibleProfileTest.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace Drupal\FunctionalTests\Installer;
  3. use Drupal\Core\Serialization\Yaml;
  4. /**
  5. * Tests distribution profile support.
  6. *
  7. * @group Installer
  8. */
  9. class SingleVisibleProfileTest extends InstallerTestBase {
  10. /**
  11. * The installation profile to install.
  12. *
  13. * Not needed when only one is visible.
  14. *
  15. * @var string
  16. */
  17. protected $profile = NULL;
  18. /**
  19. * {@inheritdoc}
  20. */
  21. protected $defaultTheme = 'stark';
  22. /**
  23. * {@inheritdoc}
  24. */
  25. protected function prepareEnvironment() {
  26. parent::prepareEnvironment();
  27. $profiles = ['standard', 'demo_umami'];
  28. foreach ($profiles as $profile) {
  29. $info = [
  30. 'type' => 'profile',
  31. 'core' => \Drupal::CORE_COMPATIBILITY,
  32. 'name' => 'Override ' . $profile,
  33. 'hidden' => TRUE,
  34. ];
  35. // File API functions are not available yet.
  36. $path = $this->siteDirectory . '/profiles/' . $profile;
  37. mkdir($path, 0777, TRUE);
  38. file_put_contents("$path/$profile.info.yml", Yaml::encode($info));
  39. }
  40. }
  41. /**
  42. * {@inheritdoc}
  43. */
  44. protected function setUpProfile() {
  45. // This step is skipped, because there is only one visible profile.
  46. }
  47. /**
  48. * Confirms that the installation succeeded.
  49. */
  50. public function testInstalled() {
  51. $this->assertUrl('user/1');
  52. $this->assertSession()->statusCodeEquals(200);
  53. // Confirm that we are logged-in after installation.
  54. $this->assertText($this->rootUser->getAccountName());
  55. // Confirm that the minimal profile was installed.
  56. $this->assertEqual(\Drupal::installProfile(), 'minimal');
  57. }
  58. }