comparison vendor/psy/psysh/test/ConfigurationTest.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 5fb285c0d0e3
children
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
28 28
29 public function testDefaults() 29 public function testDefaults()
30 { 30 {
31 $config = $this->getConfig(); 31 $config = $this->getConfig();
32 32
33 $this->assertSame(function_exists('readline'), $config->hasReadline()); 33 $this->assertSame(\function_exists('readline'), $config->hasReadline());
34 $this->assertSame(function_exists('readline'), $config->useReadline()); 34 $this->assertSame(\function_exists('readline'), $config->useReadline());
35 $this->assertSame(function_exists('pcntl_signal'), $config->hasPcntl()); 35 $this->assertSame(\function_exists('pcntl_signal'), $config->hasPcntl());
36 $this->assertSame(function_exists('pcntl_signal'), $config->usePcntl()); 36 $this->assertSame(\function_exists('pcntl_signal'), $config->usePcntl());
37 $this->assertFalse($config->requireSemicolons()); 37 $this->assertFalse($config->requireSemicolons());
38 $this->assertSame(Configuration::COLOR_MODE_AUTO, $config->colorMode()); 38 $this->assertSame(Configuration::COLOR_MODE_AUTO, $config->colorMode());
39 $this->assertNull($config->getStartupMessage()); 39 $this->assertNull($config->getStartupMessage());
40 } 40 }
41 41
55 /** 55 /**
56 * @dataProvider directories 56 * @dataProvider directories
57 */ 57 */
58 public function testFilesAndDirectories($home, $configFile, $historyFile, $manualDbFile) 58 public function testFilesAndDirectories($home, $configFile, $historyFile, $manualDbFile)
59 { 59 {
60 $oldHome = getenv('HOME'); 60 $oldHome = \getenv('HOME');
61 putenv("HOME=$home"); 61 \putenv("HOME=$home");
62 62
63 $config = new Configuration(); 63 $config = new Configuration();
64 $this->assertSame(realpath($configFile), realpath($config->getConfigFile())); 64 $this->assertSame(\realpath($configFile), \realpath($config->getConfigFile()));
65 $this->assertSame(realpath($historyFile), realpath($config->getHistoryFile())); 65 $this->assertSame(\realpath($historyFile), \realpath($config->getHistoryFile()));
66 $this->assertSame(realpath($manualDbFile), realpath($config->getManualDbFile())); 66 $this->assertSame(\realpath($manualDbFile), \realpath($config->getManualDbFile()));
67 67
68 putenv("HOME=$oldHome"); 68 \putenv("HOME=$oldHome");
69 } 69 }
70 70
71 public function directories() 71 public function directories()
72 { 72 {
73 $base = realpath(__DIR__ . '/fixtures'); 73 $base = \realpath(__DIR__ . '/fixtures');
74 74
75 return [ 75 return [
76 [ 76 [
77 $base . '/default', 77 $base . '/default',
78 $base . '/default/.config/psysh/config.php', 78 $base . '/default/.config/psysh/config.php',
123 123
124 public function testLoadConfigFile() 124 public function testLoadConfigFile()
125 { 125 {
126 $config = $this->getConfig(__DIR__ . '/fixtures/config.php'); 126 $config = $this->getConfig(__DIR__ . '/fixtures/config.php');
127 127
128 $runtimeDir = $this->joinPath(realpath(sys_get_temp_dir()), 'psysh_test', 'withconfig', 'temp'); 128 $runtimeDir = $this->joinPath(\realpath(\sys_get_temp_dir()), 'psysh_test', 'withconfig', 'temp');
129 129
130 $this->assertStringStartsWith($runtimeDir, realpath($config->getTempFile('foo', 123))); 130 $this->assertStringStartsWith($runtimeDir, \realpath($config->getTempFile('foo', 123)));
131 $this->assertStringStartsWith($runtimeDir, realpath(dirname($config->getPipe('pipe', 123)))); 131 $this->assertStringStartsWith($runtimeDir, \realpath(\dirname($config->getPipe('pipe', 123))));
132 $this->assertStringStartsWith($runtimeDir, realpath($config->getRuntimeDir())); 132 $this->assertStringStartsWith($runtimeDir, \realpath($config->getRuntimeDir()));
133 133
134 $this->assertSame(function_exists('readline'), $config->useReadline()); 134 $this->assertSame(\function_exists('readline'), $config->useReadline());
135 $this->assertFalse($config->usePcntl()); 135 $this->assertFalse($config->usePcntl());
136 $this->assertSame(E_ALL & ~E_NOTICE, $config->errorLoggingLevel()); 136 $this->assertSame(E_ALL & ~E_NOTICE, $config->errorLoggingLevel());
137 } 137 }
138 138
139 public function testLoadLocalConfigFile() 139 public function testLoadLocalConfigFile()
140 { 140 {
141 $oldPwd = getcwd(); 141 $oldPwd = \getcwd();
142 chdir(realpath(__DIR__ . '/fixtures/project/')); 142 \chdir(\realpath(__DIR__ . '/fixtures/project/'));
143 143
144 $config = new Configuration(); 144 $config = new Configuration();
145 145
146 // When no configuration file is specified local project config is merged 146 // When no configuration file is specified local project config is merged
147 $this->assertTrue($config->requireSemicolons()); 147 $this->assertTrue($config->requireSemicolons());
151 151
152 // Defining a configuration file skips loading local project config 152 // Defining a configuration file skips loading local project config
153 $this->assertFalse($config->requireSemicolons()); 153 $this->assertFalse($config->requireSemicolons());
154 $this->assertTrue($config->useUnicode()); 154 $this->assertTrue($config->useUnicode());
155 155
156 chdir($oldPwd); 156 \chdir($oldPwd);
157 } 157 }
158 158
159 /** 159 /**
160 * @expectedException \Psy\Exception\DeprecatedException 160 * @expectedException \Psy\Exception\DeprecatedException
161 */ 161 */
164 $config = new Configuration(['baseDir' => 'fake']); 164 $config = new Configuration(['baseDir' => 'fake']);
165 } 165 }
166 166
167 private function joinPath() 167 private function joinPath()
168 { 168 {
169 return implode(DIRECTORY_SEPARATOR, func_get_args()); 169 return \implode(DIRECTORY_SEPARATOR, \func_get_args());
170 } 170 }
171 171
172 public function testConfigIncludes() 172 public function testConfigIncludes()
173 { 173 {
174 $config = new Configuration([ 174 $config = new Configuration([