Пример #1
0
 /**
  * Gestion des modèles
  */
 public function actionAdmin()
 {
     $session = $this->setAdminGridViewSessionVariables('BadUrlLog');
     $model = new BadUrlLog('search');
     $model->unsetAttributes();
     // clear any default values
     $model->attributes = $session->get('admin_current_filter');
     $pager = new CPagination();
     $pager->pageSize = Yii::app()->getModule('admin')->adminPageSize;
     if ($page = $session->get('admin_current_page')) {
         $pager->currentPage = $page - 1;
     }
     $this->render('admin', array('pager' => $pager, 'model' => $model));
 }
Пример #2
0
 /**
  * @test
  */
 public function search()
 {
     // recherche par event_date
     $model = new BadUrlLog('search');
     $model->unsetAttributes();
     $model->event_date = "2014";
     $data = $model->search()->data;
     $this->assertEquals(2, count($data));
     $model->unsetAttributes();
     $model->event_date = "2019";
     $data = $model->search()->data;
     $this->assertEquals(0, count($data));
     // recherche par cookie_data
     $model->unsetAttributes();
     $model->cookie_data = 'cookie_da';
     $data = $model->search()->data;
     $this->assertEquals(1, count($data));
     // recherche par server_data
     $model->unsetAttributes();
     $model->server_data = 'server_da';
     $data = $model->search()->data;
     $this->assertEquals(1, count($data));
     // recherche par remote_addr
     $model->unsetAttributes();
     $model->remote_addr = "127.0.0";
     $data = $model->search()->data;
     $this->assertEquals(1, count($data));
     // recherche par remote_port
     $model->unsetAttributes();
     $model->remote_port = '80';
     $data = $model->search()->data;
     $this->assertEquals(1, count($data));
     // recherche par request_method
     $model->unsetAttributes();
     $model->request_method = 'GET';
     $data = $model->search()->data;
     $this->assertEquals(1, count($data));
     $model->unsetAttributes();
     $model->request_method = 'GE';
     // doit être complet
     $data = $model->search()->data;
     $this->assertEquals(0, count($data));
     // recherche par request_uri
     $model->unsetAttributes();
     $model->request_uri = 'site';
     $data = $model->search()->data;
     $this->assertEquals(1, count($data));
     // recherche par query_string
     $model->unsetAttributes();
     $model->query_string = '';
     // devrait trouver celui qui a une chaine vide et celui qui est NULL
     $data = $model->search()->data;
     $this->assertEquals(2, count($data));
 }