/** * 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; }
/** * @test */ public function search() { // recherche par mail_date $model = new MailsLog('search'); $model->unsetAttributes(); $model->mail_date = "2014"; $data = $model->search()->data; $this->assertEquals(2, count($data)); $model->unsetAttributes(); $model->mail_date = "2019"; $data = $model->search()->data; $this->assertEquals(0, count($data)); // recherche par from $model->unsetAttributes(); $model->from = 'from'; $data = $model->search()->data; $this->assertEquals(1, count($data)); // recherche par to $model->unsetAttributes(); $model->to = 'to'; $data = $model->search()->data; $this->assertEquals(1, count($data)); // recherche par contenu HTML $model->unsetAttributes(); $model->body = "texte"; $data = $model->search()->data; $this->assertEquals(2, count($data)); // recherche par type $model->unsetAttributes(); $model->type = 'CourrierTest'; $data = $model->search()->data; $this->assertEquals(2, count($data)); }