当前位置: 首页>>代码示例>>PHP>>正文


PHP sfForm::convertFileInformation方法代码示例

本文整理汇总了PHP中sfForm::convertFileInformation方法的典型用法代码示例。如果您正苦于以下问题:PHP sfForm::convertFileInformation方法的具体用法?PHP sfForm::convertFileInformation怎么用?PHP sfForm::convertFileInformation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sfForm的用法示例。


在下文中一共展示了sfForm::convertFileInformation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: catch

    $t->fail('->getEmbeddedForm() throws an exception if the embedded form does not exist');
} catch (InvalidArgumentException $e) {
    $t->pass('->getEmbeddedForm() throws an exception if the embedded form does not exist');
}
// ::convertFileInformation()
$t->diag('::convertFileInformation()');
$input = array('file' => array('name' => 'test1.txt', 'type' => 'text/plain', 'tmp_name' => '/tmp/test1.txt', 'error' => 0, 'size' => 100), 'file1' => array('name' => 'test2.txt', 'type' => 'text/plain', 'tmp_name' => '/tmp/test1.txt', 'error' => 0, 'size' => 200));
$t->is_deeply(sfForm::convertFileInformation($input), $input, '::convertFileInformation() converts $_FILES to be coherent with $_GET and $_POST naming convention');
$input = array('article' => array('name' => array('file1' => 'test1.txt', 'file2' => 'test2.txt'), 'type' => array('file1' => 'text/plain', 'file2' => 'text/plain'), 'tmp_name' => array('file1' => '/tmp/test1.txt', 'file2' => '/tmp/test2.txt'), 'error' => array('file1' => 0, 'file2' => 0), 'size' => array('file1' => 100, 'file2' => 200)));
$expected = array('article' => array('file1' => array('name' => 'test1.txt', 'type' => 'text/plain', 'tmp_name' => '/tmp/test1.txt', 'error' => 0, 'size' => 100), 'file2' => array('name' => 'test2.txt', 'type' => 'text/plain', 'tmp_name' => '/tmp/test2.txt', 'error' => 0, 'size' => 200)));
$t->is_deeply(sfForm::convertFileInformation($input), $expected, '::convertFileInformation() converts $_FILES to be coherent with $_GET and $_POST naming convention');
$t->is_deeply(sfForm::convertFileInformation($expected), $expected, '::convertFileInformation() only changes the input array if needed');
$input = array('file' => array('name' => 'test.txt', 'type' => 'text/plain', 'tmp_name' => '/tmp/test.txt', 'error' => 0, 'size' => 100), 'article' => array('name' => array('name' => array('name' => 'test1.txt', 'another' => array('file2' => 'test2.txt'))), 'type' => array('name' => array('name' => 'text/plain', 'another' => array('file2' => 'text/plain'))), 'tmp_name' => array('name' => array('name' => '/tmp/test1.txt', 'another' => array('file2' => '/tmp/test2.txt'))), 'error' => array('name' => array('name' => 0, 'another' => array('file2' => 0))), 'size' => array('name' => array('name' => 100, 'another' => array('file2' => 200)))));
$expected = array('file' => array('name' => 'test.txt', 'type' => 'text/plain', 'tmp_name' => '/tmp/test.txt', 'error' => 0, 'size' => 100), 'article' => array('name' => array('name' => array('name' => 'test1.txt', 'type' => 'text/plain', 'tmp_name' => '/tmp/test1.txt', 'error' => 0, 'size' => 100), 'another' => array('file2' => array('name' => 'test2.txt', 'type' => 'text/plain', 'tmp_name' => '/tmp/test2.txt', 'error' => 0, 'size' => 200)))));
$t->is_deeply(sfForm::convertFileInformation($input), $expected, '::convertFileInformation() converts $_FILES to be coherent with $_GET and $_POST naming convention');
$t->is_deeply(sfForm::convertFileInformation($expected), $expected, '::convertFileInformation() converts $_FILES to be coherent with $_GET and $_POST naming convention');
// ->renderFormTag()
$t->diag('->renderFormTag()');
$f = new FormTest();
$t->is($f->renderFormTag('/url'), '<form action="/url" method="post">', '->renderFormTag() renders the form tag');
$t->is($f->renderFormTag('/url', array('method' => 'put')), '<form method="post" action="/url"><input type="hidden" name="sf_method" value="put" />', '->renderFormTag() adds a hidden input tag if the method is not GET or POST');
$f->setWidgetSchema(new sfWidgetFormSchema(array('image' => new sfWidgetFormInputFile())));
$t->is($f->renderFormTag('/url'), '<form action="/url" method="post" enctype="multipart/form-data">', '->renderFormTag() adds the enctype attribute if the form is multipart');
// __clone()
$t->diag('__clone()');
$a = new FormTest();
$a->setValidatorSchema(new sfValidatorSchema(array('first_name' => new sfValidatorString(array('min_length' => 2)))));
$a->bind(array('first_name' => 'F'));
$a1 = clone $a;
$t->ok($a1->getValidatorSchema() !== $a->getValidatorSchema(), '__clone() clones the validator schema');
$t->ok($a1->getValidatorSchema() == $a->getValidatorSchema(), '__clone() clones the validator schema');
开发者ID:Tony-M,项目名称:GrannySymfony,代码行数:31,代码来源:sfFormTest.php


注:本文中的sfForm::convertFileInformation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。