Exemple #1
0
unlink($media->fullPath);
$t->diag('Sync folder');
$root->sync();
$helper->checkTreeIntegrity($t);
$t->ok(!$media->exists(), 'media has been deleted in database');
$t->ok(!file_exists($media->fullPath), 'media has been deleted in filesystem');
$t->diag('Sync root folder');
$root->sync();
$helper->checkTreeIntegrity($t);
$helper->testFolderCorrelations($t);
$t->diag('Copy heavy folders structure into folder');
$sourcePath = dmOs::join(dm::getDir(), 'dmCorePlugin/lib/view');
$destRelPath = $folder->relPath . '/' . 'test_lib_view_' . dmString::random(8);
$destFullPath = dmOs::join($root->fullPath, $destRelPath);
try {
    $helper->get('filesystem')->mirror($sourcePath, $destFullPath, sfFinder::type('all'));
    $t->pass('Copy completed');
} catch (Exception $e) {
    $t->fail('Copy failed : ' . $e->getMessage());
}
$t->ok(file_exists(dmOs::join($destFullPath, 'html/link/dmBaseLinkTag.php')), dmOs::join($destFullPath, 'html/link/dmBaseLinkTag.php') . ' exists');
$t->diag('Sync root');
$root->sync();
$helper->checkTreeIntegrity($t);
$helper->testFolderCorrelations($t);
$linkFolder = $folderTable->findOneByRelPath($destRelPath . '/html/link');
$t->isa_ok($linkFolder, 'DmMediaFolder', $destRelPath . '/html/link/ is a DmMediaFolder');
try {
    $deepMedia = $mediaTable->findOneByFileAndDmMediaFolderId('dmBaseLinkTag.php', $linkFolder->id);
    $t->isa_ok($deepMedia, 'DmMedia', 'deep media found in db');
} catch (Exception $e) {
Exemple #2
0
    $t->pass($message);
} catch (Exception $e) {
    $t->fail($message);
    throw $e;
}
$helper->checkTreeIntegrity($t);
$helper->testFolderCorrelations($t);
$t->is((string) $f2->getNode()->getParent(), (string) $f1, 'f2 is in f1');
$t->ok($f1->hasSubfolder($f2->name));
$t->is($f1->nbElements, 1, 'f1 has one element');
$t->is($f1->getSubFoldersByName(), array('f2b' => $f2), 'f1 folders by name is f2');
$t->is($f2->relPath, $parent->relPath . '/f1/f2b', 'f2 rel path: ' . $f2->relPath);
$t->is($f2->fullPath, $parent->fullPath . '/f1/f2b', 'f2 full path: ' . $f2->fullPath);
$t->is($media->relPath, $f2->relPath . '/test.jpg', 'media rel path: ' . $media->relPath);
$t->is($media->fullPath, $f2->fullPath . '/test.jpg', 'media full path: ' . $media->fullPath);
$t->is($f3->relPath, $parent->relPath . '/f1/f2b/f3', 'f3 rel path: ' . $f3->relPath);
$t->is($f3->fullPath, $parent->fullPath . '/f1/f2b/f3', 'f3 full path: ' . $f3->fullPath);
$t->ok(!file_exists($parent->fullPath . '/f2b/test.jpg'), 'old file does no more exist');
$t->ok(!is_dir($parent->fullPath . '/f2b/f3'), 'old f3 dir does no more exist');
$t->ok(!is_dir($parent->fullPath . '/f2b'), 'old f2 dir does no more exist');
$t->ok(file_exists($parent->fullPath . '/f1/f2b/test.jpg'), 'new file exists');
$t->ok(is_dir($parent->fullPath . '/f1/f2b/f3'), 'new f3 dir exists');
$t->ok(is_dir($parent->fullPath . '/f1/f2b'), 'new f2 dir exists');
$t->ok($f2->dirExists(), $f2->name . ' dir exists');
$t->ok($f2->isWritable(), $f2->name . ' isWritable');
$t->comment('Add a .thumbs folder in f2');
mkdir($f2->fullPath . '/.thumbs');
$f2->sync();
$t->is(dmDb::query('DmMediaFolder f')->where('f.rel_path LIKE ?', '%.thumbs')->count(), 0, 'No folder .thumbs where created');
$helper->get('filesystem')->sf('doctrine:dql "from DmMediaFolder folder" --table');
$t->comment($helper->get('filesystem')->getLastExec('output'));