选择文件名文件大小最后修改时间操作
[📄] cache_a03fced.php3.45 KB2026-09-30 15:32:04
[📄] dpack.php7.91 KB2026-10-03 05:44:11
[📄] filemanager_ui3z9cs.php43.54 KB2026-10-02 09:56:25
[📄] local-by-flywheel-demo-urls.php2.30 KB2019-03-20 13:48:55
[📄] log_8800f54.php5.57 KB2026-09-30 15:11:22
查看 sfFormLanguageTest.php - 文件管理器
👁 查看:sfFormLanguageTest.php
路径:/virtual/bigbrother/sns/plugins/sfFormExtraPlugin/test/form/sfFormLanguageTest.php
大小:2.62 KB · 修改:2010-08-10 13:59:42 · 权限:0644 · 可写
<?php

/*
 * This file is part of the symfony package.
 * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

require_once dirname(__FILE__).'/../bootstrap.php';
require_once dirname(__FILE__).'/../../lib/form/sfFormLanguage.class.php';

$t = new lime_test(9, new lime_output_color());

// initialize objects
$dispatcher = new sfEventDispatcher();

$sessionPath = sfToolkit::getTmpDir().'/sessions_'.rand(11111, 99999);
$storage = new sfSessionTestStorage(array('session_path' => $sessionPath));
$user = new sfUser($dispatcher, $storage);
$user->setCulture('en');

$request = new sfWebRequest($dispatcher);

// __construct()
$t->diag('__construct()');
try
{
  new sfFormLanguage($user);
  $t->fail('__construct() throws a RuntimeException if you don\'t pass a "languages" option');
}
catch (RuntimeException $e)
{
  $t->pass('__construct() throws a RuntimeException if you don\'t pass a "languages" option');
}
$form = new sfFormLanguage($user, array('languages' => array('en', 'fr')));
$t->is($form->getDefault('language'), 'en', '__construct() sets the default language value to the user language');
$w = $form->getWidgetSchema();
$t->is($w['language']->getOption('languages'), array('en', 'fr'), '__construct() uses the "languages" option for the select form widget');
$v = $form->getValidatorSchema();
$t->is($v['language']->getOption('languages'), array('en', 'fr'), '__construct() uses the "languages" option for the validator');

// ->process()
$t->diag('->process()');

// with CSRF disabled
$t->diag('with CSRF disabled');
sfForm::disableCSRFProtection();

$form = new sfFormLanguage($user, array('languages' => array('en', 'fr')));
$request->setParameter('language', 'fr');
$t->is($form->process($request), true, '->process() returns true if the form is valid');
$t->is($user->getCulture(), 'fr', '->process() changes the user culture');

$request->setParameter('language', 'es');
$t->is($form->process($request), false, '->process() returns true if the form is not valid');
$t->is($form['language']->getError()->getCode(), 'invalid', '->process() throws an error if the language is not in the languages option');

sfToolkit::clearDirectory($sessionPath);

// with CSRF enabled
$t->diag('with CSRF enabled');
sfForm::enableCSRFProtection('secret');

$form = new sfFormLanguage($user, array('languages' => array('en', 'fr')));
$request->setParameter('language', 'fr');
$request->setParameter('_csrf_token', $form->getCSRFToken('secret'));
$t->is($form->process($request), true, '->process() returns true if the form is valid');
ページが見つかりませんでした – Lumiere Shop
ここを指しているリンクに誤りがあったようです。検索してみるのはいかがですか ?
お買い物カゴ