<?php

// bootstrap in the functional configuration since the theme manager is context-dependent
require_once dirname(__FILE__) . '/../../bootstrap/unit.php';
require_once dirname(__FILE__) . '/../../bootstrap/functional.php';
$t = new lime_test(31);
$t->info('1 - Test some basics of getting themes, theme objects');
// we'll use this to test the theme object
$themeConfig = array('layout' => 'testing');
$theme = new sfTheme($themeConfig);
$manager = new sfThemeManager($context);
$t->is($manager->getThemes(), array(), '->getThemes() returns an empty array to start.');
$manager = new sfThemeManager($context, array('test_theme' => $themeConfig));
$t->is($manager->getThemes(), array('test_theme' => $themeConfig), 'Themes can be set via the constructor.');
$manager = new sfThemeManager($context);
$manager->addTheme('test_theme', $themeConfig);
$t->is($manager->getThemes(), array('test_theme' => $themeConfig), 'Themes can be set via addTheme() passing in an array.');
$t->is($manager->getThemeObject('test_theme')->getConfig(), $theme->getConfig(), '->getThemeObject() returns the correct theme object');
$manager = new sfThemeManager($context);
$manager->addTheme('test_theme', $theme);
$t->is($manager->getThemes(), array('test_theme' => $themeConfig), 'Themes can be set via addTheme() passing in an sfTheme object.');
$t->is($manager->getThemeObject('test_theme'), $theme, '->getThemeObject() returns the correct theme object');
$t->info('  1.1 - Trying to retrieve a non-existent theme object throws an exception');
try {
    $manager->getThemeObject('fake');
    $t->fail('No exception thrown');
} catch (sfException $e) {
    $t->pass($e->getMessage());
}
$t->info('  1.2 - Play with the current theme');
$t->is($manager->getCurrentTheme(), false, '->getCurrentTheme() returns false when there is no theme set');
Пример #2
0
<?php

require_once dirname(__FILE__) . '/../../bootstrap/unit.php';
$t = new lime_test(6);
$configuration = array('layout' => 'my_layout', 'stylesheets' => array('main.css'), 'javascripts' => array('main.js'));
$theme = new sfTheme($configuration);
$t->is($theme->getLayout(), $configuration['layout'], '->getLayout() return my_layout');
$t->is($theme->getStylesheets(), $configuration['stylesheets'], '->getStyleseets() returns correct value');
$t->is($theme->getJavascripts(), $configuration['javascripts'], '->getJavascripts() returns correct value');
$t->is($theme->getCallables(), array(), '->getCallables() returns correct value');
$t->is($theme->getConfig('layout', 'ignored'), $configuration['layout'], '->getConfig() returns correct value for existing config value');
$t->is($theme->getConfig('fake', 'test_default'), 'test_default', '->getConfig() returns default value for non-existant config value');