function testTag() { $data = array('actions' => array('create' => array('jip' => true), 'edit' => array('jip' => true), 'display' => array(), 'delete' => array('jip' => true))); $template = '<core:DATASOURCE id="realm"><limb:DSProcessor:GroupActions group_name="jip">'. '<list:LIST from="jip_actions"><list:ITEM>'. '<core:OPTIONAL for="jip">{$name}|</core:OPTIONAL>'. '</list:ITEM></list:LIST>'. '</core:DATASOURCE>'; RegisterTestingTemplate('/limb/actions_DSProcessor.html', $template); $page =& new Template('/limb/actions_DSProcessor.html'); $component =& $page->findChild('realm'); $dataspace = new Dataspace(); $dataspace->import($data); $component->registerDataSource($dataspace); $this->assertEqual($page->capture(), 'create|'. 'edit|'. 'delete|'); }
function testTag() { $object1_data = array('_node_id' => $id1 = 10); $object2_data = array('_node_id' => $id2 = 20); $rs = new PagedArrayDataset(array($object1_data, $object2_data)); $this->path2id_translator->expectAtleastOnce('getPathToNode'); $this->path2id_translator->setReturnValueAt(0, 'getPathToNode', $path1 = 'path1', array($id1)); $this->path2id_translator->setReturnValueAt(1, 'getPathToNode', $path2 = 'path2', array($id2)); $template = '<limb:RSProcessor:PATH source="list1">'. '<list:LIST id="list1">'. '<list:ITEM>{$_node_path}_{$_node_id}|</list:ITEM>'. '</list:LIST>'; RegisterTestingTemplate('/limb/path_record_set_processor.html', $template); $page =& new Template('/limb/path_record_set_processor.html'); $component =& $page->findChild('list1'); $component->registerDataSet($rs); $this->assertEqual($page->capture(), $path1.'_10|'. $path2 . '_20|'); }
function testFile() { $template = '<limb:locale:STRING file="error">cant_be_deleted</limb:locale:STRING>'; RegisterTestingTemplate('/limb/locale_string_file.html', $template); $page =& new Template('/limb/locale_string_file.html'); $this->assertEqual($page->capture(), 'Object can\'t be deleted'); }
function testRepeatByVariable() { $template = '<core:SET count="4"><limb:REPEAT value="{$count}">hello!</limb:REPEAT>'; RegisterTestingTemplate('/limb/repeat2.html', $template); $page =& new Template('/limb/repeat2.html'); $this->assertEqual($page->capture(), 'hello!hello!hello!hello!'); }
function testUsingManagementLocaleIdByDefault() { $template = '<limb:LOCALE name="no_such_locale" locale_type="management">Some text</limb:LOCALE>' . '<limb:LOCALE name="' . MANAGEMENT_LOCALE_ID . '" locale_type="management">Other text</limb:LOCALE>'; RegisterTestingTemplate('/limb/locale_management.html', $template); $page =& new Template('/limb/locale_management.html'); $this->assertEqual($page->capture(), 'Other text'); }
function testValueIsZero() { $template = '<limb:OPTIONAL for="var">test!</limb:OPTIONAL>'; RegisterTestingTemplate('/limb/optional_is_zero.html', $template); $page =& new Template('/limb/optional_is_zero.html'); $page->set('var', 0); $this->assertEqual('', $page->capture()); }
function testValueIsZero() { $template = '<limb:DEFAULT for="var">test!</limb:DEFAULT>'; RegisterTestingTemplate('/limb/default_is_zero.html', $template); $page =& new Template('/limb/default_is_zero.html'); $page->set('var', 0); $this->assertEqual('test!', $page->capture()); }
function testPerformOk() { RegisterTestingTemplate('/test.html', 'hello'); $command = new UseViewCommand('/test.html'); $this->assertEqual($command->perform(), LIMB_STATUS_OK); $toolkit =& Limb :: toolkit(); $view = $toolkit->getView(); $this->assertIsA($view, 'Template'); }
function setUp() { $toolkit =& Limb::toolkit(); $conn =& $toolkit->getDBConnection(); $this->db =& new SimpleDB($conn); $this->_cleanUp(); $form_template_path = '/test_content_service_node_form.html'; $form_name = 'test_form'; RegisterTestingTemplate($form_template_path, '<form id="' . $form_name . '" runat="server"></form>'); $validator = new LimbHandle(LIMB_SERVICE_NODE_DIR . '/validators/CommonEditServiceNodeValidator'); $this->command = new EditServiceNodeCommand($form_template_path, $form_name, $validator); $toolkit =& Limb::saveToolkit(); $toolkit->setRequestResolver('tree_based_entity', new TreeBasedEntityRequestResolver()); }
function testTag() { $data = array('_node_path' => $path = '/cms/limb/', '_service_name' => $service_name = 'TestService'); $this->authorizer->expectOnce('getAccessibleActions', array($path, $service_name)); $actions = array('create' => array('name' => 'create'), 'edit' => array('name' => 'edit')); $this->authorizer->setReturnValue('getAccessibleActions', $actions); $template = '<core:DATASOURCE id="realm"><limb:DSProcessor:Actions>' . '<list:LIST from="actions"><list:ITEM>' . '{$name}|' . '</list:ITEM></list:LIST>' . '</core:DATASOURCE>'; RegisterTestingTemplate('/limb/actions_DSProcessor.html', $template); $page =& new Template('/limb/actions_DSProcessor.html'); $component =& $page->findChild('realm'); $dataspace = new Dataspace(); $dataspace->import($data); $component->registerDataSource($dataspace); $this->assertEqual($page->capture(), 'create|' . 'edit|'); }
function testPerformOk() { RegisterTestingTemplate('/close_popup.html', "<list:LIST id='params'>" . "<list:ITEM>{\$name},{\$value}</list:ITEM>". "</list:LIST>"); $command = new CloseDialogCommand(); $this->assertEqual($command->perform(), LIMB_STATUS_OK); $toolkit =& Limb :: toolkit(); $response =& $toolkit->getResponse(); $this->assertEqual($response->getResponseString(), 'from_dialog,1'); }
function setUp() { $toolkit =& Limb::toolkit(); $conn =& $toolkit->getDBConnection(); $this->db =& new SimpleDB($conn); $this->_cleanUp(); $template_path = '/test_content_service_node_form.html'; $form_id = 'test_form'; $validator = new EditTestContentServiceNodeValidator(); RegisterTestingTemplate($template_path, '<form id="' . $form_id . '" runat="server"></form>'); // dataspace field => content part field $content_map = array('annotation' => 'annotation', 'content' => 'content'); $this->command = new EditContentServiceNodeCommand($template_path, $form_id, $validator, $content_map); $toolkit =& Limb::saveToolkit(); $toolkit->setRequestResolver('tree_based_entity', new TreeBasedEntityRequestResolver()); }
function testSetParameter() { $template = '<div id="test" runat="server"><limb:PARAMETER limit="10" offset="20"></div>'; RegisterTestingTemplate('/limb/parameter.html', $template); $page =& new Template('/limb/parameter.html'); $div =& $page->getChild('test'); $this->assertEqual($div->getAttribute('limit'), 10); $this->assertEqual($div->getAttribute('offset'), 20); $this->assertEqual('<div id="test" limit="10" offset="20"></div>', $page->capture()); }
function testPreserveState() { $template = '<form id="testForm" name="testForm" runat="server">' . '<limb:PRESERVE_STATE name="id">' . '</form>'; RegisterTestingTemplate('/limb/preserve_state1.html', $template); $data = new Dataspace(); $data->set('id', 10000); $page =& new Template('/limb/preserve_state1.html'); $form =& $page->findChild('testForm'); $form->registerDatasource($data); $this->assertEqual($page->capture(), '<form id="testForm" name="testForm">' . '<input type="hidden" name="id" value="10000">' . '</form>'); }
function testMultipleTargets() { $template = '<limb:DAO:Record target="testTarget1,testTarget2" class="TestDAO" />' . '<core:DATASOURCE id="testTarget1">{$username}</core:DATASOURCE>' . '<core:DATASOURCE id="testTarget2">{$secondname}</core:DATASOURCE>'; RegisterTestingTemplate('/limb/datasource_dao_multiple_targets.html', $template); $page =& new Template('/limb/datasource_dao_multiple_targets.html'); $this->toolkit->setReturnReference('createDAO', $this->ds, array('TestDAO')); $data = array('username'=>'joe', 'secondname' => 'fisher'); $datasource =& new Dataspace(); $datasource->import($data); $this->ds->expectOnce('fetchRecord'); $this->ds->setReturnReference('fetchRecord', $datasource); $this->assertEqual($page->capture(), 'joefisher'); }
function testTag() { $path = 'whatever'; $data = array('_node_id' => $node_id = 10); $this->translator->expectOnce('getPathToNode', array($node_id)); $this->translator->setReturnValue('getPathToNode', $path); $template = '<core:DATASOURCE id="realm"><limb:DSProcessor:Path>'. '{$_node_path}'. '</core:DATASOURCE>'; RegisterTestingTemplate('/limb/path_DSProcessor.html', $template); $page =& new Template('/limb/path_DSProcessor.html'); $component =& $page->findChild('realm'); $dataspace = new Dataspace(); $dataspace->import($data); $component->registerDataSource($dataspace); $this->assertEqual($page->capture(), $path); }
function testLimbRowNumberDataSetIsPaginated() { $template = '<list:LIST id="test">'. '<list:ITEM>{$LimbListRowNumber}:{$name}</list:ITEM>'. '</list:LIST>'; RegisterTestingTemplate('/limb/list_row_number_pager.html', $template); $page =& new Template('/limb/list_row_number_pager.html'); $list =& $page->getChild('test'); $dataset = new PagedArrayDataSet($this->names); $pager = new MockPageNavigatorComponent($this); $pager->setReturnValue('getStartingItem', 2); $pager->setReturnValue('getItemsPerPage', 4); $dataset->paginate($pager); $list->registerDataSet($dataset); $this->assertEqual($page->capture(), '3:Pavel4:John'); $pager->tally(); }
function testRenderAsCommonForm() { $template = '<limb:FORM id="testForm" name="testForm"></limb:FORM>'; RegisterTestingTemplate('/limb/form6.html', $template); $page =& new Template('/limb/form6.html'); $result = $page->capture(); $this->assertEqual($result, '<form id="testForm" name="testForm"></form>'); }
function testOptionsViaRegisterDataSet() { $template = '<limb:select_options_source id="source" target="select">' . '<form runat="server">' . '<select id="select" name="select"></select>' . '</form>'; $options = array(array('4' => 'red'), array('5' => 'blue')); RegisterTestingTemplate('/limb/select_options_source2.html', $template); $page =& new Template('/limb/select_options_source2.html'); $data =& $page->getChild('source'); $data->registerDataSet(new ArrayDataSet($options)); $this->assertEqual($page->capture(), '<form>'. '<select id="select" name="select"><option value="4">red</option><option value="5">blue</option></select>'. '</form>'); }
function testTranslateFromOneLocaleToAnother() { $template = '<limb:locale:DATE date_locale="fr" locale="en" date_format="%A %d %B %Y" date_type="localized_string" format_type="date">'. 'Jeudi 20 Janvier 2005'. '</limb:locale:DATE>'; RegisterTestingTemplate('/limb/locale_date_transfer_between_locales.html', $template); $page =& new Template('/limb/locale_date_transfer_between_locales.html'); $this->assertEqual($page->capture(), 'Thursday 20 January 2005'); }
function testMirror() { $uri = new Uri('test.com'); $toolkit =& new MockLimbToolkit($this); $request =& new MockRequest($this); $toolkit->setReturnReference('getRequest', $request); Limb :: registerToolkit($toolkit); $request->setReturnValue('getUri', $uri); $template = '<limb:pager:NAVIGATOR id="test1" items="10">'. '<limb:pager:PREV>P1-{$href}|</limb:pager:PREV>' . '</limb:pager:NAVIGATOR>'. //note, mirror settings override source!!! '<limb:pager:NAVIGATOR id="test2" mirror="test1" items="30">'. '<limb:pager:PREV>P2-{$href}|</limb:pager:PREV>' . '</limb:pager:NAVIGATOR>'; RegisterTestingTemplate('/limb/pager_navigator_mirror.html', $template); $page =& new Template('/limb/pager_navigator_mirror.html'); $navigator =& $page->findChild('test1'); $pager_id = $navigator->getPagerId(); $request->setReturnValue('export', array($pager_id => 3)); $request->setReturnValue('get', 3, array($pager_id)); $navigator->setTotalItems(60); $navigator->prepare(); $expected = "P1-test.com|P2-test.com|"; $this->assertEqual($page->capture(), $expected); Limb :: restoreToolkit(); }
function testTransferFrame() { $toolkit =& Limb :: toolkit(); $request =& $toolkit->getRequest(); $request->set('p1', 'test1'); $request->set('p2', 'test2'); $template = '<limb:REQUEST_TRANSFER attributes="p1,p2">' . '<frame src="/some/path"/>' . '</limb:REQUEST_TRANSFER>'; RegisterTestingTemplate('/limb/request_transfer_frame.html', $template); $page =& new Template('/limb/request_transfer_frame.html'); $this->assertEqual($page->capture(), '<frame src="/some/path?&p1=test1&p2=test2" />'); }
function testIsNotLoggedInTag() { $toolkit =& Limb :: toolkit(); $user =& $toolkit->getUser(); $user->logout(); $template = '<limb:user:IS_NOT_LOGGED_IN>NotLogged!</limb:user:IS_NOT_LOGGED_IN>'; RegisterTestingTemplate('/limb/user_is_not_logged_in_tag.html', $template); $page =& new Template('/limb/user_is_not_logged_in_tag.html'); $this->assertEqual($page->capture(), 'NotLogged!'); }
function testRefererFormSubmittedUseCurrent() { $template = "<form id='test' runat='server'><limb:form:REFERER use_current='TRUE'></form>"; RegisterTestingTemplate('/limb/form-ref5.html', $template); $page =& new Template('/limb/form-ref5.html'); $referer = 'put-me-into-result'; $dataspace = new Dataspace(); $dataspace->set('referer', $referer); $form =& $page->getChild('test'); $form->registerDataSource($dataspace); $_SERVER['HTTP_REFERER'] = 'another-referer'; $_SERVER['REQUEST_URI'] = 'another-referer'; $result = $page->capture(); $this->assertEqual($result, "<form id=\"test\"><input type='hidden' name='referer' value='$referer'></form>"); }
function testWithNavigator() { $this->toolkit->setReturnReference('createDAO', $this->ds, array('TestDAO')); $data = array ( array ('username'=>'joe'), array ('username'=>'ivan'), ); $dataset =& new PagedArrayDataSet($data); $this->ds->expectOnce('fetch'); $this->ds->setReturnReference('fetch', $dataset); $request =& new MockRequest($this); $this->toolkit->setReturnReference('getRequest', $request); $request->setReturnValue('getUri', new Uri('test.com')); $template = '<limb:DAO target="testTarget" class="TestDAO" navigator="pagenav"></limb:DAO>' . '<list:LIST id="testTarget"><list:ITEM>{$username}</list:ITEM></list:LIST>'. '<limb:pager:NAVIGATOR id="pagenav" items="10"></limb:pager:NAVIGATOR>'; RegisterTestingTemplate('/limb/dao3.html', $template); $page =& new Template('/limb/dao3.html'); $this->assertEqual($page->capture(), 'joeivan'); $pager =& $page->findChild('pagenav'); $this->assertEqual($pager->getTotalItems(), 2); }
function testDefaultDBEForAttribute() { $template = '<form id="test_form" name="test_form" runat="server">'. '<input id="test_input" type="text" value="{$^var|LimbI18NString|uppercase}">' . '</form>'; RegisterTestingTemplate('/limb/locale_string_filter_dbe_for_attribute.html', $template); $page =& new Template('/limb/locale_string_filter_dbe_for_attribute.html'); $page->set('var', 'apply_filter'); $expected = '<form id="test_form" name="test_form">'. //please note the second value attribute! '<input id="test_input" type="text" name="test_input" value="" value="APPLY FILTER">' . '</form>'; $this->assertEqual($page->capture(), $expected); }
function testUseThousandSeparator() { $template = '<limb:locale:NUMBER locale="en" value="100000" thousand_separator=" "/>'; RegisterTestingTemplate('/limb/locale_number_thousand_separator.html', $template); $page =& new Template('/limb/locale_number_thousand_separator.html'); $this->assertEqual($page->capture(), '100 000.00'); }
function testDBEUseThousandSeparator() { $template = '{$var|LimbI18NNumber:"","en","",""," "}'; RegisterTestingTemplate('/limb/locale_number_filter_DBE_thousand_separator.html', $template); $page =& new Template('/limb/locale_number_filter_DBE_thousand_separator.html'); $page->set('var', '100000'); $this->assertEqual($page->capture(), '100 000.00'); }