public function __construct($data, $question, $case_sensitive, $open_answer) { $this->question = $question; $this->open_answer = $open_answer; $this->case_sensitive = $case_sensitive; parent::__construct($data); }
public function __construct($id_test, $data = array(), $id_nodo_parent = null, $isCloze = false, $savedExerciseType = false) { $this->id_test = $id_test; $this->id_nodo_parent = $id_nodo_parent; $this->isCloze = $isCloze ? 'true' : 'false'; $this->savedExerciseType = $savedExerciseType; parent::__construct($data); }
public function __construct($data, $question, $case_sensitive = false, $modifiable = true) { $dh = $GLOBALS['dh']; $this->question = $question; $this->case_sensitive = $case_sensitive; $this->ordine = array(); $this->answers = array(); $this->modifiable = $modifiable; require_once MODULES_TEST_PATH . '/include/nodeTest.class.inc.php'; $this->questionObj = nodeTest::readNode($this->question); $res = $dh->test_getNodesByParent($this->questionObj->id_nodo); foreach ($res as $k => $v) { $this->questionObj->addChild(nodeTest::readNode($v, $this->questionObj)); } $tmp = array(); foreach ($data as $k => $v) { $tmp[$v['ordine']][] = $v; } parent::__construct($tmp); }
} public function getStylesheets() { return array('/path/to/a/' . $this->getOption('name') . '.css' => 'all'); } } $f = new FormTest(); $f->setWidgets(array('foo' => new MyWidget(array('name' => 'foo')), 'bar' => new MyWidget(array('name' => 'bar')))); $t->is($f->getJavaScripts(), array('/path/to/a/foo.js', '/path/to/a/bar.js'), '->getJavaScripts() returns the stylesheets of all widgets'); $t->is($f->getStylesheets(), array('/path/to/a/foo.css' => 'all', '/path/to/a/bar.css' => 'all'), '->getStylesheets() returns the JavaScripts of all widgets'); // ->getFormFieldSchema() $t->diag('->getFormFieldSchema()'); $f = new NumericFieldsForm(array('5' => 'default')); $t->is_deeply($f->getFormFieldSchema()->getValue(), array('5' => 'default'), '->getFormFieldSchema() includes default numeric fields'); $f->bind(array('5' => 'bound')); $t->is_deeply($f->getFormFieldSchema()->getValue(), array('5' => 'bound'), '->getFormFieldSchema() includes bound numeric fields'); // bind with a simulated file upload in the POST array $f = new FormTest(); try { $f->bind(array('file' => array('name' => 'foo.txt', 'type' => 'text/plain', 'tmp_name' => 'somefile', 'error' => 0, 'size' => 10))); $t->fail('Cannot fake a file upload with a POST'); } catch (InvalidArgumentException $e) { $t->pass('Cannot fake a file upload with a POST'); } $f = new FormTest(); try { $f->bind(array('foo' => array('bar' => array('file' => array('name' => 'foo.txt', 'type' => 'text/plain', 'tmp_name' => 'somefile', 'error' => 0, 'size' => 10))))); $t->fail('Cannot fake a file upload with a POST'); } catch (InvalidArgumentException $e) { $t->pass('Cannot fake a file upload with a POST'); }
$t->is($f1name, 'b', 'iterating on form takes in account ->moveField() operations.'); break; } $f2 = new TestForm2(); $f2->mergeForm($f1); $t->is_deeply(array_keys($f2->getWidgetSchema()->getFields()), array('c', 'd', 'b', 'a'), 'mergeForm() merges fields in the correct order'); // ->getJavaScripts() ->getStylesheets() $t->diag('->getJavaScripts() ->getStylesheets()'); class MyWidget extends sfWidgetForm { protected function configure($options = array(), $attributes = array()) { $this->addRequiredOption('name'); } public function render($name, $value = null, $attributes = array(), $errors = array()) { return null; } public function getJavaScripts() { return array('/path/to/a/' . $this->getOption('name') . '.js'); } public function getStylesheets() { return array('/path/to/a/' . $this->getOption('name') . '.css' => 'all'); } } $f = new FormTest(); $f->setWidgets(array('foo' => new MyWidget(array('name' => 'foo')), 'bar' => new MyWidget(array('name' => 'bar')))); $t->is($f->getJavaScripts(), array('/path/to/a/foo.js', '/path/to/a/bar.js'), '->getJavaScripts() returns the stylesheets of all widgets'); $t->is($f->getStylesheets(), array('/path/to/a/foo.css' => 'all', '/path/to/a/bar.css' => 'all'), '->getStylesheets() returns the JavaScripts of all widgets');
public function __construct($message) { $this->message = $message; parent::__construct(); }
$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'); $t->ok($a1->getWidgetSchema() !== $a->getWidgetSchema(), '__clone() clones the widget schema'); $t->ok($a1->getWidgetSchema() == $a->getWidgetSchema(), '__clone() clones the widget schema'); $t->ok($a1->getErrorSchema() !== $a->getErrorSchema(), '__clone() clones the error schema'); $t->ok($a1->getErrorSchema()->getMessage() == $a->getErrorSchema()->getMessage(), '__clone() clones the error schema'); // mergeForm() $t->diag('mergeForm()'); $f1 = new TestForm1(); $f2 = new TestForm2(); $f1->mergeForm($f2); $widgetSchema = $f1->getWidgetSchema();
public function __construct($id_course) { $this->id_course = $id_course; parent::__construct(); }
public static function setUpBeforeClass() { global $specs; self::$form = new Form($specs); }
public function __construct($id_test, $data = array(), $id_nodo_parent = null) { $this->id_test = $id_test; $this->id_nodo_parent = $id_nodo_parent; parent::__construct($data); }