コード例 #1
0
<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
$browser = new DarwinTestFunctional(new sfBrowser());
$browser->loadData($configuration)->login('root', 'evil');
$browser->setTester('doctrine', 'sfTesterDoctrine');
$people = Doctrine::getTable('People')->findOneByFamilyName('Chambert');
$reguser = $browser->addCustomUserAndLogin('reguser', 'evil');
$encoder = $browser->addCustomUserAndLogin('encoder', 'evil');
$browser->info('1 - New Loan screen')->get('/loan/new')->with('request')->begin()->isParameter('module', 'loan')->isParameter('action', 'new')->end()->info('1.1 - is everything ok on screen')->with('response')->begin()->isStatusCode(200)->checkElement('title', 'Add loan')->checkElement('.board_col', 1)->checkElement('.board_col .widget:first .widget_top_bar span', '/Loan/')->checkElement('.board_col .widget:nth-child(2) .widget_top_bar span', '/People involved/')->checkElement('.board_col .widget:nth-child(3) .widget_top_bar span', '/Loan status/')->checkElement('.board_col .widget:nth-child(4) .widget_top_bar span', '/Properties/')->checkElement('.board_col .widget:nth-child(5) .widget_top_bar span', '/Comments/')->checkElement('.board_col .widget:nth-child(6) .widget_top_bar span', '/Insurances/')->checkElement('.board_col .widget:nth-child(7) .widget_top_bar span', '/Related Files/')->checkElement('.board_col .widget:nth-child(8) .widget_top_bar span', '/Darwin Users/')->end()->click('#submit_loan', array('loans' => array('name' => 'loan for test', 'newActorsSender' => array(0 => array('people_ref' => $people->getId(), 'people_type' => 'sender', 'people_sub_type' => array(2), 'order_by' => 1)), 'newActorsReceiver' => array(0 => array('people_ref' => $people->getId(), 'people_type' => 'receiver', 'people_sub_type' => array(2, 4, 8), 'order_by' => 1)), 'newUsers' => array(0 => array('user_ref' => $reguser), 1 => array('user_ref' => $encoder, 'has_encoding_right' => 'on')))))->with('response')->begin()->isRedirected()->end()->followRedirect()->with('response')->begin()->isStatusCode(200)->info('2 - Edition screen')->checkElement('title', 'Edit loan')->checkElement('.board_col .widget:nth-child(2) .widget_top_bar tbody#sender_body tr:first td:nth-child(4)', '/Chambert Yann/')->checkElement('.board_col .widget:nth-child(2) .widget_top_bar tbody#receiver_body tr:first td:nth-child(4)', '/Chambert Yann/')->end()->info('3 - Look for our new loan in search')->post('/loan/search', array('orderby' => 'name', 'orderdir' => 'desc', 'page' => 1, 'is_choose' => 0, 'loans_filters' => array('name' => 'loan for test')))->with('response')->begin()->checkElement('table.results tbody tr td:first', '/loan for test/')->end();
コード例 #2
0
<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
$browser = new DarwinTestFunctional(new sfBrowser());
$browser->loadData($configuration)->login('root', 'evil');
$browser->info('Index')->get('/collection/index')->with('request')->begin()->isParameter('module', 'collection')->isParameter('action', 'index')->end()->with('response')->begin()->isStatusCode(200)->checkElement('h1', 'Collection List')->checkElement('h2:last', 'UGMM')->checkElement('.treelist:first > ul > li', 2)->checkElement('.treelist:first > ul > li:nth-child(2) span', '/Vertebrates/')->checkElement('.treelist:first > ul > li:nth-child(2) a img')->checkElement('.treelist:first > ul > li:nth-child(2) > ul > li', 2)->checkElement('.treelist:first > ul > li:nth-child(2) > ul > li:first span', '/Amphibia/')->checkElement('.treelist:last > ul > li', 1)->end()->info('New')->get('/collection/new')->with('request')->begin()->isParameter('module', 'collection')->isParameter('action', 'new')->end()->with('response')->begin()->isStatusCode(200)->end()->click('Save', array('collections' => array('name' => '', 'institution_ref' => '', 'collection_type' => '', 'code' => '', 'main_manager_ref' => '', 'parent_ref' => '')))->with('form')->begin()->hasErrors(5)->isError('name', 'required')->isError('code', 'required')->isError('institution_ref', 'required')->isError('collection_type', 'required')->isError('main_manager_ref', 'required')->end()->with('request')->begin()->isParameter('module', 'collection')->isParameter('action', 'create')->end()->click('Save', array('collections' => array('name' => 'Paléonotologie', 'institution_ref' => Doctrine::getTable('People')->findOneByFamilyName('Institut Royal des Sciences Naturelles de Belgique')->getId(), 'collection_type' => 'mix', 'code' => 'paleo', 'main_manager_ref' => Doctrine::getTable('Users')->findOneByFamilyName('Evil')->getId(), 'parent_ref' => '')))->followRedirect()->with('request')->begin()->isParameter('module', 'collection')->isParameter('action', 'edit')->end()->with('response')->begin()->isStatusCode(200)->end()->get('/collection/index')->info('Edit')->click('.treelist:first > ul > li:nth-child(3) > ul > li:nth-child(2) div a', array())->with('request')->begin()->isParameter('module', 'collection')->isParameter('action', 'edit')->end()->with('response')->begin()->isStatusCode(200)->checkElement('input[value="Aves"]')->end()->get('/collection/index')->with('response')->begin()->isStatusCode(200)->checkElement('.treelist:first > ul > li', 3)->checkElement('.treelist:last > ul > li', 1)->end()->info('Delete')->click('.col_name:eq(5) > a:first')->with('request')->begin()->isParameter('module', 'collection')->isParameter('action', 'edit')->end()->click('Delete')->followRedirect()->with('request')->begin()->isParameter('module', 'collection')->isParameter('action', 'index')->end()->with('response')->begin()->isStatusCode(200)->checkElement('.treelist:first > ul > li', 3)->end();
$user_id = $browser->addCustomUserAndLogin();
$collection_id = Doctrine::getTable('Collections')->getCollectionByName('Vertebrates')->getId();
$browser->info('sub collection right')->get('collection/rights/user_ref/' . $user_id . '/collection_ref/' . $collection_id)->with('request')->begin()->isParameter('module', 'collection')->isParameter('action', 'rights')->end()->with('response')->begin()->isStatusCode(200)->checkElement('.treelist:first > ul > li:first span', '/Amphibia/')->end()->click('Save', array('sub_collection' => array('SubCollectionsRights' => array(0 => array('user_ref' => $user_id, 'collection_ref' => Doctrine::getTable('Collections')->getCollectionByName('Amphibia')->getId(), 'check_right' => true), 1 => array('user_ref' => $user_id, 'collection_ref' => Doctrine::getTable('Collections')->getCollectionByName('Aves')->getId(), 'check_right' => false)))));
$browser->info('sub collection right')->get('collection/edit/id/' . Doctrine::getTable('collections')->getCollectionByName('Amphibia')->getId())->with('request')->begin()->isParameter('module', 'collection')->isParameter('action', 'edit')->end()->get('collection/edit/id/' . Doctrine::getTable('collections')->getCollectionByName('Aves')->getId())->with('request')->begin()->isParameter('module', 'collection')->isParameter('action', 'edit')->end()->with('response')->begin()->isStatusCode(200)->checkElement('#' . $user_id, null)->end();
$vertebrates = Doctrine::getTable('Collections')->findOneByName('Vertebrates');
$vertId = $vertebrates->getId();
$browser->info('Get vertebrate collection for specimen codes default values check')->get('collection/edit', array('id' => $vertId))->with('response')->begin()->isStatusCode(200)->checkElement('li#collectionsCodes div.widget_content table tbody tr', 1)->checkElement('li#collectionsCodes div.widget_content table tbody tr td', 10)->checkElement('li#collectionsCodes div.widget_content table tbody tr td:first', '/VERT./')->checkElement('li#collectionsCodes div.widget_content table tbody tr td:nth-child(9) a.link_catalogue', 1)->checkElement('li#collectionsCodes div.widget_content table tbody tr td:last a.widget_row_delete', 1)->end()->click('li#collectionsCodes div.widget_content table tbody tr td:nth-child(9) a.link_catalogue')->with('response')->begin()->isStatusCode(200)->checkElement('div#collections_codes_screen form#collections_codes_form', 1)->checkElement('div#collections_codes_screen form#collections_codes_form table tbody tr', 9)->checkElement('div#collections_codes_screen form#collections_codes_form table tbody tr:nth-child(2) td input#collections_code_prefix', 1)->checkElement('div#collections_codes_screen form#collections_codes_form table tbody tr:nth-child(3) td input#collections_code_prefix_separator', 1)->checkElement('div#collections_codes_screen form#collections_codes_form table tbody tr:nth-child(4) td input#collections_code_suffix_separator', 1)->checkElement('div#collections_codes_screen form#collections_codes_form table tbody tr:nth-child(5) td input#collections_code_suffix', 1)->checkElement('div#collections_codes_screen form#collections_codes_form table tbody tr:nth-child(6) td input#collections_code_auto_increment', 1)->checkElement('div#collections_codes_screen form#collections_codes_form table tbody tr:nth-child(7) td input#collections_code_auto_increment_for_insert_only', 1)->checkElement('div#collections_codes_screen form#collections_codes_form table tbody tr:nth-child(8) td input#collections_code_specimen_duplicate', 1)->checkElement('div#collections_codes_screen form#collections_codes_form table tbody tr:nth-child(9) td input#collections_code_mask', 1)->end()->click('a.delete_button')->with('response')->begin()->isStatusCode(200)->matches('/ok/')->end();
$vertebrates = Doctrine::getTable('Collections')->findOneByName('Vertebrates');
$browser->test()->is($vertebrates->getCodePrefix(), '', 'The code prefix has been well reset');
$collection_id = $browser->addCustomCollection('12345', 'Collection for test');
$browser->info('test if the two collector exist')->get('collection/edit?id=' . $collection_id)->with('response')->begin()->isStatusCode(200)->end();
コード例 #3
0
<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
$browser = new DarwinTestFunctional(new sfBrowser());
$browser->loadData($configuration)->login('root', 'evil');
$browser->info('Search')->get('/user/index')->with('request')->begin()->isParameter('module', 'user')->isParameter('action', 'index')->end()->with('response')->begin()->isStatusCode(200)->checkElement('.search_results_content')->checkElement('#users_filters_family_name')->end()->click('.search_submit', array('users_filters' => array('family_name' => array('text' => 'Evil'))))->with('response')->begin()->isStatusCode(200)->checkElement('.results_container')->checkElement('.results_container .results > tbody > tr', 1)->end()->get('/user/choose')->click('Search', array('users_filters' => array('family_name' => array('text' => 'sdf'))))->with('response')->begin()->isStatusCode(200)->end();
$browser->test()->like($browser->getResponse()->getContent(), '/No Matching Items/', 'Content is ok');
$browser->info('Address')->get('/user/profile')->with('response')->begin()->isStatusCode(200)->checkElement('#address tbody tr', 0)->end()->click('#address a.link_catalogue')->with('response')->begin()->isStatusCode(200)->end()->click('Save')->with('response')->begin()->isStatusCode(200)->end()->with('form')->begin()->hasErrors(2)->isError('locality', 'required')->isError('country', 'required')->end()->click('Save', array('users_addresses' => array('locality' => 'Bruxelles', 'country' => 'Belgium', 'tag' => 'home,pref')))->with('response')->begin()->isStatusCode(200)->end();
$browser->test()->like($browser->getResponse()->getContent(), '/ok/', 'Content is ok');
$browser->get('/user/profile')->with('response')->begin()->isStatusCode(200)->checkElement('#address tbody tr', 1)->checkElement('#address tbody tr .tag', 2)->end()->click('#address table tbody a.link_catalogue')->with('response')->begin()->isStatusCode(200)->checkElement('input[value="Bruxelles"]')->end()->click('a.delete_button')->with('response')->begin()->isStatusCode(200)->end();
$browser->test()->like($browser->getResponse()->getContent(), '/ok/', 'Content is ok');
$browser->info('Comm')->get('/user/profile')->with('response')->begin()->isStatusCode(200)->checkElement('#comm tbody tr', 0)->end()->click('#comm a.link_catalogue')->with('response')->begin()->isStatusCode(200)->end()->click('Save')->with('response')->begin()->isStatusCode(200)->end()->with('form')->begin()->hasErrors(1)->isError('entry', 'required')->end()->click('Save', array('users_comm' => array('entry' => '+32478.254415', 'comm_type' => 'phone/fax', 'tag' => 'home')))->with('response')->begin()->isStatusCode(200)->end();
$browser->test()->like($browser->getResponse()->getContent(), '/ok/', 'Content is ok');
$browser->get('/user/profile')->with('response')->begin()->isStatusCode(200)->checkElement('#comm tbody tr', 1)->checkElement('#comm tbody tr .tag', 'Home')->end()->click('#comm table tbody a.link_catalogue')->with('response')->begin()->isStatusCode(200)->checkElement('input[value="+32478.254415"]')->end()->click('.delete_button')->with('response')->begin()->isStatusCode(200)->end();
$browser->test()->like($browser->getResponse()->getContent(), '/ok/', 'Content is ok');
$browser->get('/user/profile')->with('response')->begin()->isStatusCode(200)->end();
$browser->addCustomUserAndLogin('ychambert', 'toto');
$browser->addCustomUserAndLogin('encoder', 'evil');
$browser->addCustomUserAndLogin('manager', 'evil');
$browser->get('account/logout')->with('response')->begin()->isRedirected()->end()->followRedirect()->with('user')->begin()->isAuthenticated(false)->end()->login('ychambert', 'toto');
$browser->info('Search')->get('/user/index')->with('request')->begin()->isParameter('module', 'user')->isParameter('action', 'index')->end()->with('response')->begin()->isStatusCode(403)->end();
$browser->info('Widget')->get('/user/widget')->with('response')->begin()->isStatusCode(200)->checkElement('tbody[alt="board_widget"] tr', 5)->end()->click('#submit', array('user_widget' => array('MyWidgets' => array(0 => array('category' => 'board_widget', 'group_name' => 'savedSearch', 'user_ref' => $id, 'widget_choice' => 'opened', 'title_perso' => 'Search'), 1 => array('category' => 'board_widget', 'group_name' => 'savedSpecimens', 'user_ref' => $id, 'widget_choice' => 'opened', 'title_perso' => 'Spec')))))->with('request')->begin()->isParameter('module', 'user')->isParameter('action', 'widget')->end();
$browser->info('users ychambert is not allowed to access to this page')->get('user/loginInfo?user_ref=' . Doctrine::getTable("Users")->findOneByFamilyName('Evil')->getId())->with('response')->begin()->isStatusCode(403)->end()->info('Prerences')->get('user/preferences')->with('response')->begin()->isStatusCode()->checkElement('h1', '/My Preferences/')->checkElement('.user_table > thead', 3)->checkElement('.user_table > tbody', 3)->checkElement('.user_table > tbody > tr', 6)->checkElement('#preferences_board_spec_rec_pp option[selected]', '10')->checkElement('#preferences_board_search_rec_pp option[selected]', '10')->end()->click('input[type="submit"]', array('preferences' => array('board_spec_rec_pp' => 5, 'board_search_rec_pp' => 5)))->with('response')->begin()->isRedirected()->end()->followRedirect()->with('response')->begin()->isStatusCode()->checkElement('h1', '/My Preferences/')->checkElement('#preferences_board_spec_rec_pp option[selected]', '5')->checkElement('#preferences_board_search_rec_pp option[selected]', '5')->end();