<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
$browser = new DarwinTestFunctional(new sfBrowser());
$browser->loadData($configuration)->login('root', 'evil');
$browser->info('executeSearch')->get('/catalogue/search?searchCatalogue[name]=falco&searchCatalogue[table]=taxonomy')->with('request')->begin()->isParameter('module', 'catalogue')->isParameter('action', 'search')->end()->with('response')->begin()->isStatusCode(200)->checkElement('table tbody tr', 9)->checkElement('tbody tr:first span', '/Falco Class/')->end()->info('executeTree');
$items = Doctrine::getTable('Taxonomy')->findByName('Falco Peregrinus (Duchesnus Brulus 1912)');
$browser->get('/catalogue/tree?table=taxonomy&id=' . $items[0]->getId())->with('response')->begin()->isStatusCode(200)->checkElement('body > div.wrapper > ul > li', 8)->checkElement('body > div.wrapper > ul li:first', '/Eucaryota/')->checkElement('body > div.wrapper > ul li:last', '/Duchesnus/')->end()->info('Relation');
$items = Doctrine::getTable('CatalogueRelationships')->getRelationsForTable('taxonomy', 4, 'current_name');
$browser->get('/catalogue/relation?type=rename&table=taxonomy&rid=4&id=' . $items[0]['id'])->with('response')->begin()->isStatusCode(200)->checkElement('label[for="catalogue_relationships_record_id_2"]', 'Renamed in')->checkElement('form')->checkElement('input[id="catalogue_relationships_record_id_2_name"][value="Falco Peregrinus Tunstall, 1771"]')->end();
$items = Doctrine::getTable('CatalogueRelationships')->getRelationsForTable('taxonomy', 4, 'recombined from');
$browser->get('/catalogue/relation?type=recombined&table=taxonomy&rid=4&id=' . $items[0]['id'])->with('response')->begin()->isStatusCode(200)->checkElement('label[for="catalogue_relationships_record_id_2"]', 'Recombined from')->checkElement('form')->checkElement('input[id="catalogue_relationships_record_id_2_name"][value="Falco Peregrinus recombinus"]')->end()->info('SaveRelation')->get('/catalogue/relation?type=recombined&table=taxonomy&rid=4')->with('response')->begin()->isStatusCode(200)->checkElement('label[for="catalogue_relationships_record_id_2"]', 'Recombined from')->checkElement('form')->checkElement('input[id="catalogue_relationships_record_id_2_name"][value=""]')->end()->click('Save', array('catalogue_relationships' => array('record_id_2' => '2', 'referenced_relation' => 'taxonomy', 'relationship_type' => 'recombined from', 'record_id_1' => '4')));
$browser->test()->like($browser->getResponse()->getContent(), '/ok/', 'Content is ok');
$items = Doctrine::getTable('CatalogueRelationships')->getRelationsForTable('taxonomy', 4, 'recombined from');
$tax = Doctrine::getTable('Taxonomy')->find($items[1]['record_id_2']);
$browser->get('/catalogue/relation?type=recombined&table=taxonomy&rid=4&id=' . $items[1]['id'])->with('response')->begin()->isStatusCode(200)->checkElement('label[for="catalogue_relationships_record_id_2"]', 'Recombined from')->checkElement('form')->checkElement('input[id="catalogue_relationships_record_id_2_name"]')->checkElement('input[id="catalogue_relationships_record_id_2_name"][value="' . $tax->getName() . '"]')->end()->info('DeleteRelated')->get('/catalogue/deleteRelated?table=catalogue_relationships&id=' . $items[1]['id'])->with('response')->begin()->isStatusCode(200)->end()->get('/catalogue/relation?type=recombined&table=taxonomy&rid=4&id=' . $items[1]['id'])->with('response')->begin()->isStatusCode(200)->checkElement('label[for="catalogue_relationships_record_id_2"]', 'Recombined from')->checkElement('form')->checkElement('#relation_catalogue_name', '')->end();
$items = Doctrine::getTable('Taxonomy')->findByName('Falco Peregrinus (Duchesnus Brulus 1912)');
$parent_item = Doctrine::getTable('Taxonomy')->findOneByLevelRef(48);
$items[0]->setParentRef($parent_item->getId());
$items[0]->save();
$browser->info('Test the possible upper levels check function')->get('/catalogue/searchPUL/table/taxonomy/level_id/' . $items[0]->getLevelRef() . '/parent_id/' . $parent_item->getId())->with('response')->begin()->isStatusCode(200)->matches('/ok/')->end()->get('/catalogue/searchPUL/table/taxonomy/level_id/20/parent_id/' . $parent_item->getId())->with('response')->begin()->isStatusCode(200)->matches('/not ok/')->end()->get('/catalogue/searchPUL/table/taxonomy/level_id/50/parent_id/' . $parent_item->getId())->with('response')->begin()->isStatusCode(200)->matches('/ok/')->end()->get('/catalogue/searchPUL/table/taxonomy/level_id/1/parent_id/' . $parent_item->getId())->with('response')->begin()->isStatusCode(200)->matches('/top/')->end();
<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
$browser = new DarwinTestFunctional(new sfBrowser());
$browser->loadData($configuration)->login('root', 'evil');
$browser->info('Index')->get('/mineralogy/index')->with('request')->begin()->isParameter('module', 'mineralogy')->isParameter('action', 'index')->end()->with('response')->begin()->isStatusCode(200)->checkElement('form#catalogue_filter table#search tbody td:first ul li input#searchCatalogue_code', 1)->checkElement('form#catalogue_filter table#search tbody td:nth-child(2) input#searchCatalogue_name', 1)->checkElement('form#catalogue_filter table#search tbody td:nth-child(2) input#searchCatalogue_table', 1)->checkElement('form#catalogue_filter table#search tbody td:nth-child(3) select#searchCatalogue_classification', 1)->checkElement('form#catalogue_filter table#search tbody td:nth-child(4) select#searchCatalogue_level_ref', 1)->checkElement('div.new_link', 1)->end()->info('Search with Dana classification -> no records encoded')->post('/catalogue/search/', array('searchCatalogue' => array('table' => 'mineralogy', 'classification' => 'dana')))->with('response')->begin()->isStatusCode(200)->matches('/no matching items/i')->end()->info('Search without criterias')->get('/mineralogy/index')->with('response')->begin()->isStatusCode('200')->end()->click('.search_submit')->with('response')->begin()->isStatusCode(200)->checkElement('div[class="pager paging_info"] table tr td:nth-child(2)', '/11/')->checkElement('table.results tbody tr:first td:nth-child(4)', '/Invalid/')->end()->info('Edit invalid record')->click('table.results tbody tr:first td.edit a:nth-child(3)')->with('response')->begin()->isStatusCode(200)->setField('mineralogy[code]', '')->setField('mineralogy[name]', '')->setField('mineralogy[level_ref]', '')->setField('mineralogy[classification]', '')->end()->click('Save')->with('form')->begin()->hasErrors(5)->isError('code', 'required')->isError('name', 'required')->isError('level_ref', 'required')->isError('classification', 'required')->isError('color', 'required')->setField('mineralogy[code]', '5.AA')->setField('mineralogy[name]', 'Proutprout')->setField('mineralogy[level_ref]', '72')->setField('mineralogy[classification]', 'Bouc')->setField('mineralogy[color]', '#555555')->end()->click('Save')->with('form')->begin()->hasErrors(1)->isError('classification', 'invalid')->setField('mineralogy[classification]', 'strunz')->end()->click('Save')->info('Test the record has been saved in DB');
$unit = Doctrine::getTable('mineralogy')->findOneByName('Proutprout');
$browser->test()->is($unit->getName(), 'Proutprout', 'We have the modified unit');
$browser->info('Create a new record and save it then test its existence in DB')->get('mineralogy/new')->with('response')->begin()->isStatusCode('200')->end()->click('Save', array('mineralogy' => array('code' => '5.AAH', 'color' => '#554554', 'name' => 'Paxien', 'level_ref' => '73', 'parent_ref' => $unit->getId())));
$unit = Doctrine::getTable('mineralogy')->findOneByName('Paxien');
$browser->test()->is($unit->getName(), 'Paxien', 'We have the new encoded unit');
<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
$browser = new DarwinTestFunctional(new sfBrowser());
$browser->loadData($configuration)->login('root', 'evil');
$browser->info('Index')->get('/people/index')->with('request')->begin()->isParameter('module', 'people')->isParameter('action', 'index')->end()->with('response')->begin()->isStatusCode(200)->checkElement('.search_results_content')->checkElement('#people_filters_family_name')->end()->click('.search_submit', array('people_filters' => array('family_name' => 'poil', 'is_physical' => 1)))->with('response')->begin()->isStatusCode(200)->checkElement('.results_container')->checkElement('.results_container .results > tbody > tr', 2)->checkElement('.results_container .results > tbody > tr.hidden', 1)->end()->get('/people/index')->click('.search_submit', array('people_filters' => array('family_name' => 'ntol', 'is_physical' => 1)))->with('response')->begin()->isStatusCode(200)->end();
$browser->test()->like($browser->getResponse()->getContent(), '/No Matching Items/', 'Content is ok');
$browser->get('/people/index')->click('New')->with('response')->begin()->isStatusCode(200)->end()->click('Save', array('people' => array('family_name' => '', 'additional_names' => '')))->with('form')->begin()->hasErrors(1)->isError('family_name', 'required')->end()->click('Save', array('people' => array('family_name' => 'Dupont', 'additional_names' => 'jr')))->with('response')->begin()->isRedirected()->end()->followRedirect();
$nitems = Doctrine::getTable('People')->findByAdditionalNames('jr');
$browser->test()->is($nitems[0]->getFamilyName(), 'Dupont', 'We have the new encoded people');
$browser->with('request')->begin()->isParameter('module', 'people')->isParameter('action', 'edit')->end()->with('response')->begin()->isStatusCode(200)->end()->click('Save', array('people' => array('family_name' => 'Dupond', 'additional_names' => 'jr')))->with('response')->begin()->isRedirected()->end()->followRedirect()->with('request')->begin()->isParameter('module', 'people')->isParameter('action', 'edit')->end()->with('response')->begin()->isStatusCode(200)->checkElement('input[value="Dupond"]')->end()->click('Delete')->with('response')->begin()->isRedirected()->end()->followRedirect()->with('request')->begin()->isParameter('module', 'people')->isParameter('action', 'index')->end()->with('response')->begin()->isStatusCode(200)->end();
$nitems = Doctrine::getTable('People')->findByAdditionalNames('jr');
$browser->test()->is($nitems->count(), 0, 'We have no matching people');
$browser->info('Address')->click('.search_submit', array('people_filters' => array('family_name' => 'poil', 'is_physical' => 1)))->click('td.edit a:nth-child(2)')->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('people_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('/people/index')->click('.search_submit', array('people_filters' => array('family_name' => 'poil', 'is_physical' => 1)))->click('td.edit a:nth-child(2)')->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('.delete_button')->with('response')->begin()->isStatusCode(200)->end();
$browser->test()->like($browser->getResponse()->getContent(), '/ok/', 'Content is ok');
$browser->info('Comm')->get('/people/index')->click('.search_submit', array('people_filters' => array('family_name' => 'poil', 'is_physical' => 1)))->click('td.edit a:nth-child(2)')->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('people_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('/people/index')->click('.search_submit', array('people_filters' => array('family_name' => 'poil', 'is_physical' => 1)))->click('td.edit a:nth-child(2)')->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->info('Relation')->get('/people/index')->click('.search_submit', array('people_filters' => array('family_name' => 'poil', 'is_physical' => 1)))->click('td.edit a:nth-child(2)')->with('response')->begin()->isStatusCode(200)->checkElement('#relation tbody tr', 0)->end()->click('#relation a.link_catalogue')->with('response')->begin()->isStatusCode(200)->end()->click('Save')->with('response')->begin()->isStatusCode(200)->end()->with('form')->begin()->hasErrors(1)->isError('person_1_ref', 'required')->end();
$nitems = Doctrine::getTable('Institutions')->findOneByFamilyName('UGMM');
$browser->click('Save', array('people_relationships' => array('person_1_ref' => $nitems->getId(), 'relationship_type' => 'work for', 'person_user_role' => 'Manager')))->with('response')->begin()->isStatusCode(200)->end();
$browser->test()->like($browser->getResponse()->getContent(), '/ok/', 'Content is ok');
$browser->get('/people/index')->click('.search_submit', array('people_filters' => array('family_name' => 'poil', 'is_physical' => 1)))->click('td.edit a:nth-child(2)')->with('response')->begin()->isStatusCode(200)->checkElement('#relation tbody tr', 1)->end()->click('#relation table tbody a.link_catalogue')->with('response')->begin()->isStatusCode(200)->checkElement('input[value="Manager"]')->end()->click('.delete_button')->with('response')->begin()->isStatusCode(200)->end();
$browser->test()->like($browser->getResponse()->getContent(), '/ok/', 'Content is ok');
$browser->info('Lang')->get('/people/index')->click('.search_submit', array('people_filters' => array('family_name' => 'poil', 'is_physical' => 1)))->click('td.edit a:nth-child(2)')->with('response')->begin()->isStatusCode(200)->checkElement('#lang tbody tr', 0)->end()->click('#lang a.link_catalogue')->with('response')->begin()->isStatusCode(200)->end()->click('Save', array('people_languages' => array('language_country' => 'ddddddd', 'mother' => '')))->with('response')->begin()->isStatusCode(200)->end()->with('form')->begin()->hasErrors(1)->isError('language_country', 'invalid')->end();
$browser->click('Save', array('people_languages' => array('language_country' => 'am', 'mother' => 'yes', 'preferred_language' => 'yes')))->with('response')->begin()->isStatusCode(200)->end();
$browser->test()->like($browser->getResponse()->getContent(), '/ok/', 'Content is ok');
$browser->get('/people/index')->click('.search_submit', array('people_filters' => array('family_name' => 'poil', 'is_physical' => 1)))->click('td.edit a:nth-child(2)')->with('response')->begin()->isStatusCode(200)->checkElement('#lang tbody tr', 1)->checkElement('#lang tbody tr td:first', '/Preferred/')->end()->click('#lang .widget_content > a.link_catalogue')->click('Save', array('people_languages' => array('language_country' => 'fr', 'mother' => '', 'preferred_language' => 'yes')))->with('response')->begin()->isStatusCode(200)->end();
<?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();
<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
$browser = new DarwinTestFunctional(new sfBrowser());
$browser->loadData($configuration)->login('root', 'evil');
$browser->info('Index')->get('/comment/comment?id=4&table=taxonomy')->with('request')->begin()->isParameter('module', 'comment')->isParameter('action', 'comment')->end()->with('response')->begin()->isStatusCode(200)->checkElement('.delete_button', false)->checkElement('textarea', '')->end()->click('Save', array('comments' => array('referenced_relation' => 'taxonomy', 'record_id' => '4', 'notion_concerned' => 'taxon life history', 'comment' => 'This is ok...
There is a thing')))->with('request')->begin()->isParameter('module', 'comment')->isParameter('action', 'comment')->end();
$browser->test()->like($browser->getResponse()->getContent(), '/ok/', 'Content is ok');
$item = Doctrine_Query::create()->from('Comments c')->andWhere("c.referenced_relation = 'taxonomy'")->andWhere("c.notion_concerned = 'taxon life history' ")->andWhere('c.record_id=4')->fetchOne();
$browser->test()->isnt($item, null, 'We add an item');
$browser->info('Update')->get('/comment/comment?id=4&table=taxonomy&cid=' . $item->getId())->with('request')->begin()->isParameter('module', 'comment')->isParameter('action', 'comment')->end()->with('response')->begin()->isStatusCode(200)->checkElement('.delete_button')->checkElement('textarea', '/There is a thing/')->end()->click('Save', array('comments' => array('referenced_relation' => 'taxonomy', 'record_id' => '4', 'notion_concerned' => 'taxon life history', 'comment' => 'This is not ok...')))->with('request')->begin()->isParameter('module', 'comment')->isParameter('action', 'comment')->end();
$browser->test()->like($browser->getResponse()->getContent(), '/ok/', 'Content is ok');
$browser->get('/comment/comment?id=4&table=taxonomy&cid=' . $item->getId())->with('request')->begin()->isParameter('module', 'comment')->isParameter('action', 'comment')->end()->with('response')->begin()->isStatusCode(200)->checkElement('.delete_button')->checkElement('textarea', 'This is not ok...')->end()->info('Delete')->click('.delete_button')->with('response')->begin()->isStatusCode(200)->end();
$browser->test()->like($browser->getResponse()->getContent(), '/ok/', 'Content is ok');
$item = Doctrine_Query::create()->from('Comments c')->andWhere("c.referenced_relation = 'taxonomy'")->andWhere("c.notion_concerned = 'taxon life history' ")->andWhere('c.record_id=4')->fetchOne();
$browser->test()->is($item, null, 'there is no more item');
<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
$browser = new DarwinTestFunctional(new sfBrowser());
$browser->loadData($configuration)->login('root', 'evil');
$browser->get('/cataloguepeople/people?table=taxonomy&rid=3')->with('request')->begin()->isParameter('module', 'cataloguepeople')->isParameter('action', 'people')->end()->with('response')->begin()->isStatusCode(200)->checkElement('form')->checkElement('#catalogue_people_people_type option', 2)->checkElement('.tab_choice li', 2)->end()->click('Save')->with('form')->begin()->hasErrors(1)->isError('people_ref', 'required')->end();
$people = Doctrine::getTable('People')->findOneByFamilyName('Root');
$browser->click('Save', array('catalogue_people' => array('people_type' => 'expert', 'people_sub_type' => 'Main', 'record_id' => '3', 'people_ref' => $people->getId(), 'referenced_relation' => 'taxonomy')))->with('form')->begin()->hasErrors(0)->end();
$browser->test()->like($browser->getResponse()->getContent(), '/ok/', 'Content is ok');
$rbins = Doctrine::getTable('People')->findOneByFamilyName('Institut Royal des Sciences Naturelles de Belgique');
$rbins->save();
$browser->get('/cataloguepeople/people?table=taxonomy&rid=3')->click('Save', array('catalogue_people' => array('people_type' => 'author', 'people_sub_type' => 'Main', 'record_id' => '3', 'people_ref' => $rbins->getId(), 'referenced_relation' => 'taxonomy')))->with('form')->begin()->hasErrors(0)->end();
$browser->test()->like($browser->getResponse()->getContent(), '/ok/', 'Content is ok');
$browser->get('/widgets/reloadContent?widget=cataloguePeople&category=catalogue_taxonomy&eid=3')->with('response')->begin()->isStatusCode(200)->checkElement('table tr:nth-child(1) .widget_sub_table tbody tr', 2)->checkElement('table tr:nth-child(1) .widget_sub_table tbody tr:first td:nth-child(2)', '/Root/')->checkElement('table tr:nth-child(1) .widget_sub_table tbody tr:last td:nth-child(2)', '/Institut Royal des Sciences Naturelles de Belgique/')->end();
$rbins_recId = Doctrine_Query::create()->from('CataloguePeople c')->where('c.people_ref = ?', $rbins->getId())->andWhere('c.people_type=?', 'author')->fetchOne();
$root_recId = Doctrine_Query::create()->from('CataloguePeople c')->where('c.people_ref = ?', $people->getId())->andWhere('c.people_type=?', 'author')->fetchOne();
$browser->get('/cataloguepeople/editOrder?table=taxonomy&rid=3&people_type=author&order=' . $rbins_recId->getId() . ',' . $root_recId->getId() . ',')->with('response')->begin()->isStatusCode(200)->end();
$browser->test()->like($browser->getResponse()->getContent(), '/ok/', 'Content is ok');
$browser->get('/widgets/reloadContent?widget=cataloguePeople&category=catalogue_taxonomy&eid=3')->with('response')->begin()->isStatusCode(200)->checkElement('table tr:nth-child(1) .widget_sub_table tbody tr', 2)->checkElement('table tr:nth-child(1) .widget_sub_table tbody tr:first td:nth-child(2)', '/Institut Royal des Sciences Naturelles de Belgique/')->checkElement('table tr:nth-child(1) .widget_sub_table tbody tr:last td:nth-child(2)', '/Root/')->end();
$browser->get('/cataloguepeople/getSubType?type=author')->with('response')->begin()->isStatusCode(200)->end();
$browser->test()->like($browser->getResponse()->getContent(), '/Secondary Author/', 'Content is ok');
$browser->test()->like($browser->getResponse()->getContent(), '/Corrector/', 'Content is ok');
$browser->get('/cataloguepeople/getSubType?type=expert')->with('response')->begin()->isStatusCode(200)->end();
$browser->test()->like($browser->getResponse()->getContent(), '/Main/', 'Content is ok');
<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
$browser = new DarwinTestFunctional(new sfBrowser());
$browser->loadData($configuration)->login('root', 'evil');
$browser->info('Index')->get('/igs/index')->with('response')->begin()->isStatusCode()->checkElement('h1', 'General Inventory Numbers Search')->checkElement('#searchIg_ig_num', '')->checkElement('#searchIg_from_date_day > option:first_element', 'dd')->checkElement('#searchIg_from_date_month > option:first_element', 'mm')->checkElement('#searchIg_from_date_year > option:first_element', 'yyyy')->checkElement('#searchIg_to_date_day > option:first_element', 'dd')->checkElement('#searchIg_to_date_month > option:first_element', 'mm')->checkElement('#searchIg_to_date_year > option:first_element', 'yyyy')->checkElement('form input[type="submit"]', 1)->setField('#searchIg_from_date_month', '10')->end()->info('Post waiting for a "Year missing" error')->post('/igs/search', array('searchIg' => array('from_date' => array('month' => 10))))->with('response')->begin()->isStatusCode()->checkElement('.error_list li', 'Year missing.')->end()->info('Post waiting for a "Month missing" error')->post('/igs/search', array('searchIg' => array('from_date' => array('day' => 2, 'year' => 1975))))->with('response')->begin()->isStatusCode()->checkElement('.error_list li', 'Month missing or remove the day and time.')->end()->info('Post waiting for the full results table and the pager')->post('/igs/search', array('is_choose' => 0, 'searchIg' => array('ig_num' => '', 'from_date' => '', 'to_date' => '')))->with('response')->begin()->isStatusCode()->checkElement('ul.pager_nav li', 10)->checkElement('ul.pager_nav li.page_selected', '[1]')->checkElement('.pager li a span.nav_arrow', 0)->checkElement('div.paging_info table td:nth-child(2)', 1)->checkElement('div.paging_info table td:last-child select[id="searchIg_rec_per_page"]', 1)->checkElement('table.results tbody tr', 7)->checkElement('table.results thead th:first_element a.sort span.order_sign_down')->end()->info('Click to sort on name descending...')->post('/igs/search', array('orderby' => 'ig_num', 'orderdir' => 'desc', 'page' => 1, 'is_choose' => 0, 'searchIg' => array('ig_num' => '', 'from_date' => '', 'to_date' => '')))->with('response')->begin()->checkElement('table.results thead th:first_element a.sort span.order_sign_up')->end()->info('Select a number of 5 records per pages and test existence of links in pager')->post('/igs/search', array('orderby' => 'ig_num', 'orderdir' => 'desc', 'page' => 1, 'is_choose' => 0, 'searchIg' => array('rec_per_page' => 5, 'ig_num' => '', 'from_date' => '', 'to_date' => '')))->with('response')->begin()->checkElement('.pager_nav .pager_separator')->checkElement('.pager_nav li a span.nav_arrow', 4)->checkElement('table.results tbody tr', 5)->end()->info('Select page 2')->post('/igs/search', array('orderby' => 'ig_num', 'orderdir' => 'desc', 'page' => 2, 'is_choose' => 0, 'searchIg' => array('rec_per_page' => 5, 'ig_num' => '', 'from_date' => '', 'to_date' => '')))->with('response')->begin()->checkElement('.pager .pager_separator')->checkElement('ul.pager_nav li.page_selected', '[2]')->checkElement('.pager_nav li a span.nav_arrow', 4)->checkElement('table.results tbody tr', 2)->end()->info('Search on IG num "26" like')->post('/igs/search', array('orderby' => 'ig_num', 'orderdir' => 'desc', 'page' => 1, 'is_choose' => 0, 'searchIg' => array('ig_num' => '26', 'from_date' => '', 'to_date' => '')))->with('response')->begin()->checkElement('table.results tbody tr', 4)->end()->info('Search on IG from 1900')->post('/igs/search', array('orderby' => 'ig_num', 'orderdir' => 'desc', 'page' => 1, 'is_choose' => 0, 'searchIg' => array('ig_num' => '', 'from_date' => array('day' => '', 'month' => '', 'year' => '1900'), 'to_date' => '')))->with('response')->begin()->checkElement('table.results tbody tr', 1)->end()->info('Search on IG from 01/01/1877')->post('/igs/search', array('orderby' => 'ig_num', 'orderdir' => 'desc', 'page' => 1, 'is_choose' => 0, 'searchIg' => array('ig_num' => '', 'from_date' => array('day' => '01', 'month' => '01', 'year' => '1877'), 'to_date' => '')))->with('response')->begin()->checkElement('table.results tbody tr', 2)->end()->info('Search on IG num up to 01/01/1878')->post('/igs/search', array('orderby' => 'ig_num', 'orderdir' => 'desc', 'page' => 1, 'is_choose' => 0, 'searchIg' => array('ig_num' => '', 'to_date' => array('day' => '01', 'month' => '01', 'year' => '1878'), 'from_date' => '')))->with('response')->begin()->checkElement('table.results tbody tr', 3)->end()->info('Get new record')->get('/igs/index')->click('New')->with('response')->begin()->isStatusCode()->checkElement('h1', 'New I.G. number')->checkElement('h1[class="edit_mode"]', true)->checkElement('form[class="edition"]', true)->checkElement('#igs_ig_date_day > option:first_element', 'dd')->checkElement('#igs_ig_date_month > option:first_element', 'mm')->checkElement('#igs_ig_date_year > option:first_element', 'yyyy')->checkElement('form a', 'Cancel')->checkElement('form input[type="submit"][value="Save"]', 1)->end()->info('Try to save without data')->click('Save', array('igss' => array('ig_num' => '', 'ig_date' => '')))->with('form')->begin()->hasErrors(1)->isError('ig_num', 'required')->end()->info('Try to save with only "Year missing" error')->click('Save', array('igs' => array('ig_num' => 'Pollux', 'ig_date' => array('day' => '', 'month' => '05', 'year' => ''))))->with('form')->begin()->hasErrors(1)->isError('ig_date', 'year_missing')->end()->info('Try to save with only "Month missing" error')->click('Save', array('igs' => array('ig_num' => 'Pollux', 'ig_date' => array('day' => '05', 'month' => '', 'year' => '2000'))))->with('form')->begin()->hasErrors(1)->isError('ig_date', 'month_missing')->end()->info('Save with correct data and check everything was saved correctly')->click('Save', array('igs' => array('ig_num' => 'Pollux', 'ig_date' => array('day' => '05', 'month' => '12', 'year' => '2000'))))->with('response')->begin()->isRedirected()->end()->followRedirect()->with('request')->begin()->isParameter('module', 'igs')->isParameter('action', 'edit')->end()->with('response')->begin()->checkElement('form input[name="igs[ig_num]"][value="Pollux"]', 1)->checkElement('form table tfoot a:first', 'New I.G.')->checkElement('form table tfoot a:nth-child(4)', 'Cancel')->checkElement('form table tfoot a:nth-child(5)', 'Delete')->checkElement('li[class="widget"][id="comment"]', 1)->checkElement('li[class="widget"][id="comment"] div[class="widget_content hidden"]', 1)->checkElement('li[class="widget"][id="insurances"]', 1)->checkElement('li[class="widget"][id="insurances"] div[class="widget_content hidden"]', 1)->end();
$items = Doctrine::getTable('Igs')->findByIgNum('Pollux');
$browser->info('Check new record has been saved in DB')->test()->is($items[0]->getIgNum(), 'Pollux', 'We have the new encoded IG');
$browser->test()->is($items[0]->getIgDate(), array('year' => 2000, 'month' => 12, 'day' => 5, 'hour' => '', 'minute' => '', 'second' => ''), 'We have the new encoded IG');
$browser->info('Test the delete action...')->get('/igs/edit/id/' . $items[0]->getId())->click('Delete')->with('response')->begin()->isRedirected()->end()->followRedirect()->with('request')->begin()->isParameter('module', 'igs')->isParameter('action', 'index')->end();
$items = Doctrine::getTable('Igs')->findByIgNum('Pollux');
$browser->test()->is($items->count(), 0, 'IG well deleted');
<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
$browser = new DarwinTestFunctional(new sfBrowser());
$browser->loadData($configuration)->login('root', 'evil');
$browser->info('Checks')->get('/synonym/checks?table=taxonomy&id=4&type=synonym')->with('response')->begin()->isStatusCode(200)->matches('/1/')->end()->get('/synonym/checks?table=taxonomy&id=5&type=isonym')->with('response')->begin()->isStatusCode(200)->matches('/0/')->end()->info('Add')->get('/synonym/add?table=taxonomy&id=4')->with('request')->begin()->isParameter('module', 'synonym')->isParameter('action', 'add')->end()->with('response')->begin()->isStatusCode(200)->checkElement('#syn_screen form.edition')->checkElement('#syn_screen form.edition')->checkElement('.merge_question')->checkElement('.search_box')->checkElement('#classification_synonymies_group_name option', 4)->end()->click('Save', array('classification_synonymies' => array('group_name' => 'synonym', 'order_by' => '0', 'merge' => '0', 'referenced_relation' => 'taxonomy')))->with('form')->begin()->hasErrors(2)->isError('merge', 'invalid')->isError('record_id', 'required')->end()->click('Save', array('classification_synonymies' => array('group_name' => 'synonym', 'order_by' => '0', 'record_id' => '2', 'merge' => '1', 'referenced_relation' => 'taxonomy')))->with('form')->begin()->hasErrors(false)->end()->with('response')->begin()->isStatusCode(200)->matches('/ok/')->end();
$syn = Doctrine::getTable('ClassificationSynonymies')->findByGroupId(3);
$browser->test()->is(count($syn), 4, 'There are 4 synonyms');
$browser->info('Edit')->get('/widgets/reloadContent?widget=synonym&category=catalogue_taxonomy&eid=4')->with('response')->begin()->isStatusCode(200)->checkElement('table[alt="synonym"] tbody tr', 4)->checkElement('table[alt="synonym"] tbody tr:first td:contains(\'Duchesnus\')')->checkElement('table[alt="synonym"] tbody tr:last td:contains(\'eliticus\')')->checkElement('table[alt="synonym"] tbody tr:first .widget_row_delete img')->checkElement('table[alt="synonym"] tbody tr:last .widget_row_delete img', false)->end()->post('/synonym/editOrder?order=3,6,2,7,')->with('response')->begin()->isStatusCode(200)->matches('/ok/')->end()->get('/widgets/reloadContent?widget=synonym&category=catalogue_taxonomy&eid=4')->with('response')->begin()->isStatusCode(200)->checkElement('table[alt="synonym"] tbody tr', 4)->checkElement('table[alt="synonym"] tbody tr:last td:contains(\'eliticus\')')->checkElement('table[alt="synonym"] tbody tr:first td:contains(\'recombinus\')')->checkElement('table[alt="synonym"] tbody tr.syn_id_2 .widget_row_delete img')->checkElement('table[alt="synonym"] tbody tr:first .widget_row_delete img', false)->end()->info('Delete')->get('/synonym/delete?table=taxonomy&id=3')->with('response')->begin()->isStatusCode(200)->matches('/ok/')->end();
$syn = Doctrine::getTable('ClassificationSynonymies')->findByGroupId(3);
$browser->test()->is(count($syn), 3, 'One synonym is deleted');
<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
$browser = new DarwinTestFunctional(new sfBrowser());
$browser->loadData($configuration)->login('root', 'evil');
$browser->info('Index')->get('/institution/index')->with('request')->begin()->isParameter('module', 'institution')->isParameter('action', 'index')->end()->with('response')->begin()->isStatusCode(200)->checkElement('.search_results_content')->checkElement('#institutions_filters_family_name')->end()->click('.search_submit', array('institutions_filters' => array('family_name' => 'royal', 'is_physical' => 0)))->with('response')->begin()->isStatusCode(200)->checkElement('.results_container')->checkElement('.results_container tbody tr', 1)->end()->get('/institution/index')->click('.search_submit', array('institutions_filters' => array('family_name' => 'ntol', 'is_physical' => 0)))->with('response')->begin()->isStatusCode(200)->end();
$browser->test()->like($browser->getResponse()->getContent(), '/No Matching Items/', 'Content is ok');
$browser->get('/institution/index')->click('New')->with('response')->begin()->isStatusCode(200)->end()->click('Save', array('institutions' => array('family_name' => '', 'additional_names' => '', 'sub_type' => '')))->with('form')->begin()->hasErrors(1)->isError('family_name', 'required')->end()->click('Save', array('institutions' => array('family_name' => 'Banque Bruxelles Lambert', 'additional_names' => 'BBL', 'sub_type' => 'inc')))->with('response')->begin()->isRedirected()->end()->followRedirect();
$nitems = Doctrine::getTable('Institutions')->findByAdditionalNames('BBL');
$browser->test()->is($nitems[0]->getFamilyName(), 'Banque Bruxelles Lambert', 'We have the new encoded institution');
$browser->with('request')->begin()->isParameter('module', 'institution')->isParameter('action', 'edit')->end()->with('response')->begin()->isStatusCode(200)->end()->click('Save', array('institutions' => array('family_name' => 'Ing', 'additional_names' => 'Ing', 'sub_type' => 'inc')))->with('response')->begin()->isRedirected()->end()->followRedirect()->with('request')->begin()->isParameter('module', 'institution')->isParameter('action', 'edit')->end()->with('response')->begin()->isStatusCode(200)->checkElement('input[value="Ing"]')->end()->click('Delete')->with('response')->begin()->isRedirected()->end()->followRedirect()->with('request')->begin()->isParameter('module', 'institution')->isParameter('action', 'index')->end()->with('response')->begin()->isStatusCode(200)->end();
$nitems = Doctrine::getTable('Institutions')->findByAdditionalNames('Ing');
$browser->test()->is($nitems->count(), 0, 'We have no matching institutions');
<?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();
<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
$browser = new DarwinTestFunctional(new sfBrowser());
$browser->loadData($configuration)->login('root', 'evil');
$browser->info('Can\'t edit -1')->get('/taxonomy/edit?id=-1')->with('response')->begin()->isStatusCode(200)->end()->get('/taxonomy/index')->with('request')->begin()->isParameter('module', 'taxonomy')->isParameter('action', 'index')->end()->with('response')->begin()->isStatusCode(200)->checkElement('.search_results_content')->end()->get('/taxonomy/new/')->with('response')->begin()->isStatusCode(200)->end()->click('Save', array('taxonomy' => array('name' => '', 'level_ref' => '', 'status' => '', 'extinct' => '', 'parent_ref' => '')))->with('form')->begin()->hasErrors(4)->isError('name', 'required')->isError('level_ref', 'required')->isError('status', 'required')->isError('parent_ref', 'required')->end()->click('Save', array('taxonomy' => array('name' => 'tchet savadje (tchantchès 1830)', 'level_ref' => '48', 'status' => 'valid', 'extinct' => '', 'parent_ref' => '11')))->with('response')->begin()->isRedirected()->end()->followRedirect();
$nitems = Doctrine::getTable('Taxonomy')->findByName('tchet savadje (tchantchès 1830)');
$browser->test()->is($nitems[0]->getName(), 'tchet savadje (tchantchès 1830)', 'We have the new encoded taxa');
$browser->with('request')->begin()->isParameter('module', 'taxonomy')->isParameter('action', 'edit')->end()->with('response')->begin()->isStatusCode(200)->end()->click('Save', array('taxonomy' => array('name' => 'tchet savadje (tchantchès 1830)', 'level_ref' => '48', 'status' => 'valid', 'extinct' => '', 'parent_ref' => '11')))->with('response')->begin()->isRedirected()->end()->followRedirect()->with('request')->begin()->isParameter('module', 'taxonomy')->isParameter('action', 'edit')->end()->with('response')->begin()->isStatusCode(200)->checkElement('input[value="tchet savadje (tchantchès 1830)"]')->checkElement('div#taxonomy_parent_ref_warning', 1)->checkElement('table.classifications_edit tfoot tr td input#taxonomy_id', 1)->checkElement('table.classifications_edit tfoot tr td input#taxonomy_table', 1)->checkElement('table.classifications_edit tfoot tr td a#searchPUL', 1)->end()->click('Delete')->with('response')->begin()->isRedirected()->end()->followRedirect()->with('request')->begin()->isParameter('module', 'taxonomy')->isParameter('action', 'index')->end();
$nitems = Doctrine::getTable('Taxonomy')->findByName('tchet savadje (tchantchès 1830)');
$browser->test()->is($nitems->count(), 0, 'We have no matching taxa');
$item = Doctrine::getTable('Taxonomy')->findOneByStatusAndLevelRef('invalid', 49);
$browser->info('Mimic the parenty set of the only invalid taxon of level sub_species')->get('/taxonomy/choose?level=' . $item->getLevelRef() . '&caller_id=' . $item->getId())->with('response')->begin()->isStatusCode(200)->checkElement('form select option', 5)->checkElement('form select option:last[text="species"]', true)->checkElement('form input[id="searchCatalogue_table"][value="taxonomy"]', true)->checkElement('form input[id="searchCatalogue_level"][value="49"]', true)->end()->info('Check that the results when clicking on search retrieve the only "one" species encoded')->click('Search')->with('response')->begin()->checkElement('table.results tbody tr', 1)->end();
<?php

include dirname(__FILE__) . '/../../bootstrap/functional.php';
$browser = new DarwinTestFunctional(new sfBrowser());
$browser->loadData($configuration)->login('root', 'evil');
$browser->info('Index')->get('/expedition/index')->with('response')->begin()->isStatusCode()->checkElement('h1', 'Expedition Search')->checkElement('#searchExpedition_name', '')->checkElement('#searchExpedition_expedition_from_date_day > option:first_element', 'dd')->checkElement('#searchExpedition_expedition_from_date_month > option:first_element', 'mm')->checkElement('#searchExpedition_expedition_from_date_year > option:first_element', 'yyyy')->checkElement('#searchExpedition_expedition_to_date_day > option:first_element', 'dd')->checkElement('#searchExpedition_expedition_to_date_month > option:first_element', 'mm')->checkElement('#searchExpedition_expedition_to_date_year > option:first_element', 'yyyy')->checkElement('form input[type="submit"]', 1)->setField('#searchExpedition_expedition_from_date_month', '10')->end()->info('Post waiting for a "Year missing" error')->post('/expedition/search', array('searchExpedition' => array('expedition_from_date' => array('month' => 10))))->with('response')->begin()->isStatusCode()->checkElement('.error_list li', 'Year missing.')->end()->info('Post waiting for a "Month missing" error')->post('/expedition/search', array('searchExpedition' => array('expedition_from_date' => array('day' => 2, 'year' => 1975))))->with('response')->begin()->isStatusCode()->checkElement('.error_list li', 'Month missing or remove the day and time.')->end()->info('Post waiting for the full results table and the pager')->post('/expedition/search', array('is_choose' => 0, 'searchExpedition' => array('name' => '', 'expedition_from_date' => '', 'expedition_to_date' => '')))->with('response')->begin()->isStatusCode()->checkElement('ul.pager_nav li', 10)->checkElement('ul.pager_nav li.page_selected', '[1]')->checkElement('.pager li a span.nav_arrow', 0)->checkElement('div.paging_info table td:nth-child(2)', 1)->checkElement('div.paging_info table td:last-child select[id="searchExpedition_rec_per_page"]', 1)->checkElement('table.results tbody tr', 8)->checkElement('table.results thead th:first_element a.sort span.order_sign_down')->end()->info('Click to sort on name descending...')->post('/expedition/search', array('orderby' => 'name', 'orderdir' => 'desc', 'page' => 1, 'is_choose' => 0, 'searchExpedition' => array('name' => '', 'expedition_from_date' => '', 'expedition_to_date' => '')))->with('response')->begin()->checkElement('table.results thead th:first_element a.sort span.order_sign_up')->end()->info('Select a number of 5 records per pages and test existence of links in pager')->post('/expedition/search', array('orderby' => 'name', 'orderdir' => 'desc', 'page' => 1, 'is_choose' => 0, 'searchExpedition' => array('rec_per_page' => 5, 'name' => '', 'expedition_from_date' => '', 'expedition_to_date' => '')))->with('response')->begin()->checkElement('.pager_nav .pager_separator')->checkElement('.pager_nav li a span.nav_arrow', 4)->checkElement('table.results tbody tr', 5)->end()->info('Select page 2')->post('/expedition/search', array('orderby' => 'name', 'orderdir' => 'desc', 'page' => 2, 'is_choose' => 0, 'searchExpedition' => array('rec_per_page' => 5, 'name' => '', 'expedition_from_date' => '', 'expedition_to_date' => '')))->with('response')->begin()->checkElement('.pager .pager_separator')->checkElement('ul.pager_nav li.page_selected', '[2]')->checkElement('.pager_nav li a span.nav_arrow', 4)->checkElement('table.results tbody tr', 3)->end()->info('Search on Expedition name "Antar" like')->post('/expedition/search', array('orderby' => 'name', 'orderdir' => 'desc', 'page' => 1, 'is_choose' => 0, 'searchExpedition' => array('name' => 'Antar', 'expedition_from_date' => '', 'expedition_to_date' => '')))->with('response')->begin()->checkElement('table.results tbody tr', 1)->end()->info('Search on Expedition from 2004')->post('/expedition/search', array('orderby' => 'name', 'orderdir' => 'desc', 'page' => 1, 'is_choose' => 0, 'searchExpedition' => array('name' => '', 'expedition_from_date' => array('day' => '', 'month' => '', 'year' => '2004'), 'expedition_to_date' => '')))->with('response')->begin()->checkElement('table.results tbody tr', 3)->end()->info('Search on Expedition from 24/12/2002')->post('/expedition/search', array('orderby' => 'name', 'orderdir' => 'desc', 'page' => 1, 'is_choose' => 0, 'searchExpedition' => array('name' => '', 'expedition_from_date' => array('day' => '24', 'month' => '12', 'year' => '2002'), 'expedition_to_date' => '')))->with('response')->begin()->checkElement('table.results tbody tr', 4)->end()->info('Search on Expedition from 25/12/2002')->post('/expedition/search', array('orderby' => 'name', 'orderdir' => 'desc', 'page' => 1, 'is_choose' => 0, 'searchExpedition' => array('name' => '', 'expedition_from_date' => array('day' => '25', 'month' => '12', 'year' => '2002'), 'expedition_to_date' => '')))->with('response')->begin()->checkElement('table.results tbody tr', 3)->end()->info('Get new record')->get('/expedition/index')->click('New')->with('response')->begin()->isStatusCode()->checkElement('h1', 'New Expedition')->checkElement('h1[class="edit_mode"]', true)->checkElement('form[class="edition"]', true)->checkElement('#expeditions_expedition_from_date_day > option:first_element', 'dd')->checkElement('#expeditions_expedition_from_date_month > option:first_element', 'mm')->checkElement('#expeditions_expedition_from_date_year > option:first_element', 'yyyy')->checkElement('#expeditions_expedition_to_date_day > option:first_element', 'dd')->checkElement('#expeditions_expedition_to_date_month > option:first_element', 'mm')->checkElement('#expeditions_expedition_to_date_year > option:first_element', 'yyyy')->checkElement('form tfoot a', 'Cancel')->checkElement('form input[type="submit"][value="Save"]', 1)->end()->info('Try to save without data')->click('Save', array('expeditions' => array('name' => '', 'expedition_from_date' => '', 'expedition_to_date' => '')))->with('form')->begin()->hasErrors(1)->isError('name', 'required')->end()->info('Try to save with only "Year missing" error')->click('Save', array('expeditions' => array('name' => 'Antarctica 2000', 'expedition_from_date' => array('day' => '', 'month' => '05', 'year' => ''), 'expedition_to_date' => array('day' => '', 'month' => '', 'year' => ''))))->with('form')->begin()->hasErrors(1)->isError('expedition_from_date', 'year_missing')->end()->info('Try to save with only "Month missing" error')->click('Save', array('expeditions' => array('name' => 'Antarctica 2000', 'expedition_from_date' => array('day' => '05', 'month' => '', 'year' => '2000'), 'expedition_to_date' => array('day' => '', 'month' => '', 'year' => ''))))->with('form')->begin()->hasErrors(1)->isError('expedition_from_date', 'month_missing')->end()->info('Try to save with date to bellow date from global error')->click('Save', array('expeditions' => array('name' => 'Antarctica 2000', 'expedition_from_date' => array('day' => '05', 'month' => '12', 'year' => '2000'), 'expedition_to_date' => array('day' => '05', 'month' => '12', 'year' => '1999'))))->with('form')->begin()->hasGlobalError("invalid")->end()->info('Save with correct data and check everything was saved correctly')->click('Save', array('expeditions' => array('name' => 'Antarctica 2000', 'expedition_from_date' => array('day' => '05', 'month' => '12', 'year' => '1999'), 'expedition_to_date' => array('day' => '05', 'month' => '12', 'year' => '2000'))))->with('response')->begin()->isRedirected()->end()->followRedirect()->with('request')->begin()->isParameter('module', 'expedition')->isParameter('action', 'edit')->end()->with('response')->begin()->checkElement('form input[name="expeditions[name]"][value="Antarctica 2000"]', 1)->checkElement('form table tfoot a:first', 'New Expedition')->checkElement('form table tfoot a:nth-child(4)', 'Cancel')->checkElement('form table tfoot a:nth-child(5)', 'Delete')->checkElement('li[class="widget"][id="comment"]', 1)->checkElement('li[class="widget"][id="comment"] div[class="widget_content hidden"]', 1)->end();
$items = Doctrine::getTable('Expeditions')->findByName('Antarctica 2000');
$browser->info('Check new record has been saved in DB')->test()->is($items[0]->getName(), 'Antarctica 2000', 'We have the new encoded expedition');
$browser->test()->is($items[0]->getExpeditionFromDate(), array('year' => 1999, 'month' => 12, 'day' => 5, 'hour' => '', 'minute' => '', 'second' => ''), 'We have the new encoded expedition');
$browser->test()->is($items[0]->getExpeditionToDate(), array('year' => 2000, 'month' => 12, 'day' => 5, 'hour' => '', 'minute' => '', 'second' => ''), 'We have the new encoded expedition');
$browser->info('Test the delete action...')->get('/expedition/edit/id/' . $items[0]->getId())->click('Delete')->with('response')->begin()->isRedirected()->end()->followRedirect()->with('request')->begin()->isParameter('module', 'expedition')->isParameter('action', 'index')->end();
$items = Doctrine::getTable('Expeditions')->findByName('Antarctica 2000');
$browser->test()->is($items->count(), 0, 'Expedition well deleted');