Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
mattab committed Sep 27, 2016
1 parent 9b078ce commit fac3d63
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
6 changes: 4 additions & 2 deletions plugins/CustomPiwikJs/File.php
Expand Up @@ -38,7 +38,9 @@ public function checkWritable()

public function save($content)
{
file_put_contents($this->file, $content);
if(false === file_put_contents($this->file, $content)) {
throw new AccessDeniedException(sprintf("Could not write to %s", $this->file));
}
}

public function getContent()
Expand All @@ -60,7 +62,7 @@ public function getName()
*/
public function hasWriteAccess()
{
if(file_exists($this->file) && !is_writable($this->file)) {
if (file_exists($this->file) && !is_writable($this->file)) {
return false;
}
return is_writable(dirname($this->file)) || is_writable($this->file);
Expand Down
11 changes: 9 additions & 2 deletions plugins/CustomPiwikJs/tests/Integration/FileTest.php
Expand Up @@ -63,8 +63,15 @@ private function makeNotWritableFile()
$file = new File($path);
$file->save('will be saved OK, and then we make it non writable.');

chmod($path, 0444);
chmod($this->dir, 0444);
if (!chmod($path, 0444)) {
throw new \Exception("chmod on the file didn't work");
}
if (!chmod(dirname($path), 0755)) {
throw new \Exception("chmod on the directory didn't work");
}
$this->assertTrue(is_writable(dirname($path)));
$this->assertFalse(is_writable($path));
$this->assertTrue(file_exists($path));
return $file;
}

Expand Down

0 comments on commit fac3d63

Please sign in to comment.