Exemple #1
0
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');
Exemple #2
0
<?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

$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);
Exemple #4
0
<?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', ' / ');