/** * function : recursive_file_list * Recursively gets all the files and folders from a given folder */ function recursive_file_list($base_dir, $extension = null) { $list = array(); $scan_result = @scandir($base_dir); if ($scan_result) { foreach (scandir($base_dir) as $file) { if ($file == '.' || $file == '..') { continue; } $dir = $base_dir . '/' . $file; if ($extension != null) { $ext = substr($dir, -1 * (strlen($extension) + 1)); if (is_dir($dir)) { $l = recursive_file_list($dir, $extension); if ($l) { $list = array_merge($list, $l); } } else { if ($ext != ".{$extension}") { // echo $dir . " | " . ".{$extension}" . " | " . $ext . "<br>"; continue; } else { $list[] = $dir; } } } else { if (is_dir($dir)) { $l = recursive_file_list($dir); if ($l) { $list = array_merge($list, $l); } } else { $list[] = $dir; } } } } return $list; }
$xcontext_path = $test_path . "/features/bootstrap/MyContext.php"; $xcontext = $_POST['context']; if (trim($xcontext) == "") { $error_msg = "Empty Context posted. Have you removed it by mistake? {$xcontext_path}"; } else { if (file_put_contents($xcontext_path, $xcontext, LOCK_EX) === FALSE) { $error_msg = "Could not write MyContext.php. Check file permission. {$xcontext_path}"; } else { $success_msg = "Behat Context updated."; } } } if (!empty($xapplication)) { $feature_folder = $test_path . "/features"; // echo $feature_folder; $features = recursive_file_list($feature_folder, "feature"); foreach ($features as $feature) { $feature_file = str_replace("\\", "/", $feature); $feature_base = @basename($feature_file); $cat = @basename(dirname($feature_file)); $feature_categories[] = $cat; $feature_path_all[] = $feature_file; } $feature_categories = array_unique($feature_categories, SORT_STRING); asort($feature_categories); if (in_array($xcategory, $feature_categories)) { for ($i = 0; $i < sizeof($feature_path_all); $i++) { $cat = @basename(dirname($feature_path_all[$i])); if ($cat == $xcategory && basename($feature_path_all[$i]) != 'dummy.feature') { // echo $feature_path_all[$i] . "<br>"; $feature_path[] = $feature_path_all[$i];