Example #1
0
 function test()
 {
     $this->load->library('unit_test');
     //$test = 1 + 1;
     //$expected_result = 2;
     //$test_name = 'Adds one plus one';
     //$this->unit->run($test, $expected_result, $test_name);
     $this->load->helper('kals');
     $this->unit->run(get_referer_url(), 'http://localhost/CodeIgniter_1.7.2/unit_test', '取得參考的網址!' . get_referer_url());
     $this->unit->run(parse_host(get_referer_url()), $this->host, '取得參考的HOST!' . parse_host());
     $this->unit->run(parse_uri('http://localhost/CodeIgniter_1.7.2/index.php/ut_misc/ut_kals_helper/test'), '/CodeIgniter_1.7.2/index.php/ut_misc/ut_kals_helper/test', '取得參考的URI!' . parse_uri());
     $this->unit->run(url_is_link('http://images.plurk.com/1422855_79bdc93f1317c2a7b8c9f0c5d51586c9.jpg'), TRUE, '確認是否是連結');
     $this->unit->run(url_is_image('http://images.plurk.com/1422855_79bdc93f1317c2a7b8c9f0c5d51586c9.jpg'), TRUE, '確認是否是圖片');
     $this->unit->run(url_is_link('http://www.plurk.com/p/5u89gi#response-1629050986'), TRUE, '確認是否是連結');
     $this->unit->run(url_is_image('http://www.plurk.com/p/5u89gi#response-1629050986'), FALSE, '確認是否是圖片');
     $this->unit->run(parse_email_name('*****@*****.**'), 'puddingchen.35', '取出email的名字');
     $this->unit->run(retrieve_title('http://www.plurk.com/p/5uuz7o#response-1632175301'), 'JS布丁 正在 [CODING D2] http://www.youtube.com/watch?v=c8I_WPonFHE  進度:2/182 - #5uuz7o', '取得網頁的title');
     $data = array('title' => get_class($this), 'unit' => $this->unit);
     $this->load->view('misc/unit_test', $data);
 }
Example #2
0
 /**
  * @param String|Webpage|int $webpage_id
  * @return Webpage 
  */
 public function filter_webpage_object($webpage)
 {
     if (is_object($webpage)) {
         return $webpage;
     }
     if (is_string($webpage) && url_is_link($webpage, FALSE)) {
         // Pulipuli Chen 2013117
         // 加入網址過濾
         $url = url_strip_index($webpage);
         $webpage = $this->create(array('url' => $url));
         return $webpage;
     } else {
         return new Webpage($webpage);
     }
 }