<?php include dirname(__FILE__) . '/../../bootstrap/functional.php'; $filePath = sfConfig::get('sf_web_dir') . '/images/skin_header_logo.jpg'; $browser = new sfTestFunctional(new opBrowser(), new lime_test(null, new lime_output_color())); $params = array('authMailAddress' => array('mail_address' => '*****@*****.**', 'password' => 'password')); $browser->info('1. When an user tries to post more than 4 photos, he gets an error message. (ref. #3544)')->info('1st Post')->post('/member/login/authMode/MailAddress', $params)->get('member/configImage')->click('アップロードする', array('member_image' => array('file' => array('name' => $filePath, 'type' => 'image/jpeg'))))->isStatusCode(302)->followRedirect()->info('2nd Post')->click('アップロードする', array('member_image' => array('file' => array('name' => $filePath, 'type' => 'image/jpeg'))))->isStatusCode(302)->followRedirect()->info('3rd Post')->click('アップロードする', array('member_image' => array('file' => array('name' => $filePath, 'type' => 'image/jpeg'))))->isStatusCode(302)->followRedirect()->info('4th Post')->click('アップロードする', array('member_image' => array('file' => array('name' => $filePath, 'type' => 'image/jpeg'))))->isStatusCode(200)->with('response')->begin()->checkElement('#flashError td:contains("これ以上画像を追加できません。")', true)->end();
<?php require_once dirname(__FILE__) . '/../bootstrap/bootstrap.php'; $browser = new sfTestFunctional(new sfBrowser()); $browser->info('Testing my application homepage')->get('/')->with('response')->begin()->isStatusCode(200)->end();
<?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/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'); $browser = new sfTestFunctional(new sfBrowser()); $browser->info('no tests available'); /* $browser-> get('/newsletter/index')-> with('request')->begin()-> isParameter('module', 'newsletter')-> isParameter('action', 'index')-> end()-> with('response')->begin()-> isStatusCode(200)-> checkElement('body', '!/This is a temporary page/')-> end() ; */
<?php include dirname(__FILE__) . '/../../bootstrap/functional.php'; $browser = new sfTestFunctional(new sfBrowser()); $browser->get('/default/index')->with('request')->begin()->isParameter('module', 'default')->isParameter('action', 'index')->end()->with('response')->begin()->isStatusCode(200)->checkElement('body', '!/This is a temporary page/')->end(); $browser->info('Personalized 404 page')->get('/404')->with('request')->begin()->isParameter('module', 'default')->isParameter('action', '404')->end()->with('response')->begin()->isStatusCode(404)->checkElement('.content', '#404#')->end()->get('/qwertyuiop')->with('response')->begin()->isStatusCode(404)->end();
<?php include sfConfig::get('sf_test_dir') . '/bootstrap/functional.php'; $browser = new sfTestFunctional(new sfBrowser()); $config = sfConfig::get('app_cacophony'); $browser->info('Twitter Connect')->get('/oauth/connect/twitter')->with('request')->begin()->isParameter('module', 'sfCacophonyConsumer')->isParameter('action', 'connect')->isParameter('provider', 'twitter')->end()->with('response')->begin()->isStatusCode(302)->end(); $response = $browser->getResponse(); $browser->test()->like($response->getHttpHeader('Location'), '@' . $config['providers']['twitter']['authorize_url'] . '@', 'Connect redirects to correct URL'); //$browser->info(parse_url($response->getHttpHeader('Location'), PHP_URL_QUERY)); $browser->info('Twitter Callback')->get('/oauth/callback/twitter?oauth_token=1234&oauth_verifier=5678')->with('request')->begin()->isParameter('module', 'sfCacophonyConsumer')->isParameter('action', 'callback')->isParameter('provider', 'twitter')->isParameter('oauth_token', '1234')->isParameter('oauth_verifier', '5678')->end()->with('response')->begin()->isStatusCode(302)->end()->with('user')->begin()->isFlash('error', 'Failed to retrieve access token: Invalid auth/bad request (got a 401, expected HTTP/1.1 20X or a redirect)')->end(); $browser->info('Vimeo Connect')->get('/oauth/connect/vimeo')->with('request')->begin()->isParameter('module', 'sfCacophonyConsumer')->isParameter('action', 'connect')->isParameter('provider', 'vimeo')->end()->with('response')->begin()->isStatusCode(302)->end(); $response = $browser->getResponse(); $browser->test()->like($response->getHttpHeader('Location'), '@' . $config['providers']['vimeo']['authorize_url'] . '@', 'Connect redirects to correct URL'); //$browser->info(parse_url($response->getHttpHeader('Location'), PHP_URL_QUERY)); $browser->info('Vimeo Callback')->get('/oauth/callback/vimeo?oauth_token=1234&oauth_verifier=5678')->with('request')->begin()->isParameter('module', 'sfCacophonyConsumer')->isParameter('action', 'callback')->isParameter('provider', 'vimeo')->isParameter('oauth_token', '1234')->isParameter('oauth_verifier', '5678')->end()->with('response')->begin()->isStatusCode(302)->end()->with('user')->begin()->isFlash('error', 'Failed to retrieve access token: Invalid auth/bad request (got a 401, expected HTTP/1.1 20X or a redirect)')->end(); $browser->info('Facebook Connect')->get('/oauth/connect/facebook')->with('request')->begin()->isParameter('module', 'sfCacophonyConsumer')->isParameter('action', 'connect')->isParameter('provider', 'facebook')->end()->with('response')->begin()->isStatusCode(302)->end(); $response = $browser->getResponse(); $browser->test()->like($response->getHttpHeader('Location'), '@' . $config['providers']['facebook']['authorize_url'] . '@', 'Connect redirects to correct URL'); //$browser->info(parse_url($response->getHttpHeader('Location'), PHP_URL_QUERY)); parse_str(parse_url(urldecode($response->getHttpHeader('Location')), PHP_URL_QUERY), $query_string); $browser->info('Facebook Callback')->get(sprintf('/oauth/callback/facebook?code=1234&state=%s', $query_string['state']))->with('request')->begin()->isParameter('module', 'sfCacophonyConsumer')->isParameter('action', 'callback')->isParameter('provider', 'facebook')->isParameter('code', '1234')->isParameter('state', $query_string['state'])->end()->with('response')->begin()->isStatusCode(302)->end()->with('user')->begin()->isFlash('error', 'Failed to retrieve access token: ')->end();
<?php include dirname(__FILE__) . '/../../bootstrap/doctrine.php'; $browser = new sfTestFunctional(new sfBrowser()); $browser->info('1. Active user autrhorization test')->get('/')->with('user')->isAuthenticated(false)->info(' 1.1 Login with activated & wrong pass account')->get('/login')->with('request')->begin()->isParameter('module', 'sfObjectGuardAuth')->isParameter('action', 'login')->end()->with('response')->begin()->isStatusCode(200)->checkElement('h1', 'Enter to site')->checkForm('sfObjectGuardLoginForm')->checkElement('form input[type=submit]', 1)->end()->info(' 1.2 Submitted login form with wrong pass')->click('form input[type=submit]', array('login' => array('email' => '*****@*****.**', 'password' => 'test_PaasSS')))->with('form')->begin()->hasErrors(true)->end()->with('user')->isAuthenticated(false)->info(' 1.3 Login with activated account')->get('/login')->with('request')->begin()->isParameter('module', 'sfObjectGuardAuth')->isParameter('action', 'login')->end()->with('response')->begin()->isStatusCode(200)->checkElement('h1', 'Enter to site')->checkForm('sfObjectGuardLoginForm')->checkElement('form input[type=submit]', 1)->end()->info(' 1.4 Submitted login form')->click('form input[type=submit]', array('login' => array('email' => '*****@*****.**', 'password' => 'test_PaSS')))->with('form')->begin()->hasErrors(false)->end()->with('response')->isRedirected()->followRedirect()->with('user')->isAuthenticated(true)->info('2. Active user password change')->get('/user/password')->with('request')->begin()->isParameter('module', 'sfObjectGuardAuth')->isParameter('action', 'password')->end()->with('response')->begin()->isStatusCode(200)->checkForm('sfObjectGuardPasswordForm')->checkElement('form input[type=submit]', 1)->end()->info(' 2.2 Submitted password form')->click('form input[type=submit]', array('password' => array('password' => $newPass = '******')))->with('form')->begin()->hasErrors(false)->end()->with('response')->isRedirected()->followRedirect()->info(' 2.3 Logout user')->get('/logout')->with('request')->begin()->isParameter('module', 'sfObjectGuardAuth')->isParameter('action', 'logout')->end()->with('response')->isRedirected()->followRedirect()->with('user')->isAuthenticated(false)->info(' 2.4 Login with changed password')->get('/login')->with('request')->begin()->isParameter('module', 'sfObjectGuardAuth')->isParameter('action', 'login')->end()->click('form input[type=submit]', array('login' => array('email' => '*****@*****.**', 'password' => $newPass)))->with('form')->begin()->hasErrors(false)->end()->with('response')->isRedirected()->followRedirect()->with('user')->isAuthenticated(true)->info('3. Non-active user autrhorization test')->get('/')->info(' 3.1 Logout user')->get('/logout')->with('request')->begin()->isParameter('module', 'sfObjectGuardAuth')->isParameter('action', 'logout')->end()->with('response')->isRedirected()->followRedirect()->with('user')->isAuthenticated(false)->info(' 3.2 Login with non-active account')->get('/login')->with('request')->begin()->isParameter('module', 'sfObjectGuardAuth')->isParameter('action', 'login')->end()->with('response')->begin()->isStatusCode(200)->checkElement('h1', 'Enter to site')->checkForm('sfObjectGuardLoginForm')->checkElement('form input[type=submit]', 1)->end()->info(' 3.3 Submitted login form')->click('form input[type=submit]', array('login' => array('email' => '*****@*****.**', 'password' => 'tesPasas123sa')))->with('form')->begin()->hasErrors(true)->end()->with('user')->isAuthenticated(false);
<?php $app = 'no_theme'; require dirname(__FILE__) . '/../bootstrap/functional.php'; // Test for themeing being disabled $browser = new sfTestFunctional(new sfBrowser()); $browser->info('1 - Goto the homepage of the no_theme app where theming is disabled')->get('/')->with('response')->begin()->isStatusCode(200)->info(' 1.1 - The "No theme" layout should be used')->checkElement('h1', '/No theme/')->end();
<?php include dirname(__FILE__) . '/../../bootstrap/functional.php'; $browser = new sfTestFunctional(new sfBrowser(), new lime_test(null, new lime_output_color())); $params = array('admin_user' => array()); $browser->info('0. Login')->get('/default/login')->click('ログイン', array('admin_user' => array('username' => 'admin', 'password' => 'password')))->isStatusCode(302)->info('1. When an admin user tries to change the SNS configuration. (ref. #3488)')->info('A category is not selected, admin user can change the general configuration.')->get('/sns/config')->click('設定変更')->isStatusCode(302)->info('A general category is selected, admin user can change the general configuration.')->get('/sns/config/category/general')->click('設定変更')->isStatusCode(302)->info('An authentication category is selected, admin user can change the authentication configuration.')->get('/sns/config/category/authentication')->click('設定変更')->isStatusCode(302)->info('A mobile category is selected, admin user can change the mobile configuration.')->get('/sns/config/category/mobile')->click('設定変更')->isStatusCode(302)->info('A policy category is selected, admin user can change the policy configuration.')->get('/sns/config/category/policy')->click('設定変更')->isStatusCode(302)->info('/sns/config - CSRF')->post('/sns/config')->checkCSRF()->info('/sns/config/category/external_login_page - CSRF')->post('/sns/config/category/external_login_page')->checkCSRF()->info('/sns/config/category/authentication - CSRF')->post('/sns/config/category/authentication')->checkCSRF()->info('/sns/config/category/mobile - CSRF')->post('/sns/config/category/mobile')->checkCSRF()->info('/sns/config/category/policy - CSRF')->post('/sns/config/category/policy')->checkCSRF()->info('/sns/config/category/api_keys - CSRF')->post('/sns/config/category/api_keys')->checkCSRF()->info('/sns/term - CSRF')->post('/sns/term')->checkCSRF()->info('/sns/cache - CSRF')->post('/sns/cache')->checkCSRF()->info('/sns/richTextarea - CSRF')->post('/sns/richTextarea')->checkCSRF()->info('/sns/changeRichTextareaButtonOrder - CSRF')->setHttpHeader('X_REQUESTED_WITH', 'XMLHttpRequest')->post('/sns/changeRichTextareaButtonOrder')->checkCSRF();
<?php include dirname(__FILE__) . '/../../bootstrap/functional.php'; $browser = new sfTestFunctional(new sfBrowser()); $browser->get('/job/index')->with('request')->begin()->isParameter('module', 'job')->isParameter('action', 'index')->end()->with('response')->begin()->isStatusCode(200)->checkElement('body', '!/This is a temporary page/')->end(); $browser->setHttpHeader('ACCEPT_LANGUAGE', 'fr_FR,fr,en;q=0.7'); $browser->info('6 - User culture')->restart()->info(' 6.1 - For the first request, symfony guesses the best culture')->get('/')->with('response')->isRedirected()->followRedirect()->with('user')->isCulture('fr')->info(' 6.2 - Available cultures are en and fr')->get('/it/')->with('response')->isStatusCode(404); $browser->setHttpHeader('ACCEPT_LANGUAGE', 'en,fr;q=0.7'); $browser->info(' 6.3 - The culture guessing is only for the first request')->get('/')->with('response')->isRedirected()->followRedirect()->with('user')->isCulture('fr');
<?php require dirname(__FILE__) . '/../bootstrap/functional.php'; // Test the forwarding from module to module $browser = new sfTestFunctional(new sfBrowser()); /* * This addresses an issue where if fwd'ed from one action to another with * the same theme, the manager sees that the same theme is being loaded * and stops executing the "switch theme". This is correct for stylesheets * and javascripts, avoiding extra work, but the layout still needs to be * set for the new module/action */ $browser->info('1 - Surf to an action that forwards to another action with the same theme')->get('/manager/forward_to_same_theme')->with('request')->begin()->isParameter('module', 'manager')->isParameter('action', 'forwardToSameTheme')->end()->isForwardedTo('manager', 'otherAction')->with('response')->begin()->isStatusCode(200)->info(' 1.1 - The forwarded action has the correct layout')->checkElement('h1', '/Plugin Test Layout/')->end();
<?php include dirname(__FILE__) . '/../../bootstrap/functional.php'; $browser = new sfTestFunctional(new sfBrowser()); $browser->info('1.1 - The login page: session Module')->get('/')->info(' 2.1 - The login page has a clickable sign up link')->click('sign up', array(), array('position' => 1))->with('request')->begin()->isParameter('module', 'register')->isParameter('action', 'new')->end();
<?php $executeLoader = false; include dirname(__FILE__) . '/../../bootstrap/database.php'; include dirname(__FILE__) . '/../../bootstrap/functional.php'; $browser = new sfTestFunctional(new sfBrowser(), new lime_test(null, new lime_output_color())); $params = array('admin_user' => array()); $browser->setTester('propel', 'sfTesterPropel'); $browser->info('0. Login')->get('/default/login')->click('ログイン', array('admin_user' => array('username' => 'admin', 'password' => 'password')))->isStatusCode(302)->info('1. You can add and sort home gadget')->get('/design/gadget/type/home')->info('Add gadgets to all areas')->click('設定変更', array('new' => array('top' => array('memberImageBox'), 'sideMenu' => array('memberImageBox'), 'contents' => array('memberImageBox'), 'bottom' => array('memberImageBox'))))->with('propel')->begin()->check('Gadget', array('type' => 'top'), 3)->check('Gadget', array('type' => 'sideMenu'), 4)->check('Gadget', array('type' => 'contents'), 1)->check('Gadget', array('type' => 'bottom'), 1)->end()->get('/design/gadget/type/home')->info('Sort some gadgets')->click('設定変更', array('gadget' => array('top' => array(8, 2, 1), 'sideMenu' => array(9, 4, 5, 3))))->with('propel')->begin()->check('Gadget', array('id' => '8', 'sort_order' => 10), true)->check('Gadget', array('id' => '2', 'sort_order' => 20), true)->check('Gadget', array('id' => '1', 'sort_order' => 30), true)->check('Gadget', array('id' => '9', 'sort_order' => 10), true)->check('Gadget', array('id' => '4', 'sort_order' => 20), true)->check('Gadget', array('id' => '5', 'sort_order' => 30), true)->check('Gadget', array('id' => '3', 'sort_order' => 40), true)->end()->info('2. You can add login gadget')->get('/design/gadget/type/login')->info('Add gadgets to all areas')->click('設定変更', array('new' => array('loginTop' => array('loginForm'), 'loginSideMenu' => array('loginForm'), 'loginContents' => array('loginForm'), 'loginBottom' => array('loginForm'))))->with('propel')->begin()->check('Gadget', array('type' => 'loginTop'), 1)->check('Gadget', array('type' => 'loginSideMenu'), 1)->check('Gadget', array('type' => 'loginContents'), 1)->check('Gadget', array('type' => 'loginBottom'), 1)->end()->info('3. You can add and sort side banner gadget')->get('/design/gadget/type/sideBanner')->info('Add gadgets to all areas')->click('設定変更', array('new' => array('sideBannerContents' => array('languageSelecterBox'))))->with('propel')->begin()->check('Gadget', array('type' => 'sideBannerContents'), 2)->end()->get('/design/gadget/type/sideBanner')->info('Sort some gadgets')->click('設定変更', array('gadget' => array('sideBannerContents' => array(16, 6))))->with('propel')->begin()->check('Gadget', array('id' => '16', 'sort_order' => 10), true)->check('Gadget', array('id' => '6', 'sort_order' => 20), true)->end()->info('4. You can add and sort mobile home gadget')->get('/design/gadget/type/mobileHome')->info('Add gadgets to all areas')->click('設定変更', array('new' => array('mobileTop' => array('informationBox'), 'mobileContents' => array('informationBox'), 'mobileBottom' => array('informationBox'))))->with('propel')->begin()->check('Gadget', array('type' => 'mobileTop'), 2)->check('Gadget', array('type' => 'mobileContents'), 1)->check('Gadget', array('type' => 'mobileBottom'), 1)->end()->get('/design/gadget/type/mobileHome')->info('Sort some gadgets')->click('設定変更', array('gadget' => array('mobileTop' => array(17, 7))))->with('propel')->begin()->check('Gadget', array('id' => '17', 'sort_order' => 10), true)->check('Gadget', array('id' => '7', 'sort_order' => 20), true)->end();
<?php require dirname(__FILE__) . '/../bootstrap/functional.php'; // tests the Actions extension class /* * We're not testing here to see that everything is perfect and that the * correct themes are loaded. That will be done elsewhere. We just want * to make sure that the extended methods in the Actions class work */ $browser = new sfTestFunctional(new sfBrowser()); $browser->info('1 - Test the extended functions on the actiosn class')->info(' 1.1 - Test the ->loadTheme() function')->get('/themes/test_theme')->with('response')->begin()->isStatusCode(200)->checkElement('h1', '/Plugin Test Layout/')->end()->info(' 1.2 - Test the ->loadDefaultTheme function')->get('/set_default_theme')->with('response')->begin()->isStatusCode(200)->checkElement('h1', '/Application Test Layout/')->end();
<?php require_once dirname(__FILE__) . '/../../bootstrap/functional.php'; $browser = new sfTestFunctional(new sfBrowser()); $user = new QubitUser(); $user->username = '******'; $user->email = '*****@*****.**'; $user->setPassword('test1234'); $user->save(); $browser->info('Log in')->post(';user/login', array('email' => '*****@*****.**', 'password' => 'test1234'))->with('request')->begin()->isParameter('module', 'user')->isParameter('action', 'login')->end(); $browser->test()->ok($browser->getUser()->isAuthenticated(), 'User is authenticated'); $browser->test()->isa_ok($browser->getUser()->user, 'QubitUser', 'myUser->user is QubitUser'); $browser->info('Log out')->get('/')->with('request')->begin()->isParameter('module', 'staticpage')->isParameter('action', 'static')->end()->click('Log out')->with('request')->begin()->isParameter('module', 'user')->isParameter('action', 'logout')->end(); $browser->test()->ok(!$browser->getUser()->isAuthenticated(), 'User isn\'t authenticated'); $browser = new sfTestFunctional(new sfBrowser()); $browser->info('Incorrect log in')->post(';user/login', array('email' => '*****@*****.**', 'password' => 'wrongpass'))->with('request')->begin()->isParameter('module', 'user')->isParameter('action', 'login')->end(); $browser->test()->ok(!$browser->getUser()->isAuthenticated(), 'User isn\'t authenticated'); $browser->test()->is($browser->getUser()->user, null, 'myUser->user is null'); $browser = new sfTestFunctional(new sfBrowser()); $browser->info('"localhost" "next" parameter, issue 1342')->post(';user/login', array('email' => '*****@*****.**', 'password' => 'test1234', 'next' => 'http://localhost/example'))->with('request')->begin()->isParameter('module', 'user')->isParameter('action', 'login')->end(); $browser->test()->ok($browser->getUser()->isAuthenticated(), 'User is authenticated'); $browser->test()->isa_ok($browser->getUser()->user, 'QubitUser', 'myUser->user is QubitUser'); $browser = new sfTestFunctional(new sfBrowser()); $browser->info('Empty "next" parameter')->post(';user/login', array('email' => '*****@*****.**', 'password' => 'test1234', 'next' => ''))->with('request')->begin()->isParameter('module', 'user')->isParameter('action', 'login')->end(); $browser->test()->ok($browser->getUser()->isAuthenticated(), 'User is authenticated'); $browser->test()->isa_ok($browser->getUser()->user, 'QubitUser', 'myUser->user is QubitUser'); $user->delete();
<?php /** * This file is part of the sfImageTransformExtraPlugin package. * (c) 2010 Christian Schaefer <*****@*****.**>> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. * * @package sfImageTransformExtraPluginFunctionalTests * @subpackage action * @author Christian Schaefer <*****@*****.**> * @version SVN: $Id: sfImageTransformatorActionsTest.php 29957 2010-06-24 08:24:23Z caefer $ */ /** include functional test bootstrap */ include dirname(__FILE__) . '/../bootstrap/functional.php'; $browser = new sfTestFunctional(new sfBrowser()); $browser->info('1 - Request a 1x1 blank PNG in default format')->get('/thumbnails/News/default/01/00/00/test-1.png')->with('request')->begin()->info('1.1 - Checking for correct module/action')->isParameter('module', 'sfImageTransformator')->isParameter('action', 'index')->end()->with('response')->begin()->info('1.2 - Checking for valid response')->isStatusCode(200)->isHeader('Content-Type', 'image/gif')->end()->info('2 - Request a 1x1 blank PNG in original format')->get('/thumbnails/News/original/01/00/00/test-1.png')->with('request')->begin()->info('2.1 - Checking for correct module/action')->isParameter('module', 'sfImageTransformator')->isParameter('action', 'index')->end()->with('response')->begin()->info('2.2 - Checking for valid response')->isStatusCode(200)->isHeader('Content-Type', 'image/jpg')->end();
<?php include dirname(__FILE__) . '/../../bootstrap/doctrine.php'; $browser = new sfTestFunctional(new sfBrowser()); $browser->setTester('mailerx', 'sfTesterMailerExt'); $browser->info('1. Password reminder test')->get('/')->info(' 1.1 Login with activated account')->get('/login')->click('form input[type=submit]', array('login' => array('email' => '*****@*****.**', 'password' => 'test_PaSS')))->with('response')->followRedirect()->with('user')->isAuthenticated(true)->get('/logout')->with('response')->followRedirect()->info(' 1.2 Password reminder')->get('/user/remind')->with('request')->begin()->isParameter('module', 'sfObjectGuardPasswordRemind')->isParameter('action', 'index')->end()->with('response')->begin()->isStatusCode(200)->checkElement('h1', 'Password recovery')->checkForm('sfObjectGuardReminderForm')->checkElement('form input[type=submit]', 1)->end()->info(' 1.3 Submitted form with email')->click('form input[type=submit]', array('reminder' => array('email' => $email = '*****@*****.**')))->with('form')->begin()->hasErrors(false)->end()->info(' 1.4 Mail sending')->with('mailerx')->begin()->hasSent(1)->withMessage($email)->checkHeader('Subject', '/Password recovery for/')->checkBody('/Go to the following link to proceed with password change:/')->checkBody('/<a href=\\".*\\/user\\/activate\\/.*\\">/')->regexpBody('/<a href=\\".*(\\/user\\/activate\\/[^\\"\\/]*)\\">/', $activationMailLink)->checkBody(sprintf('/Your email: \\"%s\\"/', $email))->checkBody('/Your new password: \\"[^\\"]*\\"/')->regexpBody('/Your new password: \\"([^\\"]*)\\"/', $activationMailPassword)->end()->with('response')->isRedirected()->followRedirect()->with('response')->begin()->checkElement('p', '/We have successfully sent password recovery instruction to your email/')->end()->info(' 1.4 Activate new password')->get($activationMailLink[1])->with('request')->begin()->isParameter('module', 'sfObjectGuardAuth')->isParameter('action', 'activate')->end()->with('response')->followRedirect()->get('/logout')->with('response')->followRedirect()->get('/login')->click('form input[type=submit]', array('login' => array('email' => $email, 'password' => $activationMailPassword[1])))->with('response')->followRedirect()->with('user')->isAuthenticated(true);
<?php require_once dirname(__FILE__) . '/../bootstrap/functional.php'; $browser = new sfTestFunctional(new sfBrowser()); $browser->info('1 - Surf to a url with a complex menu and check several things.')->get('/big-menu'); $pretty = '<ul class="root"> <li class="first"> <a href="' . url_for('@homepage', true) . '">Parent 1</a> <ul class="menu_level_1"> <li class="first"> <a href="' . url_for('/parent1/ch1', true) . '?test=1">Child 1</a> </li> <li class="last"> <a href="' . url_for('/parent1/ch2') . '">Child 2</a> </li> </ul> </li> <li class="current_ancestor last"> Parent 2 <ul class="menu_level_1"> <li class="current first last"> <a href="' . url_for('@test_menu') . '">Child 4</a> <ul class="menu_level_2"> <li class="first last"> Grandchild 1 </li> </ul> </li> </ul> </li> </ul>
<?php include dirname(__FILE__) . '/../../bootstrap/functional.php'; $browser = new sfTestFunctional(new sfBrowser(), new lime_test(null, new lime_output_color())); $params = array('admin_user' => array()); $browser->info('0. Login')->get('/default/login')->click('ログイン', array('admin_user' => array('username' => 'admin', 'password' => 'password')))->isStatusCode(302)->info('1. When an admin user tries to change the SNS configuration. (ref. #3488)')->info('A category is not selected, admin user can change the general configuration.')->get('/sns/config')->click('設定変更')->isStatusCode(302)->info('A general category is selected, admin user can change the general configuration.')->get('/sns/config/category/general')->click('設定変更')->isStatusCode(302)->info('An authentication category is selected, admin user can change the authentication configuration.')->get('/sns/config/category/authentication')->click('設定変更')->isStatusCode(302)->info('A mobile category is selected, admin user can change the mobile configuration.')->get('/sns/config/category/mobile')->click('設定変更')->isStatusCode(302)->info('A policy category is selected, admin user can change the policy configuration.')->get('/sns/config/category/policy')->click('設定変更')->isStatusCode(302);
<?php /** * Checks the sfGuardAuthExtra actions * * @todo Add tests ;p * * @author * @package sfDoctrineGuardExtra * @subpackage function test * @version $Id$ */ require_once dirname(__FILE__) . '/../bootstrap/bootstrap.php'; $b = new sfTestFunctional(new sfBrowser()); $b->info('test')->get('/')->with('response')->begin()->isStatusCode(200)->end();
<?php require_once dirname(__FILE__) . '/../bootstrap/functional.php'; require_once sfConfig::get('sf_lib_dir') . '/test/unitHelper.php'; $browser = new sfTestFunctional(new sfBrowser()); $arr = create_doctrine_test_tree($browser->test()); $rt = $arr['rt']; $browser->info('1 - Goto the reorder page and look around')->info(' 1.1 - Goto the reorder page with a fake name sends to a 404')->get('/test/menu/reorder/fake')->with('request')->begin()->isParameter('module', 'io_doctrine_menu')->isParameter('action', 'reorder')->end()->with('response')->begin()->isStatusCode(404)->end()->info(' 1.2 - Goto a real menu reordering page')->get('/test/menu/reorder/' . $rt->id)->with('request')->begin()->isParameter('module', 'io_doctrine_menu')->isParameter('action', 'reorder')->end()->with('response')->begin()->isStatusCode(200)->checkElement('h1', '/Reorder Menu "Root li"/')->info(' 1.3 - check for the correct nested set javascript urls')->matches('/loadUrl:\\ \'\\/index\\.php\\/test\\/menu\\/reorder\\/json\\/' . $rt->id . '/')->matches('/saveUrl:\\ \'\\/index\\.php\\/test\\/menu\\/reorder\\/save\\/' . $rt->id . '/')->end(); $browser->info('2 - Check out the json response for the menu')->get('/test/menu/reorder/json/' . $rt->id)->with('request')->begin()->isParameter('module', 'io_doctrine_menu')->isParameter('action', 'json')->isParameter('sf_format', 'json')->end()->with('response')->begin()->isStatusCode(200)->end(); $response = $browser->getResponse()->getContent(); $json = json_decode($response); $browser->test()->isnt($json, null, 'The response returns a valid json object'); $browser->info('3 - Test the save method')->call('/test/menu/reorder/save/' . $rt->id, 'post', array('nested-sortable-widget' => get_nested_set_save_array($arr)))->with('request')->begin()->isParameter('module', 'io_doctrine_menu')->isParameter('action', 'saveJson')->end()->with('response')->begin()->isStatusCode(200)->end(); $browser->info(' 3.1 - Check the menu to see that it was updated'); root_sanity_check($browser->test(), $rt); check_child_ordering($browser->test(), $rt, array(), array('Parent 2', 'Parent 1')); check_child_ordering($browser->test(), $rt, array(0), array('Child 4')); check_child_ordering($browser->test(), $rt, array(1), array('Child 3', 'Child 1', 'Child 2'));
<?php /* * This file is part of the symfony package. * (c) Fabien Potencier <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ $app = 'cache'; if (!(include dirname(__FILE__) . '/../bootstrap/functional.php')) { return; } $b = new sfTestFunctional(new sfBrowser()); $b->info('No expiration (client_lifetime is 0)')->get('/httpcache/page1')->with('response')->begin()->isHeader('Last-Modified', '/^' . substr(preg_quote(sfWebResponse::getDate(time()), '/'), 5, 16) . '/')->isHeader('ETag', true)->isHeader('Expires', false)->isHeader('Cache-Control', false)->end(); $b->info('Expiration (client_lifetime is 86400)')->get('/httpcache/page2')->with('response')->begin()->isHeader('Last-Modified', false)->isHeader('ETag', false)->isHeader('Expires', '/^' . substr(preg_quote(sfWebResponse::getDate(time() + 86400), '/'), 5, 16) . '/')->isHeader('Cache-Control', '/max-age=86400/')->end(); $b->info('Expiration (client_lifetime is 86400) but the developer has set a Last-Modified header')->get('/httpcache/page3')->with('response')->begin()->isHeader('Last-Modified', '/^' . substr(preg_quote(sfWebResponse::getDate(time() - 86400), '/'), 5, 16) . '/')->isHeader('ETag', false)->isHeader('Expires', false)->isHeader('Cache-Control', false)->end(); $b->info('No expiration and the developer has set a Last-Modified header')->get('/httpcache/page4')->with('response')->begin()->isHeader('Last-Modified', '/^' . substr(preg_quote(sfWebResponse::getDate(time() - 86400), '/'), 5, 16) . '/')->isHeader('ETag', true)->isHeader('Expires', false)->isHeader('Cache-Control', false)->end();
<?php include dirname(__FILE__) . '/../bootstrap/functional.php'; $subdir1 = sfAssetFolderTable::getInstance()->retrieveByPath('TESTsubdir1', '/'); $subdir2 = sfAssetFolderTable::getInstance()->retrieveByPath('TESTsubdir2', '/'); if (!$subdir1) { include dirname(__FILE__) . '/../../../../test/bootstrap/unit.php'; $t = new lime_test(1, array('options' => new lime_output_color(), 'error_reporting' => true)); $t->fail('subdir1 doesn\'t exist.'); exit; } if (!$subdir2) { include dirname(__FILE__) . '/../../../../test/bootstrap/unit.php'; $t = new lime_test(1, array('options' => new lime_output_color(), 'error_reporting' => true)); $t->fail('subdir2 doesn\'t exist.'); exit; } $browser = new sfTestFunctional(new sfBrowser()); $browser->setTester('doctrine', 'sfTesterDoctrine'); $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('doctrine')->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('doctrine')->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' => 'foobar')))->with('form')->hasErrors(false)->with('doctrine')->check('sfAssetFolder', array('lft' => 3, 'rgt' => 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' => 'barfoo')))->with('form')->hasErrors(false)->with('doctrine')->check('sfAssetFolder', array('lft' => 3, 'rgt' => 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('doctrine')->check('sfAssetFolder', array('lft' => 3, 'rgt' => 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('doctrine')->check('sfAssetFolder', array('lft' => 3, 'rgt' => 6, '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('doctrine')->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('doctrine')->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('doctrine')->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('doctrine')->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('doctrine')->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 sub folder')->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...
<?php require dirname(__FILE__) . '/../bootstrap/functional.php'; // Test for all the different variables that can determine which theme should be set $browser = new sfTestFunctional(new sfBrowser()); $headers = array('app_test' => 'Application Test Layout', 'test_theme' => 'Plugin Test Layout'); $browser->info('1 - Test a few straightforward ways of setting themes')->info(' 1.1 - Do nothing special, end up with the default theme')->get('/controller/default_theme')->with('response')->begin()->isStatusCode(200)->checkElement('h1', '/' . $headers['app_test'] . '/')->end()->info(' 1.2 - Go to an action that explicitly request the test_theme')->get('/controller/explicit_test_theme')->with('response')->begin()->isStatusCode(200)->checkElement('h1', '/' . $headers['test_theme'] . '/')->end(); $browser->info('2 - Test forwarding')->info(' 2.1 Start at an action with test_theme route then forward to one using the default theme')->get('/controller/test_theme_forward_default_theme')->with('response')->begin()->isStatusCode(200)->info(' 2.1.1 - The default theme, the final spot, should win out')->checkElement('h1', '/' . $headers['app_test'] . '/')->end()->info(' 2.2 Start at an action with the default theme then forward to the test theme')->get('/controller/default_theme_forward_test_theme')->with('response')->begin()->isStatusCode(200)->info(' 2.2.1 - The test theme, the final spot, should win out')->checkElement('h1', '/' . $headers['test_theme'] . '/')->end(); $browser->info('3 - Test the event listening method of setting a theme')->info(' 3.1 - Goto a module/action that should use the default theme')->get('/controller/event_listener')->with('response')->begin()->isStatusCode(200)->info(' 3.1.1 - Listener in frontendConfiguration set the theme to test_theme')->checkElement('h1', '/' . $headers['test_theme'] . '/')->end(); $browser->info('4 - Change the theme via a request parameter')->info(' 4.1 - Goto the default theme but with a request parameter to set test_theme')->get('/controller/default_theme?sf_theme=test_theme')->with('response')->begin()->isStatusCode(200)->info(' 4.2 - See that the test_theme is used')->checkElement('h1', '/' . $headers['test_theme'] . '/')->end()->with('user')->begin()->info(' 4.3 - A user attribute is set for the theme')->isAttribute('current_theme', 'test_theme')->end()->info(' 4.4 - The theme should be sticky - goto another default theme, should be test theme still')->get('/controller/test_theme_forward_default_theme')->with('response')->begin()->isStatusCode(200)->checkElement('h1', '/' . $headers['test_theme'] . '/')->end()->info(' 4.5 - Set the theme back to app_test with a request parameter')->get('/controller/test_theme_forward_default_theme?sf_theme=app_test')->with('response')->begin()->isStatusCode(200)->checkElement('h1', '/' . $headers['app_test'] . '/')->end()->info(' 4.6 - The user theme is not used if overridden explicitly')->get('/controller/explicit_test_theme')->with('response')->begin()->isStatusCode(200)->info(' 4.6.1 - The theme is test_theme, since it was explicitly set')->checkElement('h1', '/' . $headers['test_theme'] . '/')->end()->info(' 4.7 - Using an invalid theme name does nothing, unsets user attribute')->get('/controller/default_theme?sf_theme=fake')->with('response')->begin()->isStatusCode(200)->checkElement('h1', '/' . $headers['app_test'] . '/')->end()->with('user')->begin()->info(' 4.8 - A user attribute is actually unset')->isAttribute('current_theme', false)->end(); // Restart the browser to clear the session $browser->restart(); $browser->info('5 - Test the modules and routes method of setting themes')->info(' 5.1 - Goto a module that is setup in app.yml to use test_theme')->get('/test_theme_module/index')->with('response')->begin()->isStatusCode(200)->checkElement('h1', '/' . $headers['test_theme'] . '/')->end()->info(' 5.2 - Goto a route that is setup in app.yml to use test_theme')->get('/controller/test_theme_route')->with('response')->begin()->isStatusCode(200)->checkElement('h1', '/' . $headers['test_theme'] . '/')->end();
<?php // test the process of viewing and saving editable areas require_once dirname(__FILE__) . '/../bootstrap/functional.php'; $browser = new sfTestFunctional(new sfBrowser()); $browser->setTester('doctrine', 'sfTesterDoctrine'); Doctrine_Query::create()->from('Blog')->delete()->execute(); $blog = new Blog(); $blog->title = ''; $blog->body = 'Lorem ipsum'; $blog->save(); $browser->info('1 - Visit page, but not logged in')->info(' 1.1 - Start by being logged out.')->get('/blog')->with('request')->begin()->isParameter('module', 'test')->isParameter('action', 'blog')->end()->with('response')->begin()->info(' 1.2 - The title should be empty - we are not logged in, so no default text for the empty title field.')->checkElement('.test_title h1', '')->info(' 1.3 - The title tag should not have the editable class, or any extra markup')->checkElement('.test_title h1[class="test_editable_class_name"]', false)->end(); $context = $browser->getContext(true); $context->getUser()->setAuthenticated(true); $context->getUser()->addCredential('test_credential'); $context->getUser()->shutdown(); $context->getStorage()->shutdown(); $browser->info('2 - Goto a page, now logged in with the correct credential')->get('/blog')->with('response')->begin()->isStatusCode(200)->info(' 2.1 - The title has the configured placeholder text')->checkElement('.test_title h1', '[Test edit]')->info(' 2.2 - Check for the markup for the editor - should be present now')->checkElement('.test_title h1.test_editable_class_name', 1)->checkElement('.test_body div div:last', 'Lorem ipsum')->end(); $blog->title = 'test blog'; $blog->save(); $form = new BlogForm($blog); $form->useFields(array('title')); $browser->info('3 - Display and submit a simple form')->get('/service/content/form?model=Blog&pk=2&fields[]=title')->with('request')->begin()->isParameter('module', 'ioEditableContent')->isParameter('action', 'form')->end()->with('response')->begin()->isStatusCode(200)->checkForm($form)->checkElement('input[type=hidden][name=model][value=Blog]', 1)->checkElement('input[type=hidden][name=pk][value=' . $blog->id . ']', 1)->checkElement('input[type=hidden][name=form][value="BlogForm"]', 1)->checkElement('input[type=hidden][name=form_partial][value=ioEditableContent/formFields]', 1)->checkElement('input[type=hidden][name=partial][value=]', 1)->checkElement('input[type=hidden][name="method"][value=]', 1)->checkElement('input[type=hidden][name="fields[]"][value=title]', 1)->end()->info(' 3.1 - Submit with errors')->click('save', array('blog' => array('fake_field' => 'val')))->with('request')->begin()->isParameter('module', 'ioEditableContent')->isParameter('action', 'update')->end()->with('response')->begin()->isStatusCode(200)->end(); $browser->info(' 3.2 - check the json response'); $response = $browser->getResponse()->getContent(); $json = json_decode($response); $browser->test()->is($json->error, 'There were 1 errors when submitting the form.', 'The ->error key comes back correctly'); $browser->test()->like($json->response, '/id\\=\\"blog_title\\"/', 'The ->respones key contains the re-rendered form fields'); $browser->test()->like($json->response, '/Unexpected extra form field named \\"fake_field\\"/', '->respones contains the global errors'); $browser->get('/service/content/form?model=Blog&pk=2&fields[]=title')->info(' 3.3 - Submit a valid form')->click('save', array('blog' => array('title' => 'new title')))->with('doctrine')->begin()->check('Blog', array('title' => 'new title'), 1)->end(); $browser->info(' 3.4 - check the json response');
<?php $app = 'frontend'; $fixtures = 'fixtures/fixtures.yml'; require_once dirname(__FILE__) . '/../../bootstrap/functional.php'; $browser = new sfTestFunctional(new sfBrowser(), null, array('propel' => 'sfTesterPropel')); $browser->info('Check that ARRAY columns are loaded'); $criteria = AuthorQuery::create()->filterByHobbies(array('foo', 'bar'), Criteria::CONTAINS_ALL); $browser->with('propel')->begin()->check('Author', $criteria)->end();
<?php require_once dirname(__FILE__) . '/../bootstrap/functional.php'; require_once sfConfig::get('sf_lib_dir') . '/test/unitHelper.php'; $browser = new sfTestFunctional(new sfBrowser()); create_doctrine_test_tree($browser->test()); $browser->info('1 - Goto a url that uses ioDoctrineMenuActions->getMenu()')->get('/actions/get-menu')->with('request')->begin()->isParameter('module', 'test')->isParameter('action', 'getMenu')->end()->with('response')->begin()->isStatusCode(200)->info(' 1.1 - Check for the root ul and its 7 descendants.')->checkElement('ul.root', true)->checkElement('ul.root li', 7)->end(); $browser->info('2 - Goto a url that uses the get_doctrine_menu helper function.')->get('/helper/get-menu')->with('request')->begin()->isParameter('module', 'test')->isParameter('action', 'useHelper')->end()->with('response')->begin()->isStatusCode(200)->info(' 2.1 - Check for the root ul and its 7 descendants.')->checkElement('ul.root', true)->checkElement('ul.root li', 7)->end();
<?php include dirname(__FILE__) . '/../../bootstrap/functional.php'; $browser = new sfTestFunctional(new sfBrowser()); $test = $browser->test(); $conn = Doctrine::getConnectionByTableName('location'); $conn->beginTransaction(); $browser->get('/')->info('1 - homepage')->with('request')->begin()->isParameter('module', 'collector')->isParameter('action', 'locations')->end()->with('response')->begin()->isStatusCode(200)->end(); $browser->get('/data')->info('1.1 - locations data')->with('request')->begin()->isParameter('module', 'collector')->isParameter('action', 'data')->end()->with('response')->begin()->isStatusCode(200)->end(); $browser->info('2 - main links')->get('/')->info('2.1 - profits')->click("Отчёты")->with('request')->begin()->isParameter('module', 'profit')->isParameter('action', 'list')->end()->with('response')->begin()->isStatusCode(200)->end(); $browser->info('2 - main linkчёs')->get('/')->info('2.2 - talks')->click("Обсуждения")->with('request')->begin()->isParameter('module', 'talk')->isParameter('action', 'list')->end()->with('response')->begin()->isStatusCode(200)->end(); $browser->info('2 - main links')->get('/')->info('2.3 - events')->click("События")->with('request')->begin()->isParameter('module', 'event')->isParameter('action', 'list')->end()->with('response')->begin()->isStatusCode(200)->end(); //@todo: make submit check //$browser-> // info('2 - main links')-> // get('/')-> // info('2.4 - search')-> // click("Поиск")-> // with('request')->begin()-> // isParameter('module', 'location')-> // isParameter('action', 'search')-> // end()-> // with('response')->begin()-> // isStatusCode(200)-> // end() //; $browser->info('2 - main links')->get('/')->info('2.5 - signin')->click("Вход")->with('request')->begin()->isParameter('module', 'sfGuardAuth')->isParameter('action', 'signin')->end()->with('response')->begin()->isStatusCode(401)->end(); $browser->info('2 - main links')->get('/')->info('2.6 - signup')->click("Регистрация")->with('request')->begin()->isParameter('module', 'sfApply')->isParameter('action', 'apply')->end()->with('response')->begin()->isStatusCode(200)->end(); $browser->info('3 -footer links')->get('/')->info('3.1- Top')->click("По рейтингу")->with('request')->begin()->isParameter('module', 'collector')->isParameter('action', 'top')->end()->with('response')->begin()->isStatusCode(200)->end(); $browser->info('3 -footer links')->get('/')->info('3.2- Regions')->click("По регионам")->with('request')->begin()->isParameter('module', 'collector')->isParameter('action', 'regions')->end()->with('response')->begin()->isStatusCode(200)->end(); $browser->info('3 -footer links')->get('/')->info('3.3 - Free')->click("Бесплатная рыбалка")->with('request')->begin()->isParameter('module', 'collector')->isParameter('action', 'listFree')->end()->with('response')->begin()->isStatusCode(200)->end();
<?php include dirname(__FILE__) . '/../../bootstrap/functional.php'; $browser = new sfTestFunctional(new sfBrowser()); $browser->get('/scout/index')->with('request')->begin()->isParameter('module', 'scout')->isParameter('action', 'index')->end()->with('response')->begin()->isStatusCode(200)->checkElement('body', '!/This is a temporary page/')->end(); $browser->info('3 - Post a Scout page')->info(' 3.1 - Submit a Scout')->get('/scout/new')->with('request')->begin()->isParameter('module', 'scout')->isParameter('action', 'new')->end();