コード例 #1
0
ファイル: sfRequestTest.php プロジェクト: sabaki-dev/symfony1
$t->is(isset($request['foo2']), false, '->offsetExists() returns false if request parameter does not exist');
$t->is($request['foo3'], false, '->offsetGet() returns false if parameter does not exist');
$t->is($request['foo'], 'foo', '->offsetGet() returns parameter by name');
$request['foo2'] = 'foo2';
$t->is($request['foo2'], 'foo2', '->offsetSet() sets parameter by name');
unset($request['foo2']);
$t->is(isset($request['foo2']), false, '->offsetUnset() unsets parameter by name');
// ->getOption()
$t->diag('->getOption()');
$request = new myRequest($dispatcher, array(), array(), array('val_1' => 'value', 'val_2' => false));
$t->is($request->getOption('val_1'), 'value', '->getOption() returns the option value if exists');
$t->is($request->getOption('val_2'), false, '->getOption() returns the option value if exists');
$t->is($request->getOption('none'), null, '->getOption() returns the option value if not exists');
// ->getOption()
$t->diag('->__clone()');
$request = new myRequest($dispatcher);
$requestClone = clone $request;
$t->ok($request->getParameterHolder() !== $requestClone->getParameterHolder(), '->__clone() clone parameterHolder');
$t->ok($request->getAttributeHolder() !== $requestClone->getAttributeHolder(), '->__clone() clone attributeHolder');
$request = new myRequest($dispatcher);
// parameter holder proxy
require_once $_test_dir . '/unit/sfParameterHolderTest.class.php';
$pht = new sfParameterHolderProxyTest($t);
$pht->launchTests($request, 'parameter');
// attribute holder proxy
$pht = new sfParameterHolderProxyTest($t);
$pht->launchTests($request, 'attribute');
// new methods via sfEventDispatcher
require_once $_test_dir . '/unit/sfEventDispatcherTest.class.php';
$dispatcherTest = new sfEventDispatcherTest($t);
$dispatcherTest->launchTests($dispatcher, $request, 'request');