/** * Checks if asset file and thumbnails exist in filesystem. * * @param string $folder asset folder (relative path) * @param string $file asset filename * @param boolean $check_thumbs check existence/non-existence of thumbnail files * @param boolean $exist true=must exist, false=must not exist * * @return lyMediaTestFunctional current lyMediaTestFunctional instance */ protected function checkFile($folder, $file, $check_thumbs = true, $exist = true) { $fs = new lyMediaFileSystem(); $this->test()->is($fs->is_file($folder . $file), $exist, 'File ' . $folder . $file . ($exist ? ' has ' : ' has not ') . 'been found'); if ($check_thumbs) { $tn = new lyMediaThumbnails($folder, $file); foreach ($tn->getThumbnailPaths() as $file_path) { $this->test()->is($fs->is_file($file_path), $exist, 'Thumbnail ' . basename($file_path) . ($exist ? ' has ' : ' has not ') . 'been found'); } } return $this; }
/** * Checks if asset file and asset thumbnails (if supported) exist in filesystem. * * @param lyMediaAsset $asset * @param boolean $exist true=must exist, false=must not exist * * @return lyMediaTestFunctional current lyMediaTestFunctional instance */ protected function checkFile($asset, $exist = true) { $fs = new lyMediaFileSystem(); $file_path = $asset->getPath(); $this->test()->is($fs->is_file($file_path), $exist, 'File ' . $file_path . ($exist ? ' has ' : ' has not ') . 'been found'); if ($asset->supportsThumbnails()) { $tn = new lyMediaThumbnails($file_path, in_array($asset->getType(), array('image/png', 'image/gif')) ? $asset->getType() : 'image/jpeg', $asset->getThumbnailFile(null)); foreach ($tn->getThumbnailPaths() as $file_path) { $this->test()->is($fs->is_file($file_path), $exist, 'Thumbnail ' . basename($file_path) . ($exist ? ' has ' : ' has not ') . 'been found'); } } return $this; }
* -- -- -- test 2 */ $t->is($folder2->getRelativePath(), 'test_root/test/test-sub/test2/', '->getRelativePath()'); $t->is($folder2->getNode()->getPath('/', true), 'test_root/test/test-sub/test2', 'Folder has right path'); $t->ok($fs->is_dir($folder2->getRelativePath()), 'Folder exists in filesystem'); $t->info('Synchronize folder'); //Create orphaned asset $asset = new lyMediaAsset(); $asset->setFolder($folder); $asset->setFilename(dirname(__FILE__) . '/../data/assets/asseta.png'); $asset->save(); $root->synchronizeWith(dirname(__FILE__) . '/../data/assets/', false); $asset = lyMediaAssetTable::getInstance()->findOneByFilename('asset1.png'); $t->ok(is_object($asset), 'Asset created in root'); $t->is($asset->getPath(), 'test_root/asset1.png', 'Asset has correct path'); $t->ok($fs->is_file('test_root/asset1.png'), 'Asset exists in filesystem'); $t->ok($fs->is_file('test_root/thumbs/small_asset1.png'), 'Small thumbnail exists in filesystem'); $t->ok($fs->is_file('test_root/thumbs/medium_asset1.png'), 'Medium thumbnail exists in filesystem'); $asset = lyMediaAssetTable::getInstance()->findOneByFilename('assetc.png'); $t->ok(is_object($asset), 'Asset created in subfolder'); $t->is($asset->getPath(), 'test_root/test/test-sub/assetc.png', 'Asset has correct path'); $t->ok($fs->is_file('test_root/test/test-sub/assetc.png'), 'Asset exists in filesystem'); $t->ok($fs->is_file('test_root/test/test-sub/thumbs/small_assetc.png'), 'Small thumbnail exists in filesystem'); $t->ok($fs->is_file('test_root/test/test-sub/thumbs/medium_assetc.png'), 'Medium thumbnail exists in filesystem'); $t->ok($fs->is_dir('test_root/test/test-sub/test2'), 'Orphaned folder still exists'); $t->ok($fs->is_file('test_root/test/asseta.png'), 'Orphaned asset still exists'); $t->info('Synchronize folder (remove orphaned folder)'); $root->synchronizeWith(dirname(__FILE__) . '/../data/assets/', false, false, true); $t->ok(!$fs->is_dir('test_root/test/test-sub/test2'), 'Orphaned folder no longer exists'); $t->ok($fs->is_file('test_root/test/asseta.png'), 'Orphaned asset still exists'); $t->info('Synchronize folder (remove orphaned asset)');