selenium ide testing and db resets
2 posts by 1 authors in: Forums > CMS Builder
Last Post: June 5, 2014 (RSS)
By kitsguru - June 5, 2014
I am using selenium ide to test my app. I need to automate restoring my database to a pre-test state which contains seed data but not the updates performed by the tests.
Any suggestions or scripts would be welcomed.
By kitsguru - June 5, 2014
Solved my problem.
Got the database into the state I wanted it. Then used the Admin section to backup the database.
I renamed the file testData.sql.php and moved it to my development folder with the following script.
Simple script
<?php
// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('','../','../../','../../../');
foreach ($dirsToCheck as $dir) {
if (@include_once("$dir$libraryPath")) {
break;
}
}
if (!function_exists('getRecords')) {
die("Couldn't load viewer library, check filepath in sourcecode.");
}
$filepath = __DIR__."/testData.sql.php";
restoreDatabase($filepath, '');
echo "done";