public function testSerializeUnserializeRecord()
 {
     $test = new TestRecord();
     $test->save();
     $object = new SerializeTest();
     $object->objecttest = $test;
     $object->save();
     $object_before = clone $object;
     $serialized = serialize($object);
     $object_after = unserialize($serialized);
     $this->assertIdentical(get_class($object_after->objecttest), 'TestRecord');
 }
예제 #2
0
 function testValidation()
 {
     $r = new TestRecord();
     // required rule should fail
     $this->assertFalse($r->save());
     // string rule should fail
     $r->name = array();
     $this->assertFalse($r->save());
     $r->name = 'test';
     $this->assertTrue($r->save());
     $nonUnique = new TestRecord();
     $nonUnique->name = $r->name;
     // unique rule should fail
     $this->assertFalse($nonUnique->save());
     $this->assertIsA($nonUnique->validator(), 'Naf_Validator');
     $this->assertTrue(is_array($nonUnique->getErrorList()));
     $this->assertTrue(count($nonUnique->getErrorList()) > 0);
 }
예제 #3
0
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['fio'])) {
    $validator = new TestValidation();
    echo $validator->checkTests($_POST);
    $error_div = $validator->showErrors();
    $pd = connectDB();
    if ($_POST["quest1"] == "Leonard Nimoy") {
        $first = 1;
    } else {
        $first = 0;
    }
    if ($_POST['quest2'] == 1) {
        $second = 1;
    } else {
        $second = 0;
    }
    if (isset($_POST['checkboxone']) == true && isset($_POST['checkboxtwo']) == false && isset($_POST['checkboxthree']) == false) {
        $third = 1;
    } else {
        $third = 0;
    }
    $date = date('Y-m-d');
    $fio = $_POST['fio'];
    $test = new TestRecord("tests", $fio, $first, $second, $third, $date);
    $test->save($pd);
}
echo $error_div;
echo "<script>setInterval(function(){\n                history.go(-1);\n                }, 5000);</script>\n                <br><center>Вернетесь обратно через 5 секунд</center>";
?>
</div>
</body>
</html>