コード例 #1
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return MailsLog the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = MailsLog::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
コード例 #2
0
ファイル: MailsLogTest.php プロジェクト: ChristopheBrun/hLib
 /**
  * @test
  */
 public function create()
 {
     $this->assertInstanceOf('MailsLog', MailsLog::model());
     $model = new MailsLog();
     $model->attributes = array('from' => '*****@*****.**', 'to' => '*****@*****.**', 'body' => '<div>texte du mail</div>', 'type' => 'CourrierTest');
     $this->assertFalse($model->save());
     $model = new MailsLog();
     $model->attributes = array('mail_date' => "2014/08/01 12:00:00", 'to' => '*****@*****.**', 'body' => '<div>texte du mail</div>', 'type' => 'CourrierTest');
     $this->assertFalse($model->save());
     $model = new MailsLog();
     $model->attributes = array('mail_date' => "2014/08/01 12:00:00", 'from' => '*****@*****.**', 'body' => '<div>texte du mail</div>', 'type' => 'CourrierTest');
     $this->assertFalse($model->save());
     $model = new MailsLog();
     $model->attributes = array('mail_date' => "2014/08/01 12:00:00", 'from' => '*****@*****.**', 'to' => '*****@*****.**', 'type' => 'CourrierTest');
     $this->assertFalse($model->save());
     $model = new MailsLog();
     $model->attributes = array('mail_date' => "2014/08/01 12:00:00", 'from' => '*****@*****.**', 'to' => '*****@*****.**', 'body' => '<div>texte du mail</div>');
     $this->assertFalse($model->save());
     $model = new MailsLog();
     $model->attributes = array('mail_date' => "2014/08/01 12:00:00", 'from' => '*****@*****.**', 'to' => '*****@*****.**', 'body' => '<div>texte du mail</div>', 'type' => 'CourrierTest');
     $this->assertTrue($model->save());
 }