/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { // Check that user is authorized to create new bugs $this->checkAuthorization(null); // Create new model $model = new Bug(); if (isset($_GET['crashgroup'])) { // The bug is being created for a particular crash group. $model->crashgroups = $_GET['crashgroup']; // Automatically fill the summary and description fields $model->autoFillSummary(); } if (isset($_GET['crashreport'])) { // The bug is being created for a particular crash report. $model->crashreports = $_GET['crashreport']; // Automatically fill the summary and description fields $model->autoFillSummary(); } // Fill model fields if (isset($_POST['Bug'])) { $model->attributes = $_POST['Bug']; if ($model->open()) { $this->redirect(array('view', 'id' => $model->id)); } } // Render view $this->render('create', array('model' => $model)); }
public function testDelete() { // Create new bug $bug = new Bug(); $bug->summary = "Bug on Crash Report #3"; $bug->description = "Some description"; $bug->assigned_to = 1; $bug->status = Bug::STATUS_ACCEPTED; $bug->priority = Bug::PRIORITY_HIGH; $bug->reproducability = Bug::REPRO_NOT_TRIED; $bug->crashreports = "3"; // Login as root $model = new LoginForm('RegularLogin'); $model->username = "******"; $model->password = "******"; $this->assertTrue($model->login()); // Apply changes $opened = $bug->open(); // Should succeed $this->assertTrue($opened); // Find the bug $bug = Bug::model()->findByAttributes(array('summary' => 'Bug on Crash Report #3')); $this->assertTrue($bug != null); // Delete the bug $this->assertTrue($bug->delete()); }