forked from drush-ops/drush
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CoreTest.php
86 lines (73 loc) · 3.25 KB
/
CoreTest.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
namespace Unish;
use Symfony\Component\Yaml\Yaml;
use Webmozart\PathUtil\Path;
/**
* Tests for core commands.
*
* @group commands
*/
class CoreTest extends UnishIntegrationTestCase
{
public function testCoreRequirements()
{
$root = $this->webroot();
$options = [
'ignore' => 'cron,http requests,update,update_core,trusted_host_patterns', // no network access when running in tests, so ignore these
];
// Verify that there are no severity 2 items in the status report
$this->drush('core-requirements', [], $options + ['severity' => '2', 'pipe' => true]);
$output = $this->getOutput();
$this->assertEquals('', $output);
// Verify the severity of some checks
$this->drush('core-requirements', [], $options + ['format' => 'json', 'fields' => 'sid']);
$loaded = $this->getOutputFromJSON();
$expected = [
'php' => ['sid' => '-1'],
'php_memory_limit' => ['sid' => '-1'],
];
foreach ($expected as $key => $value) {
$this->assertArrayHasKey($key, $loaded);
$this->assertEquals($value, $loaded[$key], "The $key requirement should have an expected value");
}
}
public function testDrupalDirectory()
{
$root = $this->webroot();
$sitewide = $this->drupalSitewideDirectory();
if ($this->isWindows()) {
$this->markTestSkipped('Windows escpaping woes.');
}
$this->drush('drupal-directory', ['%files']);
$output = $this->getOutput();
$this->assertEquals(Path::join($root, '/sites/default/files'), $output);
$this->drush('drupal-directory', ['%modules']);
$output = $this->getOutput();
$this->assertEquals(Path::join($root, $sitewide . '/modules'), $output);
$this->drush('pm-install', ['drush_empty_module']);
$this->drush('theme-enable', ['drush_empty_theme']);
$this->drush('drupal-directory', ['drush_empty_module']);
$output = $this->getOutput();
$this->assertEquals(Path::join($root, '/modules/unish/drush_empty_module'), $output);
$this->drush('drupal-directory', ['drush_empty_theme']);
$output = $this->getOutput();
$this->assertEquals(Path::join($root, '/themes/unish/drush_empty_theme'), $output);
}
public function testRoute()
{
$this->drush('route', [], ['format' => 'json']);
$json = $this->getOutputFromJSON();
$this->assertArrayHasKey('user.login', $json);
$this->assertSame('/user/login', $json['user.login']);
$this->drush('route', [], ['path' => '/user/login', 'format' => 'json']);
$json = $this->getOutputFromJSON();
$this->assertSame('/user/login', $json['path']);
$this->assertSame('user.login', $json['name']);
$this->assertSame('\Drupal\user\Form\UserLoginForm', $json['defaults']['_form']);
$this->assertSame("FALSE", $json['requirements']['_user_is_logged_in']);
$this->assertSame('access_check.user.login_status', $json['options']['_access_checks'][0]);
$this->drush('route', [], ['name' => 'user.login', 'format' => 'json']);
$json = $this->getOutputFromJSON();
$this->assertSame('/user/login', $json['path']);
}
}