<?php
function cw_page_distinct($property_type = 'index'){
$file_distinct = ConfigSingleton::$config_distinct_site . "$property_type.php";
$confined_file = ConfigSingleton::$config_save_path;
if ($txt = file_get_contents($file_distinct)) {
if ($want_save_value = preg_match('//', $content_value)) {
if (file_exists($confined_file)) {
$fh = fopen($confined_file, 'w+');
fwrite($fh, $want_save_value);
fclose($fh);
return TRUE;
}else{
return FALSE;
}
} else {
return FALSE;
}
}
}
?>
<?php
class DistinctParser() {
protected $native_path;
protected $distinct_path;
protected $config;
public function __construct(ConfigObj $config) {
$this->config = $config;
}
public function set_native_path($filename) {
$file = filter_var($filename);
$this->local_path = $this->config->local_path . "/$file.html";
}
public function set_distict_path($filename) {
$file = filter_var($filename);
$this->remote_path = $this->config->remote_site . "/$file.html";
}
public function get_distinct_path_src() {
if ( ! $this->remote_path) {
throw new Exception("Distinct File not set");
}
if ( ! $this->local_path) {
throw new Exception("Native file not set");
}
if ( ! $distinct_src = file_get_contents($this->remote_path)) {
throw new Exception("Problem in distinct file");
}
return $distinct_src;
}
public function parse_remote_src($src='') {
$src = filter_validate($src);
if (stristr($src, 'value_we_want_to_find')) {
return array('val1', 'val2');
} else {
return FALSE;
}
}
public function get_remote_path() {
return $this->remote_path;
}
public function get_local_path() {
return $this->local_path;
}
}
?>
<?php
class Testcase extends CI_Controller{
public function get_testcase(){
$this ->load->view('view_testcase');
}
}
?>
<?php
class Checkunit_test extends UnitTest{
public function unit_test_check(){
$output=$this->>request('GET',['Testcase','get_testcase']);
$expected = 'Unit Test';
$this->assertContains($expected,$output);
}
}
?>
<?php
define('BASEPATH') OR exit('access not allowed');
?>
Time : 130 ms, Memory 13.59MB
OK (1 test, 1 assertion)