<?php require_once dirname(__FILE__) . '/helper/dmUnitTestHelper.php'; $helper = new dmUnitTestHelper(); $helper->boot(); $t = new lime_test(33); $v = new dmValidatorCssIdAndClasses(); $t->diag('->clean()'); foreach (array('a', 'a_b', 'a-c', 'qieurgfbqoiuzbfvoqiuzZFZGPSOZDNZKFjflzkh986875OoihzyfvbxoquyfvxqozufyxqzUEFV', '9', '_', ' bla rebla ', '- _ 8', '.class', '.a b.c.d', '#myid.a b.c.d', '#myid class1 class2', 'class1 class2 #myid', '.a b#myid.c.d', '.a b#myid.c.d#myid', '.a b#myid.c.d #myid', '#my_id', '#my-id', ' #my-id ') as $classes) { try { $t->comment('"' . $classes . '" -> "' . $v->clean($classes) . '"'); $t->pass('->clean() checks that the value is a valid css class name + id'); } catch (sfValidatorError $e) { $t->fail('->clean() checks that the value is a valid css class name + id'); } } foreach (array('.zegze$g.zegf', '/', 'a/f', 'a^', 'a # @', 'é', '-{') as $nonClass) { $t->comment($nonClass); try { $v->clean($nonClass); $t->fail('->clean() throws an sfValidatorError if the value is not a valid css class name + id'); $t->skip('', 1); } catch (sfValidatorError $e) { $t->pass('->clean() throws an sfValidatorError if the value is not a valid css class name + id'); $t->is($e->getCode(), 'invalid', '->clean() throws a sfValidatorError'); } }
<?php require_once dirname(__FILE__) . '/helper/dmUnitTestHelper.php'; $helper = new dmUnitTestHelper(); $helper->boot('front'); clearstatcache(true); $isSqlite = Doctrine_Manager::getInstance()->getConnection('doctrine') instanceof Doctrine_Connection_Sqlite; $t = new lime_test(16 + ($isSqlite ? 0 : 1) + 3 * count($helper->get('i18n')->getCultures())); $user = $helper->get('user'); try { $index = $helper->get('search_index'); $t->fail('Can\'t create index without dir'); } catch (dmSearchIndexException $e) { $t->pass('Can\'t create index without dir'); } $engine = $helper->get('search_engine'); $t->isa_ok($engine, 'dmSearchEngine', 'Got a dmSearchEngine instance'); $expected = dmProject::rootify(dmArray::get($helper->get('service_container')->getParameter('search_engine.options'), 'dir')); $t->is($engine->getFullPath(), $expected, 'Current engine full path is ' . $expected); $t->ok(!file_exists(dmProject::rootify('segments.gen')), 'There is no segments.gen in project root dir'); $engine->setDir('cache/testIndex'); foreach ($helper->get('i18n')->getCultures() as $culture) { $user->setCulture($culture); $currentIndex = $engine->getCurrentIndex(); $t->is($currentIndex->getName(), 'dm_page_' . $culture, 'Current index name is ' . $currentIndex->getName()); $t->is($currentIndex->getCulture(), $culture, 'Current index culture is ' . $culture); $t->is($currentIndex->getFullPath(), dmProject::rootify('cache/testIndex/' . $currentIndex->getName()), 'Current index full path is ' . $currentIndex->getFullPath()); } $user->setCulture(sfConfig::get('sf_default_culture')); $currentIndex = $engine->getCurrentIndex(); $t->isa_ok($currentIndex->getLuceneIndex(), 'Zend_Search_Lucene_Proxy', 'The current index is instanceof Zend_Search_Lucene_Proxy');
<?php require_once dirname(__FILE__) . '/helper/dmUnitTestHelper.php'; $helper = new dmUnitTestHelper(); $helper->boot('admin'); $t = new lime_test(2); $t->comment('Check config files order'); $configPath = 'config/dm/modules.yml'; $paths = $helper->getConfiguration()->getConfigPaths($configPath); $t->is($paths[0], dmOs::join(sfConfig::get('dm_core_dir'), $configPath), 'dmCore is first'); $t->is($paths[1], dmOs::join(sfConfig::get('dm_admin_dir'), $configPath), 'dmAdmin is second');