diff options
Diffstat (limited to 'plugins/CoreAdminHome/tests/Integration/SetConfigTest.php')
-rw-r--r-- | plugins/CoreAdminHome/tests/Integration/SetConfigTest.php | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/plugins/CoreAdminHome/tests/Integration/SetConfigTest.php b/plugins/CoreAdminHome/tests/Integration/SetConfigTest.php index bd1ed5e618..93cf57e7c5 100644 --- a/plugins/CoreAdminHome/tests/Integration/SetConfigTest.php +++ b/plugins/CoreAdminHome/tests/Integration/SetConfigTest.php @@ -36,6 +36,12 @@ class SetConfigTest extends ConsoleCommandTestCase parent::setUp(); } + public function tearDown() + { + parent::tearDown(); + $this->makeLocalConfigWritable(); + } + public function test_Command_SucceedsWhenOptionsUsed() { $code = $this->applicationTester->run(array( @@ -80,6 +86,22 @@ class SetConfigTest extends ConsoleCommandTestCase ); } + public function test_Command_FailsWithMissingFilePermissionException_whenConfigFileNotWritable() + { + $this->makeLocalConfigNotWritable(); + + $code = $this->applicationTester->run(array( + 'command' => 'config:set', + 'assignment' => array( + 'MySection.other_array_value=[]', + ), + '-vvv' => false, + )); + + $this->assertNotEquals(0, $code, $this->getCommandDisplayOutputErrorMessage()); + $this->assertContains('[Piwik\Exception\MissingFilePermissionException]', $this->applicationTester->getDisplay()); + } + public function test_Command_SucceedsWhenArgumentsUsed() { $config = Config::getInstance(); @@ -191,4 +213,23 @@ class SetConfigTest extends ConsoleCommandTestCase unlink($configPath); } } + + protected function makeLocalConfigNotWritable() + { + $local = Config::getInstance()->getLocalPath(); + touch($local); + chmod($local, 0444); + $this->assertFalse(is_writable($local)); + } + + protected function makeLocalConfigWritable() + { + $local = Config::getInstance()->getLocalPath(); + @chmod(dirname($local), 0755); + @chmod($local, 0755); + $this->assertTrue(is_writable(dirname($local))); + if(file_exists($local)) { + $this->assertTrue(is_writable($local)); + } + } } |