format('Y-m-d'), LocalStorage::created($testFile)->format('Y-m-d')); self::assertEquals($now->format('Y-m-d'), LocalStorage::changed($testFile)->format('Y-m-d')); self::assertGreaterThan(0, LocalStorage::size($testFile)); self::assertGreaterThan(0, LocalStorage::permission($testFile)); $newPath = __DIR__ . '/sub/path/testing.txt'; self::assertTrue(LocalStorage::copy($testFile, $newPath)); self::assertTrue(LocalStorage::exists($newPath)); self::assertFalse(LocalStorage::copy($testFile, $newPath)); self::assertTrue(LocalStorage::copy($testFile, $newPath, true)); self::assertEquals('test5test3test4', LocalStorage::get($newPath)); $newPath2 = __DIR__ . '/sub/path/testing2.txt'; self::assertTrue(LocalStorage::move($testFile, $newPath2)); self::assertTrue(LocalStorage::exists($newPath2)); self::assertFalse(LocalStorage::exists($testFile)); self::assertEquals('test5test3test4', LocalStorage::get($newPath2)); self::assertTrue(LocalStorage::delete($newPath2)); self::assertFalse(LocalStorage::exists($newPath2)); self::assertFalse(LocalStorage::delete($newPath2)); \unlink($newPath); \rmdir(__DIR__ . '/sub/path/'); \rmdir(__DIR__ . '/sub/'); self::assertTrue(LocalStorage::create($testFile)); self::assertFalse(LocalStorage::create($testFile)); self::assertEquals('', LocalStorage::get($testFile)); \unlink($testFile); } public function testDirectory() : void { $dirPath = __DIR__ . '/test'; self::assertTrue(LocalStorage::create($dirPath)); self::assertTrue(LocalStorage::exists($dirPath)); self::assertFalse(LocalStorage::create($dirPath)); self::assertTrue(LocalStorage::create(__DIR__ . '/test/sub/path')); self::assertTrue(LocalStorage::exists(__DIR__ . '/test/sub/path')); self::assertEquals('test', LocalStorage::name($dirPath)); self::assertEquals('test', LocalStorage::basename($dirPath)); self::assertEquals('test', LocalStorage::dirname($dirPath)); self::assertEquals(\str_replace('\\', '/', \realpath($dirPath . '/../')), LocalStorage::parent($dirPath)); self::assertEquals($dirPath, LocalStorage::dirpath($dirPath)); $now = new \DateTime('now'); self::assertEquals($now->format('Y-m-d'), LocalStorage::created($dirPath)->format('Y-m-d')); self::assertEquals($now->format('Y-m-d'), LocalStorage::changed($dirPath)->format('Y-m-d')); self::assertTrue(LocalStorage::delete($dirPath)); self::assertFalse(LocalStorage::exists($dirPath)); $dirTestPath = __DIR__ . '/dirtest'; self::assertGreaterThan(0, LocalStorage::size($dirTestPath)); self::assertGreaterThan(LocalStorage::size($dirTestPath, false), LocalStorage::size($dirTestPath)); self::assertGreaterThan(0, LocalStorage::permission($dirTestPath)); } public function testDirectoryMove() : void { $dirTestPath = __DIR__ . '/dirtest'; self::assertTrue(LocalStorage::copy($dirTestPath, __DIR__ . '/newdirtest')); self::assertTrue(\file_exists(__DIR__ . '/newdirtest/sub/path/test3.txt')); self::assertTrue(LocalStorage::delete($dirTestPath)); self::assertFalse(LocalStorage::exists($dirTestPath)); self::assertTrue(LocalStorage::move(__DIR__ . '/newdirtest', $dirTestPath)); self::assertTrue(\file_exists($dirTestPath . '/sub/path/test3.txt')); self::assertEquals(4, LocalStorage::count($dirTestPath)); self::assertEquals(1, LocalStorage::count($dirTestPath, false)); self::assertEquals(6, \count(LocalStorage::list($dirTestPath))); } /** * @expectedException \phpOMS\System\File\PathException */ public function testInvalidPutPath() : void { LocalStorage::put(__DIR__, 'Test'); } /** * @expectedException \phpOMS\System\File\PathException */ public function testInvalidGetPath() : void { LocalStorage::get(__DIR__); } /** * @expectedException \phpOMS\System\File\PathException */ public function testInvalidListPath() : void { LocalStorage::list(__DIR__ . '/LocalStorageTest.php'); } /** * @expectedException \phpOMS\System\File\PathException */ public function testInvalidSetPath() : void { LocalStorage::set(__DIR__, 'Test'); } /** * @expectedException \phpOMS\System\File\PathException */ public function testInvalidAppendPath() : void { LocalStorage::append(__DIR__, 'Test'); } /** * @expectedException \phpOMS\System\File\PathException */ public function testInvalidPrependPath() : void { LocalStorage::prepend(__DIR__, 'Test'); } /** * @expectedException \phpOMS\System\File\PathException */ public function testInvalidExtensionPath() : void { LocalStorage::extension(__DIR__); } }