<?php // functional test for a few special things in the admin module require_once dirname(__FILE__) . '/../bootstrap/functional.php'; require_once sfConfig::get('sf_lib_dir') . '/test/unitHelper.php'; $browser = new sfTestFunctional(new sfBrowser()); $browser->setTester('doctrine', 'sfTesterDoctrine'); $arr = create_doctrine_test_tree($browser->test()); $root = $arr['rt']; $rootForm = new ioDoctrineMenuItemForm($root); $browser->info('1 - Edit an existing, you cannot place it via parent_id')->get(sprintf('/test/menu/%d/edit', $root->id))->with('request')->begin()->isParameter('module', 'io_doctrine_menu')->isParameter('action', 'edit')->end()->with('response')->begin()->checkForm($rootForm)->info(' 1.1 - The root menu has no parent_id field')->checkElement('#io_doctrine_menu_item_parent_id', 0)->end()->click('Save', array('io_doctrine_menu_item' => array('parent_id' => $root->id)))->with('form')->begin()->hasErrors(1)->hasGlobalError('extra_fields')->end(); $browser->info('2 - Create a new menu item, set it as a child of something')->get('/test/menu/new')->with('request')->begin()->isParameter('module', 'io_doctrine_menu')->isParameter('action', 'new')->end()->with('response')->begin()->checkForm('ioDoctrineMenuItemForm')->info(' 2.1 - The root menu has a parent_id field')->checkElement('#io_doctrine_menu_item_parent_id', 1)->end()->click('Save', array('io_doctrine_menu_item' => array('parent_id' => $root->id, 'name' => 'new child')))->with('form')->begin()->hasErrors(0)->end()->with('doctrine')->begin()->check('ioDoctrineMenuItem', array('name' => 'new child', 'root_id' => $root->id, 'lft' => 16, 'rgt' => 17, 'level' => 1))->end(); die; $browser->info('3 - Create a new menu item, make it root')->get('/test/menu/new')->with('request')->begin()->isParameter('module', 'io_doctrine_menu')->isParameter('action', 'new')->end()->click('Save', array('io_doctrine_menu_item' => array('name' => 'new root')))->with('form')->begin()->hasErrors(0)->end()->with('doctrine')->begin()->check('ioDoctrineMenuItem', array('name' => 'new root', 'lft' => 18, 'rgt' => 19, 'level' => 0))->end();
<?php include dirname(__FILE__) . '/../../bootstrap/functional.php'; /** * This is an example class of sfTestFunctional * It may require some attention to work with the default values (line 40). */ $browser = new sfBrowser(); $test_browser = new sfTestFunctional($browser); $test_browser->setTester('json.response', 'sfTesterJsonResponse'); $test_browser->get('/subredditdeadline')->with('request')->begin()->isParameter('module', 'subredditdeadline')->isParameter('action', 'index')->end()->with('response')->begin()->isStatusCode(200)->end()->with('json.response')->begin()->isJson()->end(); /** * Test the creation */ $entity = new Deadline(); $entity_array = $entity->exportTo('array'); $identifier = $entity->getTable()->getIdentifier(); /** * Please build a valid $entity_array here */ unset($entity_array[$identifier]); //$entity_array['name'] = "pony"; //$entity_array['created_at'] = date('Y-m-d H:i:s'); //$entity_array['updated_at'] = date('Y-m-d H:i:s'); $test_browser->call('/subredditdeadline', 'post', array('content' => json_encode($entity_array)))->with('request')->begin()->isParameter('module', 'subredditdeadline')->isParameter('action', 'create')->end()->with('response')->begin()->isStatusCode(200)->end(); /** * If the new entity has been created */ $location = $browser->getResponse()->getHttpHeader('Location'); if ($location) { // Get ?
<?php $app = 'frontend'; $fixtures = true; require_once dirname(__FILE__) . '/../bootstrap/functional.php'; $b = new sfTestFunctional(new sfBrowser()); $b->setTester('doctrine', 'sfTesterDoctrine'); $info = array('models_user' => array('isActive' => true, 'username' => 'jonwage2', 'password' => 'newpassword', 'profile' => array('firstName' => 'Jon', 'lastName' => 'Wage'))); $checkInfo = array('isActive' => true, 'username' => 'jonwage2', 'password' => md5('newpassword')); $b->get('/users')->click('jwage')->click('Save', $info)->with('form')->begin()->hasErrors(false)->end()->with('doctrine')->begin()->check($em, 'Entities\\User', $checkInfo)->end()->with('response')->begin()->isRedirected(true)->followRedirect()->end(); $info = array('models_user' => array('isActive' => false, 'username' => 'jwage', 'password' => 'changeme', 'profile' => array('firstName' => 'J', 'lastName' => 'Wage'))); $checkInfo = array('isActive' => 0, 'username' => 'jwage', 'password' => md5('changeme')); $b->click('Back to list')->click('New')->click('Save', $info)->with('form')->begin()->hasErrors(false)->end()->with('doctrine')->begin()->check($em, 'Entities\\User', $checkInfo)->check($em, 'Entities\\Profile', $info['models_user']['profile'])->end()->with('response')->begin()->isRedirected(true)->followRedirect()->end();
<?php include dirname(__FILE__) . '/../../bootstrap/doctrine.php'; $browser = new sfTestFunctional(new sfBrowser()); $browser->setTester('mailerx', 'sfTesterMailerExt'); $browser->info('1. Invite user')->info(' 1.1 Invite page')->get('/user/invite')->with('response')->isStatusCode(302)->get('/login')->click('form input[type=submit]', array('login' => array('email' => '*****@*****.**', 'password' => 'test_PaSS')))->with('response')->followRedirect()->with('user')->isAuthenticated(true)->get('/user/invite')->with('request')->begin()->isParameter('module', 'sfObjectGuardInvite')->isParameter('action', 'index')->end()->with('response')->begin()->isStatusCode(200)->checkElement('h1', 'Invite user')->checkForm('sfObjectGuardInviteForm')->checkElement('form input[type=submit]', 1)->end()->info(' 1.2 Submitted form with existent email')->click('form input[type=submit]', array('invite' => array('email' => '*****@*****.**')))->with('form')->begin()->hasErrors(true)->end()->info(' 1.3 Submitted form with new email')->click('form input[type=submit]', array('invite' => array('email' => $email = '*****@*****.**')))->with('form')->begin()->hasErrors(false)->end()->info(' 1.4 Mail sending')->with('mailerx')->begin()->hasSent(1)->withMessage('*****@*****.**')->checkHeader('Subject', '/Invite to the/')->checkBody('/Go to the following link to finish registration:/')->checkBody('/<a href=\\".*\\/user\\/activate\\/.*\\">/')->regexpBody('/<a href=\\".*(\\/user\\/activate\\/[^\\"\\/]*)\\">/', $activationMailLink)->checkBody(sprintf('/Your email: \\"%s\\"/', $email))->checkBody('/Your temporary password: \\"[^\\"]*\\"/')->regexpBody('/Your temporary password: \\"([^\\"]*)\\"/', $activationMailPassword)->end()->with('response')->isRedirected()->followRedirect()->with('response')->begin()->checkElement('p', '/We have successfully sent registration instructions to the specified email/')->end()->info('2. Account activation')->get($activationMailLink[1])->with('request')->begin()->isParameter('module', 'sfObjectGuardAuth')->isParameter('action', 'activate')->end()->with('response')->followRedirect()->info('3. Check user')->get('/logout')->with('response')->followRedirect()->get('/login')->click('form input[type=submit]', array('login' => array('email' => $email, 'password' => $activationMailPassword[1])))->with('form')->begin()->hasErrors(false)->end()->with('response')->followRedirect()->with('user')->isAuthenticated(true);
<?php include dirname(__FILE__) . '/../bootstrap/functional.php'; $subdir1 = sfAssetFolderPeer::retrieveByPath('TESTsubdir1', '/'); $subdir2 = sfAssetFolderPeer::retrieveByPath('TESTsubdir2', '/'); $browser = new sfTestFunctional(new sfBrowser()); $browser->setTester('propel', 'sfTesterPropel'); $browser->info('assets list')->get('/sfAsset/dir/media')->with('request')->begin()->isParameter('module', 'sfAsset')->isParameter('action', 'list')->end()->with('response')->begin()->isStatusCode(200)->checkElement('div#sf_asset_bar p:first-child', '/media/')->checkElement('div#sf_asset_bar p:nth-child(2)', '/2 subfolders/')->checkElement('div#sf_asset_bar p:nth-child(3)', '/3 files, 3 KiB/')->checkElement('div#sf_asset_container div.assetImage', 5)->checkElement('div#sf_asset_container div.assetImage img[src$="folder.png"]', 2)->checkElement('div#sf_asset_container div.assetImage img[src$="asset1.png"]', 1)->checkElement('div#sf_asset_container div.assetImage:nth-child(4)', '/asset1/')->checkElement('div#sf_asset_container div.assetImage:nth-child(5)', '/asset2/')->checkElement('div#sf_asset_container div.assetImage:nth-child(6)', '/asset3/')->end()->info('sorting options')->click('Sort by date')->with('response')->begin()->checkElement('div#sf_asset_container div.assetImage:nth-child(4)', '/asset3/')->checkElement('div#sf_asset_container div.assetImage:nth-child(5)', '/asset2/')->checkElement('div#sf_asset_container div.assetImage:nth-child(6)', '/asset1/')->end()->click('Sort by name')->with('response')->begin()->checkElement('div#sf_asset_container div.assetImage:nth-child(4)', '/asset1/')->checkElement('div#sf_asset_container div.assetImage:nth-child(5)', '/asset2/')->checkElement('div#sf_asset_container div.assetImage:nth-child(6)', '/asset3/')->end()->info('enter first subfolder')->click('a[href*="media/TESTsubdir1"]')->with('request')->begin()->isParameter('module', 'sfAsset')->isParameter('action', 'list')->end()->with('response')->begin()->isStatusCode(200)->checkElement('div#sf_asset_bar p:first-child', '/TESTsubdir1/')->checkElement('div#sf_asset_container div.assetImage', 2)->checkElement('div#sf_asset_container div.assetComment', '/\\.\\./')->end()->info('return to list')->click('a[href$="media"]')->with('request')->begin()->isParameter('module', 'sfAsset')->isParameter('action', 'list')->end()->info('add new asset')->click('a[href*="media/TESTsubdir1"]')->click('input[value="Add"]', array('sf_asset' => array('file' => '')))->with('form')->begin()->hasErrors(1)->isError('file', 'required')->end()->get('/sfAsset/dir/media/TESTsubdir1')->click('input[value="Add"]', array('sf_asset' => array('file' => dirname(__FILE__) . '/../data/demo.png')))->with('form')->hasErrors(false)->with('request')->begin()->isParameter('module', 'sfAsset')->isParameter('action', 'addQuick')->end()->with('response')->isRedirected()->followRedirect()->with('request')->begin()->isParameter('module', 'sfAsset')->isParameter('action', 'edit')->end()->with('response')->begin()->isStatusCode(200)->checkElement('div#sf_asset_container div.content', '/demo\\.png/')->end()->with('propel')->check('sfAsset', array('folder_id' => $subdir1->getId(), 'filename' => 'demo.png', 'description' => 'demo.png', 'type' => 'image', 'filesize' => 4))->info('edit asset')->click('input.sf_admin_action_save', array('sf_asset' => array('description' => 'this is a demo image', 'author' => 'Massimiliano Arione', 'copyright' => '2010')))->with('form')->hasErrors(false)->with('response')->isRedirected()->followRedirect()->with('response')->begin()->checkElement('div.save-ok', '/Your modifications have been saved/')->end()->with('propel')->check('sfAsset', array('folder_id' => $subdir1->getId(), 'filename' => 'demo.png', 'description' => 'this is a demo image', 'author' => 'Massimiliano Arione', 'type' => 'image', 'filesize' => 4))->info('create a new folder')->click('TESTsubdir1')->click('input[value="Create"]', array('sf_asset_folder' => array('name' => '')))->with('form')->begin()->hasErrors(1)->isError('name', 'required')->end()->get('/sfAsset/dir/media/TESTsubdir1')->click('input[value="Create"]', array('sf_asset_folder' => array('name' => 'invalid name!')))->with('form')->begin()->hasErrors(1)->isError('name', 'invalid')->end()->get('/sfAsset/dir/media/TESTsubdir1')->click('input[value="Create"]', array('sf_asset_folder' => array('name' => 'thumbnail')))->with('form')->begin()->hasErrors(1)->isError('name', 'invalid')->end()->get('/sfAsset/dir/media/TESTsubdir1')->click('input[value="Create"]', array('sf_asset_folder' => array('name' => 'foobar')))->with('form')->hasErrors(false)->with('propel')->check('sfAssetFolder', array('tree_left' => 3, 'tree_right' => 4, 'name' => 'foobar', 'relative_path' => 'media/TESTsubdir1/foobar'))->info('rename folder')->with('response')->isRedirected()->followRedirect()->click('input[value="Rename"]', array('sf_asset_folder' => array('name' => 'invalid name!')))->with('form')->begin()->hasErrors(1)->isError('name', 'invalid')->end()->get('/sfAsset/dir/media/TESTsubdir1/foobar')->click('input[value="Rename"]', array('sf_asset_folder' => array('name' => 'thumbnail')))->with('form')->begin()->hasErrors(1)->isError('name', 'invalid')->end()->get('/sfAsset/dir/media/TESTsubdir1/foobar')->click('input[value="Rename"]', array('sf_asset_folder' => array('name' => 'barfoo')))->with('form')->hasErrors(false)->with('propel')->check('sfAssetFolder', array('tree_left' => 3, 'tree_right' => 4, 'name' => 'barfoo', 'relative_path' => 'media/TESTsubdir1/barfoo'))->info('delete folder')->with('response')->isRedirected()->followRedirect()->click('Delete folder', array(), array('method' => 'delete', '_with_csrf' => true))->with('request')->begin()->isParameter('module', 'sfAsset')->isParameter('action', 'deleteFolder')->end()->with('propel')->check('sfAssetFolder', array('tree_left' => 3, 'tree_right' => 4, 'name' => 'barfoo', 'relative_path' => 'media/TESTsubdir1/barfoo'), false)->with('response')->isRedirected()->followRedirect()->with('response')->begin()->checkElement('div.save-ok', '/The folder has been deleted/')->end()->info('move folder')->click('input[value="Move"]', array('sf_asset_folder' => array('parent_folder' => $subdir2->getId())))->with('form')->hasErrors(false)->with('request')->begin()->isParameter('module', 'sfAsset')->isParameter('action', 'moveFolder')->end()->with('propel')->check('sfAssetFolder', array('tree_left' => 3, 'tree_right' => 4, 'name' => 'TESTsubdir1', 'relative_path' => 'media/TESTsubdir2/TESTsubdir1'))->with('response')->isRedirected()->followRedirect()->with('response')->begin()->checkElement('div.save-ok', '/The folder has been moved/')->end()->info('move asset')->click('a[title="demo.png"]')->click('input[value="Move"]', array('sf_asset' => array('parent_folder' => $subdir2->getId())))->with('form')->hasErrors(false)->with('request')->begin()->isParameter('module', 'sfAsset')->isParameter('action', 'moveAsset')->end()->with('response')->isRedirected()->followRedirect()->with('response')->begin()->checkElement('div.save-ok', '/The file has been moved/')->end()->with('propel')->check('sfAsset', array('folder_id' => $subdir2->getId(), 'filename' => 'demo.png', 'description' => 'this is a demo image', 'type' => 'image', 'filesize' => 4))->info('rename asset')->click('input[value="Rename"]', array('sf_asset' => array('filename' => 'demorenamed.png')))->with('form')->hasErrors(false)->with('request')->begin()->isParameter('module', 'sfAsset')->isParameter('action', 'renameAsset')->end()->with('response')->isRedirected()->followRedirect()->with('response')->begin()->checkElement('div.save-ok', '/The file has been renamed/')->end()->with('propel')->check('sfAsset', array('folder_id' => $subdir2->getId(), 'filename' => 'demorenamed.png', 'description' => 'this is a demo image', 'type' => 'image'))->info('replace asset')->click('input[value="Replace"]', array('sf_asset' => array('file' => dirname(__FILE__) . '/../data/propel.gif')))->with('form')->hasErrors(false)->with('request')->begin()->isParameter('module', 'sfAsset')->isParameter('action', 'replaceAsset')->end()->with('response')->isRedirected()->followRedirect()->with('request')->begin()->isParameter('module', 'sfAsset')->isParameter('action', 'edit')->end()->with('response')->begin()->checkElement('div.save-ok', '/The file has been replaced/')->end()->with('propel')->check('sfAsset', array('folder_id' => $subdir2->getId(), 'filename' => 'demorenamed.png', 'description' => 'this is a demo image', 'type' => 'image'))->info('delete asset')->click('Delete', array(), array('method' => 'delete', '_with_csrf' => true))->with('request')->begin()->isParameter('module', 'sfAsset')->isParameter('action', 'deleteAsset')->end()->with('propel')->check('sfAsset', array('folder_id' => $subdir2->getId(), 'filename' => 'propel.gif', 'type' => 'image'), false)->with('response')->isRedirected()->followRedirect()->with('response')->begin()->checkElement('div.save-ok', '/The file has been deleted/')->end()->info('mass upload')->click('media')->click('Mass upload')->with('request')->begin()->isParameter('module', 'sfAsset')->isParameter('action', 'massUpload')->end()->with('response')->begin()->isValid(true)->end()->click('Upload', array('sf_asset' => array('folder_id' => $subdir1->getId(), 'file_1' => dirname(__FILE__) . '/../data/demo2.png', 'file_2' => dirname(__FILE__) . '/../data/propel2.gif')))->with('form')->hasErrors(false)->with('propel')->begin()->check('sfAsset', array('folder_id' => $subdir1->getId(), 'filename' => 'demo2.png', 'type' => 'image'))->check('sfAsset', array('folder_id' => $subdir1->getId(), 'filename' => 'propel2.gif', 'type' => 'image'))->end()->info('search')->get('/sfAsset/dir/media')->click('input[value="Search"]')->with('form')->begin()->hasErrors(false)->end()->with('request')->begin()->isParameter('module', 'sfAsset')->isParameter('action', 'search')->end()->with('response')->begin()->checkElement('div.search_result', 7)->end()->click('input[value="Search"]', array('sf_asset_filters' => array('filename' => array('text' => 'asset1'))))->with('form')->begin()->hasErrors(false)->end()->with('request')->begin()->isParameter('module', 'sfAsset')->isParameter('action', 'search')->end()->with('response')->begin()->checkElement('div.search_result', 3)->end()->info('delete folder with subfolder')->get('/sfAsset/dir/media')->click('input[value="Create"]', array('sf_asset_folder' => array('name' => 'sub')))->with('response')->isRedirected()->followRedirect()->click('input[value="Create"]', array('sf_asset_folder' => array('name' => 'sub2')))->with('response')->isRedirected()->followRedirect()->info('create sub folder')->get('/sfAsset/dir/media/sub')->info('delete folder with sub folder')->click('Delete folder', array(), array('method' => 'delete', '_with_csrf' => true))->with('request')->begin()->isParameter('module', 'sfAsset')->isParameter('action', 'deleteFolder')->end()->with('response')->isRedirected()->followRedirect()->with('response')->begin()->checkElement('div.save-ok', '/The folder has been deleted/')->end(); // TODO more tests...