コード例 #1
0
 public function testEncode()
 {
     $iniString = file_get_contents(dirname(__FILE__) . '/ini/output.ini');
     $input = $this->getData();
     $ini = Encode::toIni($input);
     $this->assertEquals($iniString, $ini->load());
 }
コード例 #2
0
 /**
  * @expectedException InvalidArgumentException
  */
 public function testCallbackEvent()
 {
     $input = $this->generageArray();
     $json = Encode::toJsonp('foo|bar', $input)->on(\Serializers\Events::JSONP_VALID_CALLBACK, function ($callback) {
         return false;
     });
     $json->load(true);
 }
コード例 #3
0
 public function testSerialize()
 {
     $input = $this->generageArray();
     $json = Encode::toJson($input)->on(\Serializers\Events::JSON_SERIALIZE, function ($input) {
         $input['a'] = 'foo';
         $input['g'] = 'bar';
         return $input;
     });
     json_decode($json->load());
     $this->assertEquals(json_last_error(), JSON_ERROR_NONE);
 }
コード例 #4
0
ファイル: Yaml.php プロジェクト: realshadow/serializers
 /**
  * Transform to INI
  *
  * @return \Serializers\Encoders\Ini
  *
  * @since 1.0
  */
 public function toIni()
 {
     $ini = Encode::toIni($this->toArray());
     return $ini;
 }
コード例 #5
0
ファイル: Ini.php プロジェクト: realshadow/serializers
 /**
  * Transform to YAML
  *
  * @param array $config - additional configuration
  *
  * @return \Serializers\Encoders\Yaml
  *
  * @since 1.0
  */
 public function toYaml(array $config = array())
 {
     $yaml = Encode::toYaml($this->toArray(), $config);
     return $yaml;
 }
コード例 #6
0
ファイル: Jsonp.php プロジェクト: realshadow/serializers
 /**
  * Parse to JSON and return instance of JSON Encoder
  *
  * @param array $config - configuration
  *
  * @return \Serializers\Encoders\Json
  *
  * @since 1.0
  */
 public function toJSON(array $config = array())
 {
     $json = Encode::toJson($this->data, $config);
     return $json;
 }
コード例 #7
0
 /**
  * Tests bad element name, e.g numeric indexes in array
  *
  * @expectedException RuntimeException
  */
 public function testEncodeBadInput()
 {
     $input = array_values($this->generageArray());
     $xml = Encode::toXml('root', $input);
     $xml->load();
 }