forked from drush-ops/drush
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MulitsiteContainerTest.php
54 lines (48 loc) · 1.57 KB
/
MulitsiteContainerTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
namespace Unish;
/**
* Tests for core commands.
*
* @group commands
*/
class MulitsiteContainerTest extends CommandUnishTestCase
{
public function setup(): void
{
if (!$this->getSites()) {
$this->setUpDrupal(1, true);
}
}
public function testMultisiteContainer()
{
$conf_dir = $this->webroot() . '/sites/dev';
// Ensure a custom module in a site can't be removed from the container
// due to container rebuilds.
mkdir($conf_dir . '/modules');
mkdir($conf_dir . '/modules/my_module');
$info = <<<EOT
name: My module
type: module
description: 'Example module'
core_version_requirement: '*'
EOT;
$module = <<<EOT
<?php
function my_module_cron() {
\Drupal::messenger()->addMessage("test");
}
EOT;
$options['uri'] = 'dev';
file_put_contents($conf_dir . '/modules/my_module/my_module.info.yml', $info);
file_put_contents($conf_dir . '/modules/my_module/my_module.module', $module);
$this->drush('pm-install', ['my_module'], $options);
$this->drush('cron', [], $options);
$this->assertStringContainsString('Message: test', $this->getErrorOutput());
// Change the deployment identifier.
chmod($conf_dir, 0777);
chmod($conf_dir . '/settings.php', 0777);
file_put_contents($conf_dir . '/settings.php', "\n\$settings['deployment_identifier'] = 'a_random_thing';\n", FILE_APPEND);
$this->drush('cron', [], $options);
$this->assertStringContainsString('Message: test', $this->getErrorOutput());
}
}