Example #1
0
 public function testFieldDatetimeWrapper()
 {
     $field = new Field([], [], "any", "label", new DateTime());
     $this->assertInstanceOf('Athens\\Core\\Field\\DateTimeWrapper', $field->getInitial());
     $this->assertContains(date("Y") . "-", (string) $field->getInitial());
 }
Example #2
0
 public function testRenderFieldErrors()
 {
     $writer = new HTMLWriter();
     /* Field not required, no data provided: no field errors */
     $field = new Field([], [], "text", "An unrequired field", "5", false, [], 200);
     $field->validate();
     // Confirm that the field has no errors
     $this->assertEmpty($field->getErrors());
     // Get result and strip quotes, for easier analysis
     $result = $this->stripQuotes($writer->visitField($field));
     // Assert that the result does not display any errors
     $this->assertNotContains("field-errors", $result);
     /* Field required, but no data provided: field errors */
     $field = new Field([], [], "text", "A required field", "5", true, [], 200);
     $field->validate();
     // Confirm that the field has errors
     $this->assertNotEmpty($field->getErrors());
     // Get result and strip quotes, for easier analysis
     $result = $this->stripQuotes($writer->visitField($field));
     // Assert that the result does display errors
     $this->assertContains("field-errors", $result);
 }