Example #1
0
 function index()
 {
     //        $url = 'http://www.lib.nccu.edu.tw/?m=1109&sn=54&id=92&mm=1101';
     //        $host = 'http://www.lib.nccu.edu.tw/';
     //        $title = '政治大學圖書館網站';
     $url = 'http://pulipuli.blogspot.com/2010/07/2010711.html';
     $host = 'http://pulipuli.blogspot.com/';
     $title = '布丁布丁吃?';
     //以下才是正是的測試開始
     create_context(TRUE);
     $this->load->library('kals_resource/Domain');
     $domain2 = new Domain();
     $domain2->set_field('url', $url);
     $domain2->update();
     $this->unit->run($domain2->get_field("url"), $host, '以new建立domain2,測試get_field("url")');
     $domain = $this->domain->create($url);
     $domain_id = $domain->get_id();
     $this->unit->run($domain_id, 'is_int', '用ctreate()來建立Domain,看看是否有id');
     $test_domain = $this->domain->create($url);
     $test_domain_id = $test_domain->get_id();
     //echo $test_domain_id;
     $this->unit->run($test_domain->get_field("url"), $host, '測試get_host');
     $this->unit->run($domain_id != NULL, TRUE, '測試test_domain是不是真的find到domain');
     $this->unit->run($domain_id, $test_domain_id, '測試test_domain是不是真的find到domain');
     $this->unit->run($test_domain->get_id(), $domain_id, '用ctreate()以同樣的url來建立Domain,看看是否有id');
     $this->unit->run($test_domain->get_field('title'), $title, '再建立時,是否就能找到title?');
     $id = $test_domain->get_id();
     $test_domain = new Domain($id);
     $this->unit->run($test_domain->get_id() != NULL, TRUE, '測試用id來find Domain');
     $this->unit->run($test_domain->get_field('url'), $host, '測試用id來find Domain 測試get_host');
     $this->unit->run($test_domain->get_field('title'), $title, '測試title');
     $domains = $this->domain->find_all();
     $this->unit->run(count($domains) > 0, TRUE, '測試find_all是否有找到東西');
     $domains = $this->domain->find_all(array('domain_id' => $id));
     $this->unit->run(count($domains), 1, '測試find_all加上條件,是否能找到測試時建立的domain');
     $this->unit->run($domains[0]->get_id(), $id, '測試find_all中能不能get_id()');
     $this->unit->run($domains[0]->get_host(), $host, '測試find_all中能不能get_host()');
     $test_domain->delete();
     $this->unit->run($test_domain->get_id(), NULL, '測試刪除之後,Domain ID還在不在這件事情');
     $domain_deleted = $this->domain->find($url);
     $this->unit->run($domain_deleted, NULL, '測試刪除之後,Domain還能不能找到這件事情');
     //context_complete();
     //context_abort();
     unit_test_report($this);
     //destory_context();
 }
Example #2
0
 public function actionEdit()
 {
     $msgDomain = "";
     $rsInfo = "";
     $request = Yii::app()->getRequest();
     $id = trim($request->getParam("id"));
     if (!empty($_POST)) {
         $name = trim($request->getPost("name"));
         $admin = trim($request->getPost("admin"));
         $username = trim($request->getPost("username"));
         $password = trim($request->getPost("password"));
         $provider = trim($request->getPost("provider"));
         $status = trim($request->getPost("status"));
         if ($name == "") {
             $msgDomain = "域名名称选项不能留空";
         } else {
             if (strlen($name) > 64) {
                 $msgDomain = "输入不能大于64个字符";
             }
         }
         if ($msgDomain == "") {
             $domain = array('name' => $name, 'admin' => $admin, 'username' => $username, 'password' => $password, 'provider' => $provider, 'status' => $status);
             try {
                 $res = new Domain();
                 $res->_pk = $id;
                 $res->_attributes = $domain;
                 $res->setIsNewRecord(false);
                 $res->update();
                 $this->redirect(array('list'));
             } catch (CDbException $e) {
                 throw CDbException($e);
             }
         }
     }
     try {
         $Rs = new Domain();
         $rsInfo = $Rs->findByPk($id);
     } catch (CDbException $e) {
         throw CDbException($e);
     }
     $this->render('edit', array('r' => Yii::app()->request->baseUrl . '/', 'rsInfo' => $rsInfo, 'msgDomain' => $msgDomain));
 }
Example #3
0
function doEdit()
{
    if (isset($_POST['submit'])) {
        $domain_id = $_POST['domain_id'];
        $domainname = $_POST['domainname'];
        $description = $_POST['description'];
        $sector = $_POST['psector'];
        $domain = new Domain();
        $domain->domain_id = $domain_id;
        $domain->domain_name = $domainname;
        $domain->description = $description;
        $domain->sector_id = $sector;
    }
    if ($domain_id == "") {
        message('Domain ID is required!', "error");
        redirect('index.php?view=edit&id=' . $domain_id);
    } elseif ($domainname == "") {
        message('Domain Name is required!', "error");
        redirect('index.php?view=edit&id=' . $domain_id);
    } elseif ($description == "") {
        message('Description is required!', "error");
        redirect('index.php?view=edit&id=' . $domain_id);
    } elseif ($sector == "") {
        message('Sector is required!', "error");
        redirect('index.php?view=edit&id=' . $domain_id);
    } else {
        $domain->update($_GET['id']);
        message('Domain infomation updated successfully!', "info");
        redirect('index.php');
    }
}