/** * 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 testAutoFillSummary() { // Some cheating $_SERVER["SERVER_NAME"] = '127.0.0.1'; // Login as root $model = new LoginForm('RegularLogin'); $model->username = "******"; $model->password = "******"; $this->assertTrue($model->login()); // Create new bug $bug = new Bug(); $bug->crashreports = '3'; $bug->autoFillSummary(); $bug->assigned_to = 2; $bug->status = Bug::STATUS_NEW; $bug->priority = Bug::PRIORITY_MEDIUM; $bug->reproducability = Bug::REPRO_ALWAYS; // Apply changes $opened = $bug->open(); // Should succeed $this->assertTrue($opened); // Create new bug $bug = new Bug(); $bug->crashgroups = '3'; $bug->autoFillSummary(); $bug->assigned_to = 2; $bug->status = Bug::STATUS_NEW; $bug->priority = Bug::PRIORITY_MEDIUM; $bug->reproducability = Bug::REPRO_ALWAYS; // Apply changes $opened = $bug->open(); // Should succeed $this->assertTrue($opened); }