function testTheme(sfSympalTestFunctional $browser, $expected, $explanation, $contentTheme = null, $contentTypeTheme = null, $siteTheme = null) { $browser->info('... setting up theme data'); $content = Doctrine_Core::getTable('sfSympalContent')->findOneBySlug('sample-page'); $content->theme = $contentTheme; $content->save(); $content->Type->theme = $contentTypeTheme; $content->Type->save(); $content->Site->theme = $siteTheme; $content->Site->save(); $browser->info(' Content = ' . ($contentTheme ? $contentTheme : '(none)'))->info(' ContentType = ' . ($contentTypeTheme ? $contentTypeTheme : '(none)'))->info(' Site = ' . ($siteTheme ? $siteTheme : '(none)'))->get('/sample-page')->info(' ' . $explanation)->with('theme')->begin()->isCurrentTheme($expected)->end(); // spacing after the test $browser->info(''); $browser->info(''); }
<?php /** * Testing the sympal_content actions class */ $app = 'sympal'; require_once dirname(__FILE__) . '/../../bootstrap/functional.php'; $browser = new sfSympalTestFunctional(new sfBrowser()); $browser->signinAsAdmin(); $types = Doctrine_Core::getTable('sfSympalContentType')->getAllContentTypes(); $pageType = Doctrine_Core::getTable('sfSympalContentType')->findOneBySlug('page'); $admin = Doctrine_Core::getTable('sfGuardUser')->findOneByUsername('admin'); $contents = Doctrine_Core::getTable('sfSympalContent')->createQuery()->execute(); $content = new sfSympalContent(); $content->setType($pageType); $contentForm = new sfSympalContentForm($content); $browser->info('1 - Test the new action')->info(' 1.1 - Going to the new action directly displays a menu of the content types')->get('/admin/content/manage/new')->with('request')->begin()->isParameter('module', 'sympal_content')->isParameter('action', 'new')->end()->isForwardedTo('sympal_content', 'chooseNewType')->with('response')->begin()->isStatusCode(200)->checkElement('h1', '/Add new content/')->checkElement('ul.new-content-type li', 3)->end()->info(sprintf(' 1.2 - Click on the %s new content', $pageType->name))->click('Create ' . $pageType->label)->with('request')->begin()->isParameter('module', 'sympal_content')->isParameter('action', 'create_type')->isParameter('type', $pageType->id)->end()->with('response')->begin()->isStatusCode(200)->checkElement('h1', 'Create New ' . $pageType->label)->checkForm($contentForm)->end()->info(' 1.3 - Create a new piece of content')->click('Save')->with('request')->begin()->isParameter('module', 'sympal_content')->isParameter('action', 'create')->end()->with('form')->begin()->hasErrors(1)->isError('TypeForm[title]')->end()->click('Save', array('sf_sympal_content' => array('page_title' => 'test page title', 'TypeForm' => array('title' => 'New page title')))); $createdContent = Doctrine_Core::getTable('sfSympalContent')->findOneByPageTitle('test page title'); $browser->info(' 1.4 - See that the sfSympalContent and sfSympalPage entries were created')->with('doctrine')->begin()->check('sfSympalContent', array(), count($contents) + 1)->check('sfSympalContent', array('content_type_id' => $pageType->id, 'created_by_id' => $admin->id, 'page_title' => 'test page title'))->check('sfSympalPage', array('content_id' => $createdContent->id, 'title' => 'New page title'))->end()->with('response')->begin()->isRedirected()->end()->followRedirect()->info(' 1.5 - Edit the form and save again')->click('Save', array('sf_sympal_content' => array('TypeForm' => array('title' => 'new test title'))))->with('request')->begin()->isParameter('module', 'sympal_content')->isParameter('action', 'update')->end()->with('doctrine')->begin()->check('sfSympalPage', array('title' => 'new test title'))->check('sfSympalContent', array(), count($contents) + 1)->end(); $createdContent->delete(); // refresh $contentTypeCount = count($types); $home = Doctrine_Core::getTable('sfSympalContent')->findOneBySlug('home'); $browser->info('2 - Test the content type index, click through the types and edit')->info(' 2.1 - Start at the content types index page')->get('/admin/content')->with('request')->begin()->isParameter('module', 'sympal_content')->isParameter('action', 'content_types_index')->end()->with('response')->begin()->isStatusCode(200)->info(sprintf(' 2.2 There should be %s rows, one for each content type', $contentTypeCount))->checkElement('#sf_admin_content .sf_admin_list tbody tr', $contentTypeCount)->end()->info(' 2.3 - click the "Page" content type to see its index')->click('Page')->with('request')->begin()->isParameter('module', 'sympal_content')->isParameter('action', 'list_type')->isParameter('type', 'page')->end()->with('response')->begin()->isStatusCode(200)->info(' 2.4 - There should be 3 pages: Home, Register, Sample Page')->checkElement('#sf_admin_content .sf_admin_list tbody tr', 3)->end()->info(' 2.5 - Click the "Page" entry, takes you to view that page')->click('Home')->with('request')->begin()->isParameter('module', 'sympal_content_renderer')->isParameter('action', 'index')->isParameter('sympal_content_type', 'sfSympalPage')->isParameter('sympal_content_id', $home->id)->end()->info(' 2.6 - Go back to the page index and click edit')->get('/admin/content/manage/type/page')->click('Edit')->with('request')->begin()->isParameter('module', 'sympal_content')->isParameter('action', 'edit')->isParameter('id', $home->id)->end()->info(' 2.7 - Goto the content index page, it will show the page type')->get('/admin/content/manage')->with('request')->begin()->isParameter('module', 'sympal_content')->isParameter('action', 'index')->end()->with('response')->begin()->isStatusCode(200)->checkElement('h1', '/Manage Page Content/')->end()->info(' 2.8 - goto the "view" action of a page, redirects you to the frontend')->get('/admin/content/manage/' . $home->id . '/view')->with('request')->begin()->isParameter('module', 'sympal_content')->isParameter('action', 'view')->end()->with('response')->begin()->isRedirected(true)->end()->followRedirect()->with('request')->begin()->isParameter('action', 'index')->isParameter('sympal_content_type', 'sfSympalPage')->isParameter('sympal_content_id', $home->id)->end(); // count the number of true (non-column) slots $trueSlots = 0; $trueSlot = null; foreach ($home->Slots as $slot) { if (!$slot->is_column) { $trueSlot = $slot; // just retrieve one of the true slots for use
<?php require_once dirname(__FILE__) . '/../bootstrap/functional.php'; $browser = new sfSympalTestFunctional(new sfBrowser()); $browser->signInAsAdmin(); $browser->get('/'); $browser->info('1 - Test that all the menu items display with a link'); $menuItems = Doctrine_Core::getTable('sfSympalMenuItem')->findAll(); $i = 1; foreach ($menuItems as $menuItem) { if ($menuItem->level <= 0 || $menuItem->requires_auth || $menuItem->requires_no_auth || !($content = $menuItem->getContent())) { continue; } $browser->info(sprintf(' 1.%s - Checking %s menu item', $i++, $menuItem->getLabel()))->click($menuItem->getLabel())->with('response')->begin()->isStatusCode('200')->end()->with('request')->begin()->isParameter('module', 'sympal_content_renderer')->isParameter('action', 'index')->end(); } $browser->info('2 - Testing the login to the admin')->get('/security/signin')->click('input[type="submit"]', array('signin' => array('username' => 'admin', 'password' => 'admin')), array('method' => 'post', '_with_csrf' => true))->with('response')->begin()->isRedirected()->followRedirect()->end()->with('user')->begin()->isAuthenticated()->end()->get('/admin/dashboard')->with('request')->begin()->isParameter('module', 'sympal_dashboard')->isParameter('action', 'index')->end(); $browser->signOut(); $browser->info('3 - Testing the registration form')->get('/register')->click('input[type="submit"]', array('sf_guard_user' => array('first_name' => 'Jonathan', 'last_name' => 'Wage', 'email_address' => '*****@*****.**', 'username' => 'test', 'password' => 'test', 'password_again' => 'test')), array('method' => 'post', '_with_csrf' => true))->with('response')->begin()->isRedirected()->followRedirect()->end()->info(' 3.1 - Attempt to signin after the registration')->signOut()->click('Signin')->click('input[type="submit"]', array('signin' => array('username' => 'test', 'password' => 'test')), array('method' => 'post', '_with_csrf' => true))->with('user')->begin()->isAuthenticated()->end()->signOut(); $browser->info('4 - Test that loading a page takes only one query'); $profiler = new Doctrine_Connection_Profiler(); $conn = Doctrine_Manager::connection(); $conn->addListener($profiler); // Test base query count for pulling a page is 2 $browser->get('/pages/home'); $count = 0; foreach ($profiler as $event) { if ($event->getName() == 'execute') { $count++; } } $browser->test()->is($count, 1, 'Make sure we do not have more than 1 query');
<?php if (!isset($app)) { $app = 'sympal'; } require_once dirname(__FILE__) . '/../fixtures/project/config/ProjectConfiguration.class.php'; $configuration = ProjectConfiguration::getApplicationConfiguration($app, 'test', isset($debug) ? $debug : true); require_once dirname(__FILE__) . '/../bootstrap/cleanup.php'; sfSympalConfig::writeSetting('installed', false); sfContext::createInstance($configuration); $browser = new sfSympalTestFunctional(new sfBrowser()); $browser->get('/install'); $install = array('install' => array('user' => array('first_name' => 'Jonathan', 'last_name' => 'Wage', 'email_address' => '*****@*****.**', 'username' => 'jwage', 'password' => 'changeme', 'password_again' => 'changeme'))); $browser->click('Install Now', $install)->with('response')->begin()->isRedirected()->followRedirect()->end()->with('request')->begin()->isParameter('module', 'sympal_dashboard')->end()->with('user')->begin()->isAuthenticated()->end(); sfSympalConfig::writeSetting('installed', true);
<?php require_once dirname(__FILE__) . '/../bootstrap/functional.php'; $browser = new sfSympalTestFunctional(new sfBrowser()); $browser->signInAsAdmin(); $browser->get('/'); // Make sure we can click each menu item in the menu $menuItems = Doctrine_Core::getTable('sfSympalMenuItem')->findAll(); foreach ($menuItems as $menuItem) { if ($menuItem->level <= 0 || $menuItem->requires_auth || $menuItem->requires_no_auth || !($content = $menuItem->getContent())) { continue; } $browser->click($menuItem->getLabel())->with('response')->begin()->isStatusCode('200')->end()->with('request')->begin()->isParameter('module', 'sympal_content_renderer')->isParameter('action', 'index')->end(); } $browser->get('/security/signin')->click('input[type="submit"]', array('signin' => array('username' => 'admin', 'password' => 'admin')), array('method' => 'post', '_with_csrf' => true))->with('response')->begin()->isRedirected()->followRedirect()->end()->with('user')->begin()->isAuthenticated()->end()->get('/admin/dashboard')->with('request')->begin()->isParameter('module', 'sympal_dashboard')->isParameter('action', 'index')->end(); $browser->signOut(); $browser->get('/register')->click('input[type="submit"]', array('sf_guard_user' => array('first_name' => 'Jonathan', 'last_name' => 'Wage', 'email_address' => '*****@*****.**', 'username' => 'test', 'password' => 'test', 'password_again' => 'test')), array('method' => 'post', '_with_csrf' => true))->with('response')->begin()->isRedirected()->followRedirect()->end(); $browser->signOut()->click('Signin')->click('input[type="submit"]', array('signin' => array('username' => 'test', 'password' => 'test')), array('method' => 'post', '_with_csrf' => true))->with('user')->begin()->isAuthenticated()->end()->signOut(); $profiler = new Doctrine_Connection_Profiler(); $conn = Doctrine_Manager::connection(); $conn->addListener($profiler); // Test base query count for pulling a page is 2 $browser->get('/pages/home'); $count = 0; foreach ($profiler as $event) { if ($event->getName() == 'execute') { $count++; } } $browser->test()->is($count, 1, 'Make sure we do not have more than 1 query');
<?php $app = 'sympal'; require_once dirname(__FILE__) . '/../bootstrap/functional.php'; $browser = new sfSympalTestFunctional(new sfBrowser()); $redirect = new sfSympalRedirect(); $redirect->source = '/test_redirect1/:parameter1/ok/:parameter2'; $redirect->destination = '@redirect_route'; $redirect->site_id = sfSympalContext::getInstance()->getSite()->getId(); $redirect->save(); $redirect = new sfSympalRedirect(); $redirect->source = '/test_redirect2'; $redirect->site_id = sfSympalContext::getInstance()->getSite()->getId(); $redirect->content_id = 1; $redirect->save(); $redirect = new sfSympalRedirect(); $redirect->source = '/test_redirect3/:parameter1/ok/:parameter2'; $redirect->destination = '/some/path/ok/:parameter2'; $redirect->site_id = sfSympalContext::getInstance()->getSite()->getId(); $redirect->save(); $browser->clearCache(); $browser->get('/test_redirect1/test1/ok/test2')->with('response')->begin()->isStatusCode(301)->isRedirected()->followRedirect()->end()->with('request')->begin()->isParameter('module', 'test')->isParameter('action', 'redirect')->isParameter('parameter1', 'test1')->end(); $browser->get('/test_redirect2')->with('response')->begin()->isStatusCode(301)->isRedirected()->followRedirect()->end()->with('request')->begin()->isParameter('module', 'sympal_content_renderer')->isParameter('action', 'index')->end()->with('response')->begin()->matches('/Sample Content List/')->end(); $browser->get('/test_redirect3/test1/ok/test2')->with('response')->begin()->isStatusCode(301)->isRedirected()->followRedirect()->end()->with('request')->begin()->isParameter('module', 'test')->isParameter('action', 'redirect')->isParameter('parameter2', 'test2')->end();
<?php $app = 'sympal'; require_once dirname(__FILE__) . '/../../bootstrap/functional.php'; $browser = new sfSympalTestFunctional(new sfBrowser()); $browser->signinAsAdmin(); $browser->info('1 - Test some basic submission of the config form')->get('/admin/configuration')->with('request')->begin()->isParameter('module', 'sympal_config')->isParameter('action', 'index')->end()->with('response')->begin()->isStatusCode(200)->checkElement('h1', '/System Settings/')->checkForm('sfSympalConfigForm')->end()->info(' 1.1 - Change a few settings and save')->click('Save', array('settings' => array('default_rendering_action' => 'test', 'content_list' => array('rows_per_page' => 65))))->with('request')->begin()->isParameter('module', 'sympal_config')->isParameter('action', 'save')->end()->with('response')->begin()->isRedirected()->end()->followRedirect(); $browser->info(' 1.2 - Check that the application app.yml was updated with the changed config'); $appYaml = sfYaml::load(sfConfig::get('sf_apps_dir') . '/sympal/config/app.yml'); $browser->test()->is($appYaml['all']['sympal_config']['default_rendering_action'], 'test'); $browser->test()->is($appYaml['all']['sympal_config']['content_list']['rows_per_page'], 65);
<?php $app = 'sympal'; require_once dirname(__FILE__) . '/../bootstrap/functional.php'; $browser = new sfSympalTestFunctional(new sfBrowser()); $browser->signInAsAdmin(); $adminGenModules = array('sympal_users' => '/admin/security/user', 'sympal_groups' => '/admin/security/group', 'sympal_permissions' => '/admin/security/permission', 'sympal_content' => '/admin/content/manage', 'sympal_content_types' => '/admin/content/types', 'sympal_sites' => '/admin/sites'); foreach ($adminGenModules as $adminGenModule => $url) { $browser->get($url)->with('response')->begin()->isStatusCode('200')->end()->with('request')->begin()->isParameter('module', $adminGenModule)->end()->click('Edit')->with('request')->begin()->isParameter('module', $adminGenModule)->isParameter('action', 'edit')->end()->click('Save', array(), array('_with_csrf' => true))->with('response')->begin()->isStatusCode('302')->isRedirected()->followRedirect()->end(); }
<?php $app = 'sympal'; require_once dirname(__FILE__) . '/../../bootstrap/functional.php'; $browser = new sfSympalTestFunctional(new sfBrowser()); $browser->info('2 - Test the signin action')->get('/admin')->with('request')->begin()->isParameter('module', 'sympal_admin')->isParameter('action', 'signin')->end()->with('response')->begin()->isStatusCode(200)->checkElement('h1', '/Signin/')->end()->info(' 2.1 - Sign into the form successfully')->click('Signin', array('signin' => array('username' => 'admin', 'password' => 'admin')))->with('form')->begin()->hasErrors(0)->end()->with('request')->begin()->isParameter('module', 'sympal_admin')->isParameter('action', 'signin')->end()->info(' 2.2 - Post-signin should redirect to the dashboard')->with('response')->begin()->isRedirected()->end()->followRedirect()->with('request')->begin()->isParameter('module', 'sympal_dashboard')->isParameter('action', 'index')->end()->info(' 2.3 - Going back to /admin will automatically redirect to the dashboard')->get('/admin')->with('response')->begin()->isRedirected()->end()->followRedirect()->with('request')->begin()->isParameter('module', 'sympal_dashboard')->isParameter('action', 'index')->end(); $browser->info('2 - Test the phpinfo page')->get('/admin/phpinfo')->with('request')->begin()->isParameter('module', 'sympal_admin')->isParameter('action', 'phpinfo')->end()->with('response')->begin()->isStatusCode(200)->matches('/PHP Version/')->end(); $browser->info('3 - Test the check server action')->get('/admin/check_server')->with('request')->begin()->isParameter('module', 'sympal_admin')->isParameter('action', 'check_server')->end()->with('response')->begin()->isStatusCode(200)->end(); $browser->signinAsAdmin(); $browser->info('4 - Test the clear_cache action')->get('/admin/clear_cache')->with('request')->begin()->isParameter('module', 'sympal_admin')->isParameter('action', 'clear_cache')->end()->with('response')->begin()->isStatusCode(200)->checkElement('h1', '/Clearing Cache/')->end(); $caches = array('config', 'i18n', 'routing', 'module', 'template', 'menu'); $i = 1; foreach ($caches as $cache) { $browser->info(sprintf(' 4.%d - Clearing %s cache', $i++, $cache))->get('/admin/clear_cache?type=' . $cache)->with('response')->begin()->isStatusCode(200)->end(); }
<?php $app = 'no_sympal'; require_once dirname(__FILE__) . '/../bootstrap/functional.php'; $browser = new sfSympalTestFunctional(new sfBrowser()); $browser->get('/')->with('request')->begin()->isParameter('module', 'test')->isParameter('action', 'index')->end();
<?php require_once dirname(__FILE__) . '/../bootstrap/functional.php'; $browser = new sfSympalTestFunctional(new sfBrowser()); $browser->get('/sitemap.xml')->with('response')->begin()->isStatusCode('200')->isValid()->matches('/http:\\/\\//')->matches('/sample-page/')->end()->with('request')->begin()->isParameter('module', 'sympal_default')->isParameter('action', 'sitemap')->end();
<?php /** * A functional test for sfSympalActions - as close to a unit test as * we could get * * @package sfSympalPlugin * @subpackage test * @author Jonathan H. Wage <*****@*****.**> * @author Ryan Weaver <*****@*****.**> */ require_once dirname(__FILE__) . '/../bootstrap/functional.php'; $browser = new sfSympalTestFunctional(new sfBrowser()); $browser->signInAsAdmin(); $browser->info('1 - Test the ask confirmation action')->get('/test/ask_confirmation')->click('Yes')->with('request')->begin()->isParameter('sympal_ask_confirmation', 1)->isParameter('yes', 'Yes')->end()->with('response')->begin()->matches('/Ok!/')->end()->get('/admin/dashboard')->get('/test/ask_confirmation')->click('No')->with('response')->begin()->isRedirected()->followRedirect()->end()->with('request')->begin()->isParameter('module', 'sympal_dashboard')->isParameter('action', 'index')->end(); $browser->info('2 - Test the ->forwardToRoute() method')->info(' 2.1 - Test using the ?var=val query params')->get('/test/forward_to_route')->with('request')->begin()->isParameter('module', 'test')->isParameter('action', 'route_to_forward_to')->isParameter('param1', 'value1')->isParameter('param2', 'value2')->end()->info(' 2.2 - Test using the array formation of variables')->get('/test/forward_to_route2')->with('request')->begin()->isParameter('module', 'test')->isParameter('action', 'route_to_forward_to')->isParameter('param1', 'value1')->isParameter('param2', 'value2')->end(); $browser->info('3 - Test the ->goBack() method')->get('/test/start_go_back')->get('/test/go_back')->with('response')->begin()->info(' 3.1 - Using ->goBack() causes a redirect')->isRedirected()->followRedirect()->end()->with('request')->begin()->info(' 3.2 - The final resting place is the original action')->isParameter('module', 'test')->isParameter('action', 'start_go_back')->end(); $site = Doctrine_Core::getTable('sfSympalSite')->createQuery('s')->fetchOne(); $site->theme = 'wordpress_default'; $site->save(); $browser->info('4 - Test theme-related operations')->info(' 4.1 - Goto a theme that sets nothing, see default theme')->get('/theme/default')->with('theme')->begin()->isCurrentTheme('default')->end()->info(' 4.2 - Goto an action and explicitly set the test theme')->get('/theme/set_test_theme')->with('theme')->begin()->isCurrentTheme('test')->end()->info(' 4.3 - Goto an action that uses the site\'s theme, which is set to wordpress')->get('/theme/set_site_theme')->with('theme')->begin()->isCurrentTheme('wordpress_default')->end();
<?php require_once dirname(__FILE__) . '/../bootstrap/functional.php'; $browser = new sfSympalTestFunctional(new sfBrowser()); $browser->signInAsAdmin(); $browser->get('/test/ask_confirmation')->click('Yes')->with('request')->begin()->isParameter('sympal_ask_confirmation', 1)->isParameter('yes', 'Yes')->end()->with('response')->begin()->matches('/Ok!/')->end()->get('/admin/dashboard')->get('/test/ask_confirmation')->click('No')->with('response')->begin()->isRedirected()->followRedirect()->end()->with('request')->begin()->isParameter('module', 'sympal_dashboard')->isParameter('action', 'index')->end(); $browser->get('/test/forward_to_route')->with('request')->begin()->isParameter('module', 'test')->isParameter('action', 'route_to_forward_to')->isParameter('param1', 'value1')->isParameter('param2', 'value2')->end(); $browser->get('/test/forward_to_route2')->with('request')->begin()->isParameter('module', 'test')->isParameter('action', 'route_to_forward_to')->isParameter('param1', 'value1')->isParameter('param2', 'value2')->end(); $browser->get('/test/start_go_back')->get('/test/go_back')->with('response')->begin()->isRedirected()->followRedirect()->end()->with('request')->begin()->isParameter('module', 'test')->isParameter('action', 'start_go_back')->end(); $browser->get('/test/change_layout'); $response = $browser->getResponse(); $stylesheets = $response->getStylesheets(); $browser->test()->is(isset($stylesheets['test']), true); $browser->with('response')->begin()->matches('/Test Layout/')->end();
<?php require_once dirname(__FILE__) . '/../bootstrap/functional.php'; $browser = new sfSympalTestFunctional(new sfBrowser()); $browser->signInAsAdmin(); $browser->get('/admin/configuration')->click('Save', array('settings' => array('breadcrumbs_separator' => ' / ', 'plugin_api' => array('username' => 'test', 'password' => 'test')))); $after = sfYaml::load(sfConfig::get('sf_app_dir') . '/config/app.yml'); $t = $browser->test(); $t->is($after['all']['sympal_config']['breadcrumbs_separator'], ' / ', 'Test breadcrumbs separator saved'); $t->is($after['all']['sympal_config']['plugin_api']['username'], 'test', 'Test plugin_api.username saved'); $t->is($after['all']['sympal_config']['plugin_api']['password'], 'test', 'Test plugin_api.password saved'); sfSympalConfig::writeSetting('breadcrumbs_separator', ' / ');
<?php $app = 'sympal'; require_once dirname(__FILE__) . '/../../bootstrap/functional.php'; $browser = new sfSympalTestFunctional(new sfBrowser()); $browser->signinAsAdmin(); $browser->info('1 - Goto the links chooser and examine it')->get('/editor/links')->with('request')->begin()->isParameter('module', 'sympal_editor')->isParameter('action', 'links')->end()->with('response')->begin()->isStatusCode(200)->info(' 1.1 - The 3 different content types show up in the #content_types div')->checkElement('#content_types li', 3)->info(' 1.2 - Check for the #links_chooser div')->checkElement('#links_chooser', true)->end();
<?php /** * Functional testing for sfSympalCommentsPlugin * * @author Jon Wage <*****@*****.**> * @author Ryan Weaver <*****@*****.**> * @since 2010-01-22 * @version svn:$Id$ $Author$ */ require_once dirname(__FILE__) . '/../bootstrap/functional.php'; $browser = new sfSympalTestFunctional(new sfBrowser()); $browser->setTester('doctrine', 'sfTesterDoctrine'); $goodValues = array('website' => 'http://www.sympalphp.org', 'body' => 'Hey, nice test comment!'); $browser->info('1 - Sign in and post some comments')->signInAsAdmin()->get('/blog-post/sample_blogpost')->with('response')->begin()->isStatusCode(200)->checkElement('#sympal_comments', true)->checkForm('sfSympalNewCommentForm')->end()->info(' 1.1 - Submit a bad form, count the errors')->click('Save Comment', array('sf_sympal_comment' => array('website' => 'bad site')))->with('form')->begin()->hasErrors(2)->isError('body', 'required')->isError('website', 'invalid')->end()->click('Save Comment', array('sf_sympal_comment' => $goodValues))->with('form')->begin()->hasErrors(0)->end()->with('request')->begin()->isParameter('module', 'sympal_comments')->isParameter('action', 'create')->end(); Doctrine_Core::getTable('sfSympalBlogPost')->getConnection()->clear(); $sympalAdmin = Doctrine_Core::getTable('sfGuardUser')->findOneByUsername('admin'); $browser->with('response')->isRedirected()->followRedirect()->with('response')->begin()->matches('/comment_1/')->matches('/Posted on (.*) by/')->info(' 1.2 - Check that the website is surrounded by a nofollow')->checkElement('a[rel="nofollow"][href="' . $goodValues['website'] . '"]', '/Sympal Admin/')->end()->with('doctrine')->begin()->check('sfSympalComment', array_merge($goodValues, array('user_id' => $sympalAdmin->id)))->end(); $goodValues = array('email_address' => '*****@*****.**', 'body' => 'just another test comment'); $browser->info('2 - Post some comments anonymously')->signOut()->get('/blog-post/sample_blogpost')->with('response')->begin()->isStatusCode(200)->checkElement('#sympal_comments', true)->checkForm('sfSympalNewCommentForm')->end()->info(' 2.1 - Submit a bad form, count the errors')->click('Save Comment')->with('form')->begin()->hasErrors(2)->isError('body', 'required')->isError('email_address', 'required')->end()->click('Save Comment', array('sf_sympal_comment' => $goodValues))->with('form')->begin()->hasErrors(0)->end()->with('request')->begin()->isParameter('module', 'sympal_comments')->isParameter('action', 'create')->end(); Doctrine_Core::getTable('sfSympalBlogPost')->getConnection()->clear(); $browser->with('response')->isRedirected()->followRedirect()->with('response')->begin()->matches('/comment_2/')->matches('/Posted on (.*) by[\\s]+ anonymous\\./')->end()->with('doctrine')->begin()->check('sfSympalComment', $goodValues)->end();
<?php require_once dirname(__FILE__) . '/../bootstrap/functional.php'; $browser = new sfSympalTestFunctional(new sfBrowser()); $browser->get('/lists/sample-content-list')->with('response')->begin()->isStatusCode(200)->isValid()->end()->with('request')->begin()->isFormat('html')->end(); $browser->get('/lists/sample-content-list.rss')->with('response')->begin()->isStatusCode(200)->isValid()->end()->with('request')->begin()->isFormat('rss')->end();
<?php $app = 'sympal'; require_once dirname(__FILE__) . '/../../bootstrap/functional.php'; $browser = new sfSympalTestFunctional(new sfBrowser()); $browser->signinAsAdmin(); refresh_assets(); $browser->info('Synchronizing the test assets...'); $sync = new sfSympalAssetSynchronizer($configuration->getEventDispatcher()); $sync->run(); $asset = Doctrine_Query::create()->from('sfSympalAsset a')->fetchOne(); $browser->info('1 - Browse around the assets library')->get('/admin/assets')->with('request')->begin()->isParameter('module', 'sympal_assets')->isParameter('action', 'index')->end()->with('response')->begin()->isStatusCode(200)->checkElement('h1', '/Sympal Assets Manager/')->info(' 1.1 - There should be 1 root asset and 2 subdirectories')->checkElement('.asset', 1)->checkElement('.folder', 2)->end()->info(' 1.2 - Click to go into the /screens directory')->click('li.folder a')->with('request')->begin()->isParameter('module', 'sympal_assets')->isParameter('action', 'index')->isParameter('dir', urlencode('/screens'))->end()->with('response')->begin()->isStatusCode(200)->info(' 1.3 - There should be one asset in this directory')->checkElement('.asset', 1)->info(' 1.4 - Check some information on the asset')->checkElement('.asset .size', '/275 Kb/')->checkElement('.asset .dimensions', '/1024x590/')->checkElement('.asset .embed_code', '/[asset:screens-sympalphp]/')->end()->info(' 1.5 - Click to edit the asset')->click('.asset a.edit')->with('request')->begin()->isParameter('module', 'sympal_assets')->isParameter('action', 'edit_asset')->end()->with('response')->begin()->isStatusCode(200)->checkElement('h1', '/Editing Asset "sympalphp.png"/')->end()->info(' 1.6 - Goto an edit of an asset just as a sanity check')->get('/admin/assets/edit/asset/' . $asset->id)->with('response')->begin()->isStatusCode(200)->end(); $browser->info('2 - Test the asset selector')->get('/assets/select')->with('request')->begin()->isParameter('module', 'sympal_assets')->isParameter('action', 'select')->end()->with('response')->begin()->isStatusCode(200)->checkElement('h1', '/Asset Browser/')->end();