2014-08-04 08:46:48 -04:00
|
|
|
<?php
|
2025-06-30 09:04:05 -04:00
|
|
|
|
2014-08-04 08:46:48 -04:00
|
|
|
/**
|
2024-05-10 09:09:14 -04:00
|
|
|
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2014-08-04 08:46:48 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
namespace Test\Files\Cache;
|
|
|
|
|
|
2025-06-30 10:56:59 -04:00
|
|
|
use OC\Files\Cache\Cache;
|
|
|
|
|
use OC\Files\Cache\Scanner;
|
2019-11-22 14:52:10 -05:00
|
|
|
use OC\Files\Filesystem as Filesystem;
|
2025-06-30 10:56:59 -04:00
|
|
|
use OC\Files\Storage\Storage;
|
2025-06-12 12:31:58 -04:00
|
|
|
use OC\Files\Storage\Temporary;
|
2015-11-10 10:31:30 -05:00
|
|
|
use OC\Files\View;
|
2022-02-23 12:29:08 -05:00
|
|
|
use OCP\Files\Mount\IMountManager;
|
2025-06-12 12:31:58 -04:00
|
|
|
use OCP\IUserManager;
|
|
|
|
|
use OCP\Server;
|
2014-08-04 08:46:48 -04:00
|
|
|
|
2015-11-02 19:52:41 -05:00
|
|
|
/**
|
2016-05-20 09:38:20 -04:00
|
|
|
* Class UpdaterLegacyTest
|
2015-11-02 19:52:41 -05:00
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @package Test\Files\Cache
|
|
|
|
|
*/
|
2025-10-20 19:52:40 -04:00
|
|
|
#[\PHPUnit\Framework\Attributes\Group('DB')]
|
2016-05-20 09:38:20 -04:00
|
|
|
class UpdaterLegacyTest extends \Test\TestCase {
|
2014-08-04 08:46:48 -04:00
|
|
|
/**
|
2025-06-30 10:56:59 -04:00
|
|
|
* @var Storage $storage
|
2014-08-04 08:46:48 -04:00
|
|
|
*/
|
|
|
|
|
private $storage;
|
|
|
|
|
|
|
|
|
|
/**
|
2025-06-30 10:56:59 -04:00
|
|
|
* @var Scanner $scanner
|
2014-08-04 08:46:48 -04:00
|
|
|
*/
|
|
|
|
|
private $scanner;
|
|
|
|
|
|
|
|
|
|
/**
|
2025-06-30 10:56:59 -04:00
|
|
|
* @var Cache $cache
|
2014-08-04 08:46:48 -04:00
|
|
|
*/
|
|
|
|
|
private $cache;
|
|
|
|
|
|
|
|
|
|
private static $user;
|
|
|
|
|
|
2019-11-21 10:40:38 -05:00
|
|
|
protected function setUp(): void {
|
2014-11-07 09:23:15 -05:00
|
|
|
parent::setUp();
|
2014-08-04 08:46:48 -04:00
|
|
|
|
2025-06-12 12:31:58 -04:00
|
|
|
$this->storage = new Temporary([]);
|
2014-08-04 08:46:48 -04:00
|
|
|
$textData = "dummy file data\n";
|
2018-08-28 09:58:27 -04:00
|
|
|
$imgData = file_get_contents(\OC::$SERVERROOT . '/core/img/logo/logo.png');
|
2014-08-04 08:46:48 -04:00
|
|
|
$this->storage->mkdir('folder');
|
|
|
|
|
$this->storage->file_put_contents('foo.txt', $textData);
|
|
|
|
|
$this->storage->file_put_contents('foo.png', $imgData);
|
|
|
|
|
$this->storage->file_put_contents('folder/bar.txt', $textData);
|
|
|
|
|
$this->storage->file_put_contents('folder/bar2.txt', $textData);
|
|
|
|
|
|
|
|
|
|
$this->scanner = $this->storage->getScanner();
|
|
|
|
|
$this->scanner->scan('');
|
|
|
|
|
$this->cache = $this->storage->getCache();
|
|
|
|
|
|
|
|
|
|
if (!self::$user) {
|
2014-12-02 07:51:36 -05:00
|
|
|
self::$user = $this->getUniqueID();
|
2014-08-04 08:46:48 -04:00
|
|
|
}
|
|
|
|
|
|
2025-06-12 12:31:58 -04:00
|
|
|
Server::get(IUserManager::class)->createUser(self::$user, 'NotAnEasyPassword123456+');
|
2015-04-08 06:03:55 -04:00
|
|
|
$this->loginAsUser(self::$user);
|
2014-08-04 08:46:48 -04:00
|
|
|
|
2014-11-12 09:54:41 -05:00
|
|
|
Filesystem::init(self::$user, '/' . self::$user . '/files');
|
2014-08-04 08:46:48 -04:00
|
|
|
|
2022-02-23 12:29:08 -05:00
|
|
|
/** @var IMountManager $manager */
|
2025-06-12 12:31:58 -04:00
|
|
|
$manager = Server::get(IMountManager::class);
|
2022-02-23 12:29:08 -05:00
|
|
|
$manager->removeMount('/' . self::$user);
|
|
|
|
|
|
2020-03-26 04:30:18 -04:00
|
|
|
Filesystem::mount($this->storage, [], '/' . self::$user . '/files');
|
2014-08-04 08:46:48 -04:00
|
|
|
|
|
|
|
|
\OC_Hook::clear('OC_Filesystem');
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-21 10:40:38 -05:00
|
|
|
protected function tearDown(): void {
|
2014-08-04 08:46:48 -04:00
|
|
|
if ($this->cache) {
|
|
|
|
|
$this->cache->clear();
|
|
|
|
|
}
|
2015-12-17 09:59:23 -05:00
|
|
|
|
|
|
|
|
$result = false;
|
2025-06-12 12:31:58 -04:00
|
|
|
$user = Server::get(IUserManager::class)->get(self::$user);
|
2020-04-10 08:19:56 -04:00
|
|
|
if ($user !== null) {
|
|
|
|
|
$result = $user->delete();
|
|
|
|
|
}
|
2014-08-04 08:46:48 -04:00
|
|
|
$this->assertTrue($result);
|
2014-11-07 09:23:15 -05:00
|
|
|
|
2015-04-08 06:03:55 -04:00
|
|
|
$this->logout();
|
2014-11-07 09:23:15 -05:00
|
|
|
parent::tearDown();
|
2014-08-04 08:46:48 -04:00
|
|
|
}
|
|
|
|
|
|
2024-09-15 16:32:31 -04:00
|
|
|
public function testWrite(): void {
|
2014-08-04 08:46:48 -04:00
|
|
|
$textSize = strlen("dummy file data\n");
|
2018-08-28 09:58:27 -04:00
|
|
|
$imageSize = filesize(\OC::$SERVERROOT . '/core/img/logo/logo.png');
|
2020-03-26 04:30:18 -04:00
|
|
|
$this->cache->put('foo.txt', ['mtime' => 100, 'storage_mtime' => 150]);
|
2014-08-04 08:46:48 -04:00
|
|
|
$rootCachedData = $this->cache->get('');
|
|
|
|
|
$this->assertEquals(3 * $textSize + $imageSize, $rootCachedData['size']);
|
|
|
|
|
|
|
|
|
|
$fooCachedData = $this->cache->get('foo.txt');
|
|
|
|
|
Filesystem::file_put_contents('foo.txt', 'asd');
|
|
|
|
|
$cachedData = $this->cache->get('foo.txt');
|
|
|
|
|
$this->assertEquals(3, $cachedData['size']);
|
2019-11-27 09:27:18 -05:00
|
|
|
$this->assertIsString($fooCachedData['etag']);
|
|
|
|
|
$this->assertIsString($cachedData['etag']);
|
2014-08-04 08:46:48 -04:00
|
|
|
$this->assertNotSame($fooCachedData['etag'], $cachedData['etag']);
|
|
|
|
|
$cachedData = $this->cache->get('');
|
|
|
|
|
$this->assertEquals(2 * $textSize + $imageSize + 3, $cachedData['size']);
|
2019-11-27 09:27:18 -05:00
|
|
|
$this->assertIsString($rootCachedData['etag']);
|
|
|
|
|
$this->assertIsString($cachedData['etag']);
|
2014-08-04 08:46:48 -04:00
|
|
|
$this->assertNotSame($rootCachedData['etag'], $cachedData['etag']);
|
|
|
|
|
$rootCachedData = $cachedData;
|
|
|
|
|
|
|
|
|
|
$this->assertFalse($this->cache->inCache('bar.txt'));
|
|
|
|
|
Filesystem::file_put_contents('bar.txt', 'asd');
|
|
|
|
|
$this->assertTrue($this->cache->inCache('bar.txt'));
|
|
|
|
|
$cachedData = $this->cache->get('bar.txt');
|
|
|
|
|
$this->assertEquals(3, $cachedData['size']);
|
|
|
|
|
$mtime = $cachedData['mtime'];
|
|
|
|
|
$cachedData = $this->cache->get('');
|
|
|
|
|
$this->assertEquals(2 * $textSize + $imageSize + 2 * 3, $cachedData['size']);
|
2019-11-27 09:27:18 -05:00
|
|
|
$this->assertIsString($rootCachedData['etag']);
|
|
|
|
|
$this->assertIsString($cachedData['etag']);
|
2014-08-04 08:46:48 -04:00
|
|
|
$this->assertNotSame($rootCachedData['etag'], $cachedData['etag']);
|
|
|
|
|
$this->assertGreaterThanOrEqual($rootCachedData['mtime'], $mtime);
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-15 16:32:31 -04:00
|
|
|
public function testWriteWithMountPoints(): void {
|
2025-06-12 12:31:58 -04:00
|
|
|
$storage2 = new Temporary([]);
|
2014-08-04 08:46:48 -04:00
|
|
|
$storage2->getScanner()->scan(''); //initialize etags
|
|
|
|
|
$cache2 = $storage2->getCache();
|
2020-03-26 04:30:18 -04:00
|
|
|
Filesystem::mount($storage2, [], '/' . self::$user . '/files/folder/substorage');
|
2015-11-10 10:31:30 -05:00
|
|
|
$view = new View('/' . self::$user . '/files');
|
|
|
|
|
$folderCachedData = $view->getFileInfo('folder');
|
2014-08-04 08:46:48 -04:00
|
|
|
$substorageCachedData = $cache2->get('');
|
|
|
|
|
Filesystem::file_put_contents('folder/substorage/foo.txt', 'asd');
|
|
|
|
|
$this->assertTrue($cache2->inCache('foo.txt'));
|
|
|
|
|
$cachedData = $cache2->get('foo.txt');
|
2016-11-09 10:14:54 -05:00
|
|
|
$oldEtag = $substorageCachedData['etag'];
|
2014-08-04 08:46:48 -04:00
|
|
|
$this->assertEquals(3, $cachedData['size']);
|
|
|
|
|
$mtime = $cachedData['mtime'];
|
|
|
|
|
|
|
|
|
|
$cachedData = $cache2->get('');
|
2019-11-27 09:27:18 -05:00
|
|
|
$this->assertIsString($substorageCachedData['etag']);
|
|
|
|
|
$this->assertIsString($cachedData['etag']);
|
2016-11-09 10:14:54 -05:00
|
|
|
$this->assertNotSame($oldEtag, $cachedData['etag']);
|
2014-08-04 08:46:48 -04:00
|
|
|
|
2015-11-10 10:31:30 -05:00
|
|
|
$cachedData = $view->getFileInfo('folder');
|
2019-11-27 09:27:18 -05:00
|
|
|
$this->assertIsString($folderCachedData['etag']);
|
|
|
|
|
$this->assertIsString($cachedData['etag']);
|
2016-11-09 10:14:54 -05:00
|
|
|
$this->assertNotSame($oldEtag, $cachedData['etag']);
|
2014-08-04 08:46:48 -04:00
|
|
|
}
|
|
|
|
|
|
2024-09-15 16:32:31 -04:00
|
|
|
public function testDelete(): void {
|
2014-08-04 08:46:48 -04:00
|
|
|
$textSize = strlen("dummy file data\n");
|
2018-08-28 09:58:27 -04:00
|
|
|
$imageSize = filesize(\OC::$SERVERROOT . '/core/img/logo/logo.png');
|
2014-08-04 08:46:48 -04:00
|
|
|
$rootCachedData = $this->cache->get('');
|
2016-11-09 10:14:54 -05:00
|
|
|
$oldEtag = $rootCachedData['etag'];
|
2014-08-04 08:46:48 -04:00
|
|
|
$this->assertEquals(3 * $textSize + $imageSize, $rootCachedData['size']);
|
|
|
|
|
|
|
|
|
|
$this->assertTrue($this->cache->inCache('foo.txt'));
|
|
|
|
|
Filesystem::unlink('foo.txt');
|
|
|
|
|
$this->assertFalse($this->cache->inCache('foo.txt'));
|
|
|
|
|
$cachedData = $this->cache->get('');
|
|
|
|
|
$this->assertEquals(2 * $textSize + $imageSize, $cachedData['size']);
|
2019-11-27 09:27:18 -05:00
|
|
|
$this->assertIsString($rootCachedData['etag']);
|
|
|
|
|
$this->assertIsString($cachedData['etag']);
|
2016-11-09 10:14:54 -05:00
|
|
|
$this->assertNotSame($oldEtag, $cachedData['etag']);
|
2014-08-04 08:46:48 -04:00
|
|
|
$this->assertGreaterThanOrEqual($rootCachedData['mtime'], $cachedData['mtime']);
|
|
|
|
|
$rootCachedData = $cachedData;
|
|
|
|
|
|
|
|
|
|
Filesystem::mkdir('bar_folder');
|
|
|
|
|
$this->assertTrue($this->cache->inCache('bar_folder'));
|
|
|
|
|
$cachedData = $this->cache->get('');
|
2019-11-27 09:27:18 -05:00
|
|
|
$this->assertIsString($rootCachedData['etag']);
|
|
|
|
|
$this->assertIsString($cachedData['etag']);
|
2016-11-09 10:14:54 -05:00
|
|
|
$this->assertNotSame($oldEtag, $cachedData['etag']);
|
2014-08-04 08:46:48 -04:00
|
|
|
$rootCachedData = $cachedData;
|
2016-11-09 10:14:54 -05:00
|
|
|
$oldEtag = $rootCachedData['etag'];
|
2014-08-04 08:46:48 -04:00
|
|
|
Filesystem::rmdir('bar_folder');
|
|
|
|
|
$this->assertFalse($this->cache->inCache('bar_folder'));
|
|
|
|
|
$cachedData = $this->cache->get('');
|
2019-11-27 09:27:18 -05:00
|
|
|
$this->assertIsString($rootCachedData['etag']);
|
|
|
|
|
$this->assertIsString($cachedData['etag']);
|
2016-11-09 10:14:54 -05:00
|
|
|
$this->assertNotSame($oldEtag, $cachedData['etag']);
|
2014-08-04 08:46:48 -04:00
|
|
|
$this->assertGreaterThanOrEqual($rootCachedData['mtime'], $cachedData['mtime']);
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-15 16:32:31 -04:00
|
|
|
public function testDeleteWithMountPoints(): void {
|
2025-06-12 12:31:58 -04:00
|
|
|
$storage2 = new Temporary([]);
|
2014-08-04 08:46:48 -04:00
|
|
|
$cache2 = $storage2->getCache();
|
2020-03-26 04:30:18 -04:00
|
|
|
Filesystem::mount($storage2, [], '/' . self::$user . '/files/folder/substorage');
|
2014-08-04 08:46:48 -04:00
|
|
|
Filesystem::file_put_contents('folder/substorage/foo.txt', 'asd');
|
2015-11-10 10:31:30 -05:00
|
|
|
$view = new View('/' . self::$user . '/files');
|
2014-08-04 08:46:48 -04:00
|
|
|
$this->assertTrue($cache2->inCache('foo.txt'));
|
2015-11-10 10:31:30 -05:00
|
|
|
$folderCachedData = $view->getFileInfo('folder');
|
2014-08-04 08:46:48 -04:00
|
|
|
$substorageCachedData = $cache2->get('');
|
2016-11-09 10:14:54 -05:00
|
|
|
$oldEtag = $folderCachedData['etag'];
|
2014-08-04 08:46:48 -04:00
|
|
|
Filesystem::unlink('folder/substorage/foo.txt');
|
|
|
|
|
$this->assertFalse($cache2->inCache('foo.txt'));
|
|
|
|
|
|
|
|
|
|
$cachedData = $cache2->get('');
|
2019-11-27 09:27:18 -05:00
|
|
|
$this->assertIsString($substorageCachedData['etag']);
|
|
|
|
|
$this->assertIsString($cachedData['etag']);
|
2016-11-09 10:14:54 -05:00
|
|
|
$this->assertNotSame($substorageCachedData, $cachedData['etag']);
|
2014-08-04 08:46:48 -04:00
|
|
|
$this->assertGreaterThanOrEqual($substorageCachedData['mtime'], $cachedData['mtime']);
|
|
|
|
|
|
2015-11-10 10:31:30 -05:00
|
|
|
$cachedData = $view->getFileInfo('folder');
|
2019-11-27 09:27:18 -05:00
|
|
|
$this->assertIsString($folderCachedData['etag']);
|
|
|
|
|
$this->assertIsString($cachedData['etag']);
|
2016-11-09 10:14:54 -05:00
|
|
|
$this->assertNotSame($oldEtag, $cachedData['etag']);
|
2014-08-04 08:46:48 -04:00
|
|
|
$this->assertGreaterThanOrEqual($folderCachedData['mtime'], $cachedData['mtime']);
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-15 16:32:31 -04:00
|
|
|
public function testRename(): void {
|
2014-08-04 08:46:48 -04:00
|
|
|
$textSize = strlen("dummy file data\n");
|
2018-08-28 09:58:27 -04:00
|
|
|
$imageSize = filesize(\OC::$SERVERROOT . '/core/img/logo/logo.png');
|
2014-08-04 08:46:48 -04:00
|
|
|
$rootCachedData = $this->cache->get('');
|
|
|
|
|
$this->assertEquals(3 * $textSize + $imageSize, $rootCachedData['size']);
|
|
|
|
|
|
|
|
|
|
$this->assertTrue($this->cache->inCache('foo.txt'));
|
|
|
|
|
$fooCachedData = $this->cache->get('foo.txt');
|
|
|
|
|
$this->assertFalse($this->cache->inCache('bar.txt'));
|
|
|
|
|
Filesystem::rename('foo.txt', 'bar.txt');
|
|
|
|
|
$this->assertFalse($this->cache->inCache('foo.txt'));
|
|
|
|
|
$this->assertTrue($this->cache->inCache('bar.txt'));
|
|
|
|
|
$cachedData = $this->cache->get('bar.txt');
|
|
|
|
|
$this->assertEquals($fooCachedData['fileid'], $cachedData['fileid']);
|
|
|
|
|
$mtime = $cachedData['mtime'];
|
|
|
|
|
$cachedData = $this->cache->get('');
|
|
|
|
|
$this->assertEquals(3 * $textSize + $imageSize, $cachedData['size']);
|
2019-11-27 09:27:18 -05:00
|
|
|
$this->assertIsString($rootCachedData['etag']);
|
|
|
|
|
$this->assertIsString($cachedData['etag']);
|
2014-08-04 08:46:48 -04:00
|
|
|
$this->assertNotSame($rootCachedData['etag'], $cachedData['etag']);
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-15 16:32:31 -04:00
|
|
|
public function testRenameExtension(): void {
|
2014-08-04 08:46:48 -04:00
|
|
|
$fooCachedData = $this->cache->get('foo.txt');
|
|
|
|
|
$this->assertEquals('text/plain', $fooCachedData['mimetype']);
|
|
|
|
|
Filesystem::rename('foo.txt', 'foo.abcd');
|
|
|
|
|
$fooCachedData = $this->cache->get('foo.abcd');
|
|
|
|
|
$this->assertEquals('application/octet-stream', $fooCachedData['mimetype']);
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-15 16:32:31 -04:00
|
|
|
public function testRenameWithMountPoints(): void {
|
2025-06-12 12:31:58 -04:00
|
|
|
$storage2 = new Temporary([]);
|
2014-08-04 08:46:48 -04:00
|
|
|
$cache2 = $storage2->getCache();
|
2020-03-26 04:30:18 -04:00
|
|
|
Filesystem::mount($storage2, [], '/' . self::$user . '/files/folder/substorage');
|
2014-08-04 08:46:48 -04:00
|
|
|
Filesystem::file_put_contents('folder/substorage/foo.txt', 'asd');
|
2015-11-10 10:31:30 -05:00
|
|
|
$view = new View('/' . self::$user . '/files');
|
2014-08-04 08:46:48 -04:00
|
|
|
$this->assertTrue($cache2->inCache('foo.txt'));
|
2015-11-10 10:31:30 -05:00
|
|
|
$folderCachedData = $view->getFileInfo('folder');
|
2016-11-09 10:14:54 -05:00
|
|
|
$oldEtag = $folderCachedData['etag'];
|
2014-08-04 08:46:48 -04:00
|
|
|
$substorageCachedData = $cache2->get('');
|
|
|
|
|
$fooCachedData = $cache2->get('foo.txt');
|
|
|
|
|
Filesystem::rename('folder/substorage/foo.txt', 'folder/substorage/bar.txt');
|
|
|
|
|
$this->assertFalse($cache2->inCache('foo.txt'));
|
|
|
|
|
$this->assertTrue($cache2->inCache('bar.txt'));
|
|
|
|
|
$cachedData = $cache2->get('bar.txt');
|
|
|
|
|
$this->assertEquals($fooCachedData['fileid'], $cachedData['fileid']);
|
|
|
|
|
$mtime = $cachedData['mtime'];
|
|
|
|
|
|
|
|
|
|
$cachedData = $cache2->get('');
|
2019-11-27 09:27:18 -05:00
|
|
|
$this->assertIsString($substorageCachedData['etag']);
|
|
|
|
|
$this->assertIsString($cachedData['etag']);
|
2016-11-09 10:14:54 -05:00
|
|
|
$this->assertNotSame($oldEtag, $cachedData['etag']);
|
2014-08-04 08:46:48 -04:00
|
|
|
// rename can cause mtime change - invalid assert
|
2023-11-23 04:22:34 -05:00
|
|
|
// $this->assertEquals($mtime, $cachedData['mtime']);
|
2014-08-04 08:46:48 -04:00
|
|
|
|
2015-11-10 10:31:30 -05:00
|
|
|
$cachedData = $view->getFileInfo('folder');
|
2019-11-27 09:27:18 -05:00
|
|
|
$this->assertIsString($folderCachedData['etag']);
|
|
|
|
|
$this->assertIsString($cachedData['etag']);
|
2016-11-09 10:14:54 -05:00
|
|
|
$this->assertNotSame($oldEtag, $cachedData['etag']);
|
2014-08-04 08:46:48 -04:00
|
|
|
// rename can cause mtime change - invalid assert
|
2023-11-23 04:22:34 -05:00
|
|
|
// $this->assertEquals($mtime, $cachedData['mtime']);
|
2014-08-04 08:46:48 -04:00
|
|
|
}
|
|
|
|
|
|
2024-09-15 16:32:31 -04:00
|
|
|
public function testTouch(): void {
|
2014-08-04 08:46:48 -04:00
|
|
|
$rootCachedData = $this->cache->get('');
|
|
|
|
|
$fooCachedData = $this->cache->get('foo.txt');
|
|
|
|
|
Filesystem::touch('foo.txt');
|
|
|
|
|
$cachedData = $this->cache->get('foo.txt');
|
2019-11-27 09:27:18 -05:00
|
|
|
$this->assertIsString($fooCachedData['etag']);
|
|
|
|
|
$this->assertIsString($cachedData['etag']);
|
2014-08-04 08:46:48 -04:00
|
|
|
$this->assertGreaterThanOrEqual($fooCachedData['mtime'], $cachedData['mtime']);
|
|
|
|
|
|
|
|
|
|
$cachedData = $this->cache->get('');
|
2019-11-27 09:27:18 -05:00
|
|
|
$this->assertIsString($rootCachedData['etag']);
|
|
|
|
|
$this->assertIsString($cachedData['etag']);
|
2014-08-04 08:46:48 -04:00
|
|
|
$this->assertNotSame($rootCachedData['etag'], $cachedData['etag']);
|
|
|
|
|
$this->assertGreaterThanOrEqual($rootCachedData['mtime'], $cachedData['mtime']);
|
|
|
|
|
$rootCachedData = $cachedData;
|
|
|
|
|
|
|
|
|
|
$time = 1371006070;
|
|
|
|
|
$barCachedData = $this->cache->get('folder/bar.txt');
|
|
|
|
|
$folderCachedData = $this->cache->get('folder');
|
2015-02-13 09:01:05 -05:00
|
|
|
$this->cache->put('', ['mtime' => $time - 100]);
|
2014-08-04 08:46:48 -04:00
|
|
|
Filesystem::touch('folder/bar.txt', $time);
|
|
|
|
|
$cachedData = $this->cache->get('folder/bar.txt');
|
2019-11-27 09:27:18 -05:00
|
|
|
$this->assertIsString($barCachedData['etag']);
|
|
|
|
|
$this->assertIsString($cachedData['etag']);
|
2014-08-04 08:46:48 -04:00
|
|
|
$this->assertNotSame($barCachedData['etag'], $cachedData['etag']);
|
|
|
|
|
$this->assertEquals($time, $cachedData['mtime']);
|
|
|
|
|
|
|
|
|
|
$cachedData = $this->cache->get('folder');
|
2019-11-27 09:27:18 -05:00
|
|
|
$this->assertIsString($folderCachedData['etag']);
|
|
|
|
|
$this->assertIsString($cachedData['etag']);
|
2014-08-04 08:46:48 -04:00
|
|
|
$this->assertNotSame($folderCachedData['etag'], $cachedData['etag']);
|
|
|
|
|
|
|
|
|
|
$cachedData = $this->cache->get('');
|
2019-11-27 09:27:18 -05:00
|
|
|
$this->assertIsString($rootCachedData['etag']);
|
|
|
|
|
$this->assertIsString($cachedData['etag']);
|
2014-08-04 08:46:48 -04:00
|
|
|
$this->assertNotSame($rootCachedData['etag'], $cachedData['etag']);
|
|
|
|
|
$this->assertEquals($time, $cachedData['mtime']);
|
|
|
|
|
}
|
|
|
|
|
}
|