/** * @dataProvider dataGetMetadataFromIndexWorks * @param array $files * @param string $directory * @param bool $recursive * @param array $expected */ public function testGetMetadataFromIndexWorks($files, $directory, $recursive, $expected) { foreach ($files as $file) { $this->fileSystem->write($file, null); } $this->assertArrayEquals($expected, array_map(function ($v) { return $v["path"]; }, $this->fileSystem->listContents($directory, $recursive))); }
/** * @dataProvider performanceIsNotIntrusiveDataProvider * @param FileSystem $fileSystem * @param int $from * @param int $to */ public function testPerformanceIsNotIntrusive(FileSystem $fileSystem, $from, $to) { $profilerWasEnabled = SimpleProfiler::start(); if (!$profilerWasEnabled) { SimpleProfiler::enable(); } #region Build storage for ($i = $from; $i < $to; $i++) { $file = "/file_{$i}.tmp"; #region Create file SimpleProfiler::start(); $fileSystem->write($file, null); $profile = SimpleProfiler::finish(); $this->assertLessThanOrEqual(5, $profile->absoluteDuration); #endregion #region Write content SimpleProfiler::start(); $fileSystem->update($file, sha1($i, true)); $fileSystem->update($file, md5($i, true), ["append" => true]); $profile = SimpleProfiler::finish(); $this->assertLessThanOrEqual(10, $profile->absoluteDuration); #endregion #region Read content SimpleProfiler::start(); $fileSystem->read($file); $profile = SimpleProfiler::finish(); $this->assertLessThanOrEqual(5, $profile->absoluteDuration); #endregion } #endregion #region Iterate all files SimpleProfiler::start(); /** @noinspection PhpUnusedLocalVariableInspection */ foreach ($fileSystem->listContents() as $unused) { } $profile = SimpleProfiler::finish(); $this->assertLessThanOrEqual(5 * $to, $profile->absoluteDuration); #endregion if (!$profilerWasEnabled) { SimpleProfiler::disable(); } SimpleProfiler::finish(); }