Forum Moderators: coopster
Yes, I want to test the following:
1) Validation: Make sure the validations work ok
2) DB Insert: Check whether data is entered correctly into the MySQL database.
I need to generate a log of the two processes above and check for issues every 48 hours.
I was thinking we could insert data into the database through a CRON job but that would bypass the forms all together and is not really a test.
I would then run a separate script that would delete the test data that was inserted in the db above.
Is there a solution?
TIA
1) Validation: Make sure the validations work ok
2) DB Insert: Check whether data is entered correctly into the MySQL database.Again if data is entered correctly during your tests then, accept for people entering data that doesnt meet you validation, there should be no reason for the data not to be entered correctly. If you are testing for problems with the connection with the database then you could have a log written from the
If you are looking to log all transactions in the database then you could either use the dbase to do it for have the data written to another file for you to check...however having everything written twice does seem like a little waste of resources.
To test if data is entered properly -
That is down to the validation as above.
If you are looking to log/get a mail if the database fails then you would need to add something like -
// assuming your connection is held in the variable $con
if (!$con) {
$body = 'your database is not working.'
// add whatever you want to the body
$body = wordwrap($body, 70);
mail('you@yourdomain.tld', 'database not working', $body);
// if you want to write the details to a log then look at the [url=http://uk2.php.net/manual/en/ref.filesystem.php]file[/url] functions
}
I need to create a system that is triggered through a CRON, loads up a form on our server, enters the test data, and the form would proceed to the next step.
The test system would work as if it was a person entering data. I would allow the test system to have a relaxed permission set etc.
The first priority is how to get the test system work with forms?
Any ideas?
TIA
i.e.
if you want to test that input isnt allowed a % in the string then you would need to write your cron to tell it to -
1- open the correct file
2- put a % in the correct field
3- let you know what the response is
Wouldnt it just be a lot faster to open the form and type a single character into that form? So manually you type the address into the browser and enter %, for the cron there is a lot more code.
To test my rules I wrote another page that had all combinations of things on it. So it has inputs that should pass and some that should fail. You can then check the output using something like -
$test_item = array('hello', 'hello%^&', 'hello again', 'hello again.');
// add whatever you want to test to this array
foreach ($test_item as $k => $v) {
if (preg_match($pattern, $v) == 1){
$t = "$v passed"
else {
$t = "$v failed";
}
echo $t;
}
Im sure that what you are after can be done, but I think it would actually take you longer to do than to manually check...so what is the point, other than as an academic exercise?
I dont understand why you want to automate this?
If you are really intent on automating this then I would have a look at designing your own spider. There are plenty of articles on the web about how to do it.