|
@@ -35,12 +35,11 @@ class areaTest extends PHPUnit_Framework_TestCase
|
|
|
$area = new area\upgrade();
|
|
|
$area->country();
|
|
|
}
|
|
|
+
|
|
|
public function testExport()
|
|
|
{
|
|
|
$area = new area\area_check();
|
|
|
$result = $area->export();
|
|
|
- //$data = json_encode($result,JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
|
|
|
-
|
|
|
wcache('area_2.0', array('data' => serialize($result)), 'mb_area');
|
|
|
}
|
|
|
public function testUpdate()
|
|
@@ -55,6 +54,43 @@ class areaTest extends PHPUnit_Framework_TestCase
|
|
|
$result_name = $validator->from_name('上海','上海市','松江区');
|
|
|
}
|
|
|
|
|
|
+ public function testNosub()
|
|
|
+ {
|
|
|
+ $validator = new area\area_validator('area');
|
|
|
+ $cities = $validator->nosub_city();
|
|
|
+
|
|
|
+ $output = [];
|
|
|
+ $input = [];
|
|
|
+ foreach ($cities as $city)
|
|
|
+ {
|
|
|
+ $area_id = $city['area_id'];
|
|
|
+ $items = $validator->city($city['area_id']);
|
|
|
+ $prov = $items['province'];
|
|
|
+ $input[$area_id] = ['其它区'];
|
|
|
+ $str_out = "area_id={$area_id} prov_name = {$prov['area_name']} , city_name ={$city['area_name']}";
|
|
|
+ $output[] = $str_out;
|
|
|
+ }
|
|
|
+
|
|
|
+ $in_json = json_encode($input,JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
|
|
+ $out_json = json_encode($output,JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function testAddCountry()
|
|
|
+ {
|
|
|
+ $path = BASE_DATA_PATH . '/area/input';
|
|
|
+ $content = file_get_contents($path);
|
|
|
+ $items = json_decode($content);
|
|
|
+
|
|
|
+ $mod_area = Model('area');
|
|
|
+ foreach ($items as $parent_id => $names)
|
|
|
+ {
|
|
|
+ foreach ($names as $name) {
|
|
|
+ $ret = $mod_area->insert(array('area_name' => $name,'area_deep' => 3,'area_parent_id' => $parent_id));
|
|
|
+ Log::record("insert aread_id = {$ret},area_name={$name}");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public function testFixAreadid()
|
|
|
{
|
|
|
area_helper::fix_areaid();
|