cvs: pear /DB_DataObject_FormBuilder/tests existingRecordUpdated.phpt newRecordInserted.phpt
| From: | Justin Patrin | Date: | Sat, 30 Jul 2005 23:13:30 +0000 |
| Subject: | cvs: pear /DB_DataObject_FormBuilder/tests existingRecordUpdated.phpt newRecordInserted.phpt | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-33477@lists.php.net to get a copy of this message | ||
justinpatrin Sat Jul 30 19:13:30 2005 EDT
Added files:
/pear/DB_DataObject_FormBuilder/tests existingRecordUpdated.phpt
newRecordInserted.phpt
Log:
Adding tests to check update/insert
http://cvs.php.net/co.php/pear/DB_DataObject_FormBuilder/tests/existingRecordUpdated.phpt?r=1.1&p=1
Index: pear/DB_DataObject_FormBuilder/tests/existingRecordUpdated.phpt
+++ pear/DB_DataObject_FormBuilder/tests/existingRecordUpdated.phpt
--TEST--
existingRecordUpdated
--FILE--
<?php
$_POST = $_REQUEST = array('title' => 'Alien', 'genre_id' =>
'5', 'anotherField' => 'TEST','_qf__dataobject_movie'
=> '');
include(dirname(__FILE__).'/config.php');
$do =& DB_DataObject::factory('movie');
if (!$do->get('title', 'Alien')) {
die('Alien record not found, please re-build the testing DB
');
}
if ($do->anotherField !== '') {
die('Alien record field anotherField is filled out, pleas re-build the testing DB
');
}
$fb =& DB_DataObject_FormBuilder::create($do);
$form =& $fb->getForm();
if ($form->validate()) {
echo 'Validated
';
$form->process(array(&$fb, 'processForm'), false);
$do2 =& DB_DataObject::factory('movie');
if ($do2->get('title', $_POST['title'])) {
echo 'Found
';
if ($do2->anotherField !== 'TEST') {
die('Update failed, anotherField is "'.$do2->anotherField.'"
');
}
$do2->anotherField = '';
$do2->update();
}
} else {
$form->display();
}
?>
--EXPECT--
Validated
Found
http://cvs.php.net/co.php/pear/DB_DataObject_FormBuilder/tests/newRecordInserted.phpt?r=1.1&p=1
Index: pear/DB_DataObject_FormBuilder/tests/newRecordInserted.phpt
+++ pear/DB_DataObject_FormBuilder/tests/newRecordInserted.phpt
--TEST--
newRecordInserted
--FILE--
<?php
$_POST = $_REQUEST = array('title' => 'New movie', 'genre_id' =>
'5', '_qf__dataobject_movie' => '');
include(dirname(__FILE__).'/config.php');
$do2 =& DB_DataObject::factory('movie');
if ($do2->get('title', $_POST['title'])) {
die('Found before insert
');
}
$do =& DB_DataObject::factory('movie');
$fb =& DB_DataObject_FormBuilder::create($do);
$form =& $fb->getForm();
if ($form->validate()) {
echo 'Validated
';
$form->process(array(&$fb, 'processForm'), false);
$do2 =& DB_DataObject::factory('movie');
if ($do2->get('title', $_POST['title'])) {
echo 'Found
';
$do2->delete();
}
} else {
$form->display();
}
?>
--EXPECT--
Validated
Found