function actionUnitTest($id, $raw = 0) { $test = UnitTest::model()->findByPk($id); if ($test == null) { throw new CHttpException(404, 'Test not found'); } $this->render_code('unit_test', $raw, false, array('test' => $test)); }
function actionUnitMethod($method) { $meth = Method::model()->findByPk($method); if ($meth == null) { throw new CHttpException(404, 'Method not found :-('); } $t = UnitTest::model()->findByAttributes(array('id_method' => $method)); if ($t != null) { $this->redirect(array('view', 'id' => $t->id_test)); } else { $model = new Test(); $special = new UnitTest(); $special->id_method = $id_method; // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Test'])) { $model->attributes = $_POST['Test']; $special->id_test = 0; if ($model->save()) { $special->id_test = $model->id_test; $special->save(false); $this->redirect(array('view', 'id' => $model->id_test)); } } $this->render('create', array('model' => $model, 'special' => $special)); } }
<?php $tests = UnitTest::model()->findAll(); foreach ($tests as $t) { echo strtolower($t->public_id()) . ".cpp"; }
<?php function test_row(UnitTest $test, $indentation, TableCreator $table_creator) { return $table_creator->row(array($table_creator->child_indentation($indentation), $test->public_id(), $test->test->description, $test->method->name . "()", 'success')); } $toplevel = UnitTest::model()->findAll(); $table = $table_creator->begin_table("|r l|p{6cm}|l|l|") . $table_creator->heading_row(array("Test di unità" => 2, "Descrizione", "Metodo", "Stato")); foreach ($toplevel as $test) { $table .= test_row($test, 0, $table_creator); } $table .= $table_creator->caption("Tabella test unità / metodi") . $table_creator->end_table(); if ($table_creator->id() != 'html' && !$raw) { echo CodeGen::generic_render_code($table, 'latex', true); } else { echo $table; }