public function test_exception_3() { $session = new stack_cas_session(null); $this->setExpectedException('stack_exception'); $at1 = new stack_cas_text("Hello world", $session, "abc"); $at1->get_valid(); }
/** * Validate a CAS text field. * @param array $errors the errors array that validation is assembling. * @param string $value the submitted value validate. * @param string $fieldname the name of the field add any errors to. * @param string $savesession the array key to save the session to in $this->validationcasstrings. * @return array updated $errors array. */ protected function validate_cas_text($errors, $value, $fieldname, $fixingdollars, $session = null) { if (!$fixingdollars && strpos($value, '$$') !== false) { $errors[$fieldname][] = stack_string('forbiddendoubledollars'); } $castext = new stack_cas_text($value, $session, $this->seed, 't'); if (!$castext->get_valid()) { $errors[$fieldname][] = $castext->get_errors(); return $errors; } // Validate any [[facts:...]] tags. $unrecognisedtags = stack_fact_sheets::get_unrecognised_tags($value); if ($unrecognisedtags) { $errors[$fieldname][] = stack_string('unrecognisedfactstags', array('tags' => implode(', ', $unrecognisedtags))); return $errors; } if ($session) { $display = $castext->get_display_castext(); if ($castext->get_errors()) { $errors[$fieldname][] = $castext->get_errors(); return $errors; } } return $errors; }
public function test_empty_strings() { $s = '@"This is a string"@ whereas this is empty @""@.'; $at2 = new stack_cas_text($s, null, 0, 't'); $this->assertTrue($at2->get_valid()); $at2->get_display_castext(); $this->assertEquals($at2->get_display_castext(), '\\(\\mbox{This is a string}\\) whereas this is empty \\(\\mbox{ }\\).'); }