예제 #1
0
 protected function _before()
 {
     $this->id = '4804370';
     $this->url = "http://jp.finalfantasyxiv.com/lodestone/character/";
     $vendorDir = dirname(dirname(dirname(dirname(dirname(__FILE__)))));
     $this->mappingFilePath = $vendorDir . '/Lodestone/Mapping/Mock.json';
     $mapping = ["name" => ["selector" => "//*[@id='character']/div[1]/div/div/div/div/div/div/h2/a", "filter" => "filterXPath", "attr" => "", "subset" => "", "trim" => ""], "race" => ["selector" => "#character > div.base_footer > div > div > div:nth-child(2) > div.clearfix > div.chara_profile_left > div.chara_profile_box > div > section > div", "filter" => "filter", "attr" => "", "subset" => "", "trim" => ""], "mount" => ["selector" => '//*[@id="character"]/div[3]/div/div/div[5]/div[1]/div/div/div/a', "filter" => "filterXPath", "attr" => "title", "subset" => 1, "trim" => ""], "level" => ["selector" => '//*[@id="character"]/div[3]/div/div/div[2]/div[3]/div[1]/div[2]/div[1]/ul/li', "filter" => "filterXPath", "attr" => "", "subset" => 1, "trim" => ""], "text" => ["selector" => '//*[@id="character"]/div[3]/div/div/div[2]/div[1]/div/div/h3', "filter" => "filterXPath", "attr" => "", "trim" => ""]];
     //*[@id="character"]/div[3]/div/div/div[2]/div[1]/div/div/h3
     file_put_contents($this->mappingFilePath, JSON::stringify($mapping));
 }
예제 #2
0
 /**
  * Object Initialize.
  */
 public function init()
 {
     if ($data = Cache::get($this->_id, $this->_group)) {
         $mapping = $data;
     } else {
         $mappingJson = file_get_contents($this->_mappingFilePath);
         $mapping = JSON::parse($mappingJson);
         Cache::save($mapping, $this->_id, $this->_group);
     }
     $this->setMapping($mapping);
     return $this;
 }
예제 #3
0
 public function testJSON_JSONエンコード引数ありの場合_文字列が返る()
 {
     $json = JSON::stringify(["formatted JSON" => 1], 5);
     $this->assertEquals('{"formatted JSON":1}', $json);
 }