TESTING: add tests for writing into bootstrap/cache and storage directories

This commit is contained in:
Michal Kváček
2016-01-28 20:51:35 +01:00
parent 703adfcb78
commit da23bb4100
2 changed files with 43 additions and 19 deletions
+43
View File
@@ -0,0 +1,43 @@
<?php
class WritePermissionsTest extends TestCase
{
public function testStorageDir()
{
$this->writeToDir('test.txt');
}
public function testLogsDir()
{
$this->writeToDir('logs/test.txt');
}
public function testFrameworkDir()
{
$this->writeToDir('framework/test.txt');
}
public function testBootstrapCacheDir()
{
$this->writeToDir('../bootstrap/cache/test.txt');
}
/**
* Create and delete some file
*
* @param $path
*/
protected function writeToDir($path)
{
$file = storage_path($path);
$content = uniqid();
$bytesWritten = @file_put_contents($file, $content);
// test writing
$this->assertNotFalse($bytesWritten);
// test deleting
$deleted = @unlink($file);
$this->assertTrue($deleted);
}
}