public function index($request) { if ($request->is('get')) { $test_directory = str_replace('\\', '/', realpath(\app\lib\Library::retrieve('test_directory'))); $suites = array(); $stats = array(); $store_statistics = \app\lib\Library::retrieve('store_statistics'); $create_snapshots = \app\lib\Library::retrieve('create_snapshots'); $sandbox_errors = \app\lib\Library::retrieve('sandbox_errors'); $use_xml = \app\lib\Library::retrieve('xml_configuration_file'); $xhprof_installed = \app\lib\Library::isXHProfInstalled(); return compact('create_snapshots', 'sandbox_errors', 'stats', 'store_statistics', 'suites', 'test_directory', 'use_xml', 'xhprof_installed'); } $data = array(); if (!empty($request->data['data_keys']) && !empty($request->data['data_values'])) { $data = array_combine($request->data['data_keys'], $request->data['data_values']); } $tests = explode('|', $request->data['test_files']); $vpu = new \app\lib\VPU(); if ($request->data['sandbox_errors']) { error_reporting(\app\lib\Library::retrieve('error_reporting')); set_error_handler(array($vpu, 'handle_errors')); } $xml_config = false; $notifications = array(); if ($request->data['use_xml']) { $xml_config = \app\lib\Library::retrieve('xml_configuration_file'); if (!$xml_config || !($xml_config = realpath($xml_config))) { $notifications[] = array('type' => 'failed', 'title' => 'No Valid XML Configuration File Found', 'message' => 'Please ensure that the ' . '<code>xml_configuration_file</code> in ' . '<code>app/config/bootstrap.php</code> exists and ' . 'has the proper permissions.'); } } $use_xhprof = $request->data['use_xhprof']; list($results, $memory_stats, $xhprof_run_id) = $xml_config ? $vpu->run_with_xml($xml_config, $use_xhprof) : $vpu->run_tests($tests, $data, $use_xhprof); $results = $vpu->compile_suites($results, 'web'); $xhprof_url = false; if ($xhprof_run_id !== false) { $xhprof_url_root = \app\lib\Library::retrieve('xhprof_root') . '/xhprof_html/'; $xhprof_ns = \app\lib\Library::retrieve('xhprof_namespace'); $xhprof_url = $xhprof_url_root . '?source=' . urlencode($xhprof_ns) . '&run=' . urlencode($xhprof_run_id); } if ($request->data['sandbox_errors']) { restore_error_handler(); } $suites = $results['suites']; $stats = $results['stats']; $errors = $vpu->get_errors(); $to_view = compact('suites', 'stats', 'errors', 'memory_stats', 'xhprof_url'); if ($request->data['create_snapshots']) { $notifications[] = $this->_create_snapshot($to_view); } if ($request->data['store_statistics']) { $notifications[] = $this->_store_statistics($stats); } return $to_view + compact('notifications'); }
public function index($request) { if ($request->is('get')) { $test_directory = str_replace('\\', '/', realpath(\app\lib\Library::retrieve('test_directory'))); $suites = array(); $stats = array(); $store_statistics = \app\lib\Library::retrieve('store_statistics'); $create_snapshots = \app\lib\Library::retrieve('create_snapshots'); $sandbox_errors = \app\lib\Library::retrieve('sandbox_errors'); $use_xml = \app\lib\Library::retrieve('xml_configuration_file'); $usable_group_names = \app\lib\Library::retrieve('usable_group_names'); return compact('create_snapshots', 'sandbox_errors', 'stats', 'store_statistics', 'suites', 'test_directory', 'use_xml', 'usable_group_names'); } $tests = explode('|', $request->data['test_files']); $vpu = new \app\lib\VPU(); if ($request->data['sandbox_errors']) { error_reporting(\app\lib\Library::retrieve('error_reporting')); set_error_handler(array($vpu, 'handle_errors')); } $xml_config = false; $notifications = array(); if ($request->data['use_xml']) { $xml_config = \app\lib\Library::retrieve('xml_configuration_file'); if (!$xml_config || !($xml_config = realpath($xml_config))) { $notifications[] = array('type' => 'failed', 'title' => 'No Valid XML Configuration File Found', 'message' => 'Please ensure that the ' . '<code>xml_configuration_file</code> in ' . '<code>app/config/bootstrap.php</code> exists and ' . 'has the proper permissions.'); } } $extraConfiguration = array(); if (isset($request->data['use_group_name']) && $request->data['use_group_name'] != '') { $extraConfiguration['use_group_name'] = $request->data['use_group_name']; } else { if (isset($request->data['run_specific_test']) && $request->data['run_specific_test'] != '') { $extraConfiguration['run_specific_test'] = $request->data['run_specific_test']; } } $results = $xml_config ? $vpu->run_with_xml($xml_config, $extraConfiguration) : $vpu->run_tests($tests); $results = $vpu->compile_suites($results, 'web'); if ($request->data['sandbox_errors']) { restore_error_handler(); } $suites = $results['suites']; $stats = $results['stats']; $errors = $vpu->get_errors(); $to_view = compact('suites', 'stats', 'errors'); if ($request->data['create_snapshots']) { $notifications[] = $this->_create_snapshot($to_view); } if ($request->data['store_statistics']) { $notifications[] = $this->_store_statistics($stats); } return $to_view + compact('notifications'); }
public function index($request) { if ($request->is('get')) { $normalize_path = function ($path) { return str_replace('\\', '/', realpath($path)); }; $test_directories = json_encode(array_map($normalize_path, \app\lib\Library::retrieve('test_directories'))); $suites = array(); $stats = array(); $store_statistics = \app\lib\Library::retrieve('store_statistics'); $create_snapshots = \app\lib\Library::retrieve('create_snapshots'); $sandbox_errors = \app\lib\Library::retrieve('sandbox_errors'); $xml_configuration_files = \app\lib\Library::retrieve('xml_configuration_files'); return compact('create_snapshots', 'sandbox_errors', 'stats', 'store_statistics', 'suites', 'test_directories', 'xml_configuration_files'); } $tests = explode('|', $request->data['test_files']); $vpu = new \app\lib\VPU(); if ($request->data['sandbox_errors']) { error_reporting(\app\lib\Library::retrieve('error_reporting')); set_error_handler(array($vpu, 'handle_errors')); } $xml_config = false; $notifications = array(); if ($xml_file_index = $request->data['xml_configuration_file']) { $files = \app\lib\Library::retrieve('xml_configuration_files'); $xml_config = $files[$xml_file_index - 1]; if (!$xml_config || !($xml_config = realpath($xml_config))) { $notifications[] = array('type' => 'failed', 'title' => 'No Valid XML Configuration File Found', 'message' => 'Please ensure that the ' . '<code>xml_configuration_file</code> in ' . '<code>app/config/bootstrap.php</code> exists and ' . 'has the proper permissions.'); } } $results = $xml_config ? $vpu->run_with_xml($xml_config) : $vpu->run_tests($tests); $results = $vpu->compile_suites($results, 'web'); if ($request->data['sandbox_errors']) { restore_error_handler(); } $suites = $results['suites']; $stats = $results['stats']; $errors = $vpu->get_errors(); $to_view = compact('suites', 'stats', 'errors'); if ($request->data['create_snapshots']) { $notifications[] = $this->_create_snapshot($to_view); } if ($request->data['store_statistics']) { $notifications[] = $this->_store_statistics($stats); } return $to_view + compact('notifications'); }