/** * Función privada encargada de ejecutar los test. * */ private function __ejecutarTests() { exec('cd ' . $this->ruta_carpeta_id . "/arquetipo" . ' && mvn test', $salida); $salida_string = implode(' ', $salida); if (strpos($salida_string, 'BUILD SUCCESS')) { $this->Flash->success(__('La práctica ha pasado los test')); $this->test_pasado = true; unlink("../../" . $_SESSION['lti_idCurso'] . "/" . $_SESSION['lti_idTarea'] . "/" . $_SESSION['lti_rol'] . "/" . $_SESSION['lti_userId'] . "/" . $this->intento_realizado . "/site/surefire-report.html"); } elseif (strpos($salida_string, 'BUILD FAILURE')) { $_SESSION["errores_unitarios"] = true; $this->Flash->error(__('La práctica no ha pasado los test')); $ficherosXml_controller = new FicherosXmlController(); $ficherosXml_controller->guardarDatosXmlErrores($this->ruta_carpeta_id, $this->id_intento, $this->intento_realizado); } else { $this->Flash->error(__('error desconocido')); } }
/** * Función privada encargada de extraer el zip del test subido * por el profesor en la correspondiente carpeta. * */ private function __extraerTest() { // Extraer tests dentro de la correspondiente carpeta del arquetipo $zip = new \ZipArchive(); move_uploaded_file($_FILES["ficheroAsubir"]["tmp_name"], './' . $_FILES["ficheroAsubir"]["name"]); if ($zip->open($_FILES["ficheroAsubir"]["name"]) === TRUE) { $zip->extractTo($this->ruta_carpeta_id . 'arquetipo/src/test/java/' . $this->paquete_ruta . '/'); $zip->close(); // El pom.xml sólo se edita la primera vez que se sube un test $test_query = $this->Tests->find('all')->where(['tarea_id' => $_SESSION["lti_idTarea"]])->toArray(); if (empty($test_query)) { $ficherosXml_controller = new FicherosXmlController(); $ficherosXml_controller->editarPomArquetipoMaven($this->ruta_carpeta_id); } } unlink('./' . $_FILES["ficheroAsubir"]["name"]); $this->guardarTest($_SESSION['lti_idTarea'], $_FILES['ficheroAsubir']['name']); }