コード例 #1
0
ファイル: ContentListTest.php プロジェクト: slemoigne/sympal
<?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();
コード例 #2
0
ファイル: InstallTest.php プロジェクト: slemoigne/sympal
<?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);
コード例 #3
0
ファイル: SanityCheckTest.php プロジェクト: sympal/sympal
<?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');
コード例 #4
0
ファイル: RedirectsTest.php プロジェクト: slemoigne/sympal
<?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();
コード例 #5
0
ファイル: SanityCheckTest.php プロジェクト: slemoigne/sympal
<?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');
コード例 #6
0
ファイル: NoSympalTest.php プロジェクト: slemoigne/sympal
<?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();
コード例 #7
0
ファイル: SitemapTest.php プロジェクト: slemoigne/sympal
<?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();
コード例 #8
0
ファイル: ActionsTest.php プロジェクト: slemoigne/sympal
<?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();
コード例 #9
0
ファイル: ConfigurationTest.php プロジェクト: sympal/sympal
<?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', ' / ');
コード例 #10
0
ファイル: AdminGenTest.php プロジェクト: slemoigne/sympal
<?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();
}