|
6 | 6 | use Illuminate\Contracts\Filesystem\FileNotFoundException;
|
7 | 7 | use Illuminate\Filesystem\Filesystem;
|
8 | 8 | use Illuminate\Support\Carbon;
|
| 9 | +use Mockery as m; |
9 | 10 | use PHPUnit\Framework\TestCase;
|
10 | 11 |
|
11 | 12 | class CacheFileStoreTest extends TestCase
|
@@ -79,6 +80,27 @@ public function testStoreItemProperlyStoresValues()
|
79 | 80 | $this->assertTrue($result);
|
80 | 81 | }
|
81 | 82 |
|
| 83 | + public function testStoreItemProperlySetsPermissions() |
| 84 | + { |
| 85 | + $files = m::mock(Filesystem::class); |
| 86 | + $files->shouldIgnoreMissing(); |
| 87 | + $store = $this->getMockBuilder(FileStore::class)->setMethods(['expiration'])->setConstructorArgs([$files, __DIR__, 0644])->getMock(); |
| 88 | + $hash = sha1('foo'); |
| 89 | + $cache_dir = substr($hash, 0, 2).'/'.substr($hash, 2, 2); |
| 90 | + $files->shouldReceive('put')->withArgs([__DIR__.'/'.$cache_dir.'/'.$hash, m::any(), m::any()])->andReturnUsing(function ($name, $value) { |
| 91 | + return strlen($value); |
| 92 | + }); |
| 93 | + $files->shouldReceive('chmod')->withArgs([__DIR__.'/'.$cache_dir.'/'.$hash])->andReturnValues(["0600", "0644"])->times(3); |
| 94 | + $files->shouldReceive('chmod')->withArgs([__DIR__.'/'.$cache_dir.'/'.$hash, 0644])->andReturn([true])->once(); |
| 95 | + $result = $store->put('foo', 'foo', 10); |
| 96 | + $this->assertTrue($result); |
| 97 | + $result = $store->put('foo', 'bar', 10); |
| 98 | + $this->assertTrue($result); |
| 99 | + $result = $store->put('foo', 'baz', 10); |
| 100 | + $this->assertTrue($result); |
| 101 | + m::close(); |
| 102 | + } |
| 103 | + |
82 | 104 | public function testForeversAreStoredWithHighTimestamp()
|
83 | 105 | {
|
84 | 106 | $files = $this->mockFilesystem();
|
|
0 commit comments