Beispiel #1
0
<?php

require_once realpath(dirname(__FILE__) . '/../../..') . '/unit/helper/dmModuleUnitTestHelper.php';
$helper = new dmModuleUnitTestHelper();
$helper->boot();
$moduleManager = $helper->get('module_manager');
$t = new lime_test(83);
$t->comment('Is module test');
foreach (array('dmPage' => true, 'dmTransUnit' => true, 'dmWidget' => true, 'dmWidget' => true, 'dmTestPost' => true, 'dmTestDomain' => true, 'main' => true, 'dmTestTag' => true, 'dmTestPostTag' => false, 'dm' => false, '' => false, ' main ' => false) as $moduleKey => $exists) {
    $t->is($moduleManager->hasModule($moduleKey), $exists, $moduleKey . ' exists : ' . $exists);
}
$t->diag('isProject tests');
foreach (array('dmPage' => false, 'dmTransUnit' => false, 'dmWidget' => false, 'dmWidget' => false, 'dmTestPost' => true, 'dmTestDomain' => true, 'main' => true, 'dmTestTag' => true) as $moduleKey => $isProject) {
    $t->is($moduleManager->getModule($moduleKey)->isProject(), $isProject, $moduleKey . '->isProject() : ' . $isProject);
}
$t->comment('Module components tests');
foreach (array('main' => 'header footer sitemap', 'dmUser' => 'signin form list show', 'dmTestCateg' => 'list listByDomain show', 'dmTestPost' => 'listByDomain listByCateg listByTag show', 'dmTestComment' => 'listByDomain listByCateg listByPost form') as $moduleKey => $componentKeys) {
    $module = $helper->getModule($moduleKey);
    foreach (explode(' ', $componentKeys) as $componentKey) {
        $component = $module->getComponent($componentKey);
        $t->isa_ok($component, 'dmModuleComponent', $moduleKey . '/' . $componentKey . ' is a dmModuleComponent');
    }
}
$t->diag('Ancestor tests');
foreach (array('dmTestFruit dmTestPost' => false, 'dmTestFruit dmTestFruit' => false, 'dmTestPost dmTestCateg' => true, 'dmTestPost dmTestDomain' => true, 'dmTestComment dmTestPost' => true, 'dmTestComment dmTestCateg' => true, 'dmTestComment dmTestDomain' => true, 'dmTestComment dmTestComment' => false, 'dmTestCateg dmTestComment' => false, 'dmTestCateg dmTestDomain' => true, 'dmTestTag dmTestTag' => false, 'dmTestTag dmTestDomain' => false, 'dmTestTag dmTestComment' => false, 'dmTestTag dmUser' => false, 'dmUser dmTestTag' => false) as $modules => $hasAncestor) {
    $modules = explode(' ', $modules);
    $t->is($helper->hasAncestor($modules[0], $modules[1]), $hasAncestor, sprintf('%s has %s ancestor: %s', $modules[0], $modules[1], $hasAncestor ? 'TRUE' : 'FALSE'));
}
$t->diag('Nearest ancestor with page tests');
foreach (array('dmTestFruit dmTestPost' => false, 'dmTestFruit dmTestFruit' => false, 'dmTestPost dmTestCateg' => true, 'dmTestPost dmTestDomain' => false, 'dmTestComment dmTestPost' => true, 'dmTestComment dmTestCateg' => false, 'dmTestComment dmTestComment' => false, 'dmTestCateg dmTestComment' => false, 'dmTestCateg dmTestDomain' => true, 'dmTestTag dmTestTag' => false, 'dmTestTag dmTestComment' => false) as $modules => $hasAncestor) {
    $modules = explode(' ', $modules);
Beispiel #2
0
<?php

require_once realpath(dirname(__FILE__) . '/../../..') . '/unit/helper/dmModuleUnitTestHelper.php';
$helper = new dmModuleUnitTestHelper();
$helper->boot('front');
$t = new lime_test(21);
$manager = $helper->get('theme_manager');
$default = $manager->getDefaultTheme();
$t->isa_ok($default, 'dmTheme', 'default theme is a dmTheme');
$t->is($default->getName(), 'Fancy Theme', 'default theme name is Fancy Theme');
$t->is($default->getPath(), '/fancyTheme/', 'default theme path is fancyTheme');
$t->ok($default->isEnabled(), 'default theme is enabled');
$t->ok($default->exists(), 'Fancy Theme exists');
$first = $manager->getTheme('First Theme');
$t->isa_ok($first, 'dmTheme', 'first theme is a dmTheme');
$t->is($first->getName(), 'First Theme', 'first theme name is First Theme');
$t->is($first->getPath(), '/theme/', 'first theme path is theme');
$t->ok(!$first->isEnabled(), 'first theme is not enabled');
$t->ok(!$first->exists(), 'First Theme does not exist');
$another = $manager->getTheme('Another Theme');
$t->isa_ok($another, 'dmTheme', 'another theme is a dmTheme');
$t->is($another->getName(), 'Another Theme', 'another theme name is Fancy Theme');
$t->is($another->getPath(), '/anotherTheme/', 'another theme path is fancyTheme');
$t->ok($another->isEnabled(), 'another theme is enabled');
$t->ok(!$another->exists(), 'Another Theme does not exist');
$t->is_deeply($manager->getThemeNames(), $expected = array('First Theme', 'Fancy Theme', 'Another Theme'), 'Theme names are ' . implode(', ', $expected));
$t->is($manager->getDefaultThemeName(), 'Fancy Theme', 'default theme name is Fancy Theme');
$t->is($manager->getDefaultTheme(), $default, 'default theme is Fancy Theme');
$t->ok($manager->themeNameExists('Fancy Theme'), 'Fancy Theme exists');
$t->ok(!$manager->themeNameExists('Uncool Theme'), 'Uncool Theme does not exist');
$t->is_deeply($manager->getThemesEnabled(), $expected = array('Fancy Theme' => $default, 'Another Theme' => $another), 'themes enabled are ' . implode(', ', array_keys($expected)));