示例#1
0
 public function testJsonEncodeDecode()
 {
     $data = array('one' => 1, 'two' => 'two');
     $jsonData = '{"one":1,"two":"two"}';
     $this->assertEquals($jsonData, $this->_helper->jsonEncode($data));
     $this->assertEquals($data, $this->_helper->jsonDecode($jsonData));
 }
示例#2
0
文件: Data.php 项目: nemphys/magento2
 /**
  * Get next bunch of validated rows.
  *
  * @return array|null
  */
 public function getNextBunch()
 {
     if (null === $this->_iterator) {
         $this->_iterator = $this->getIterator();
         $this->_iterator->rewind();
     }
     if ($this->_iterator->valid()) {
         $dataRow = $this->_iterator->current();
         $dataRow = $this->_jsonHelper->jsonDecode($dataRow[0]);
         $this->_iterator->next();
     } else {
         $this->_iterator = null;
         $dataRow = null;
     }
     return $dataRow;
 }
示例#3
0
 /**
  * @param array $source
  * @param array $result
  * @param bool $isXml
  *
  * @dataProvider getLayoutUpdateActionDataProvider
  */
 public function testGetLayoutUpdateAction(array $source, array $result, $isXml = false)
 {
     $this->getRequest()->setPost($source);
     $this->dispatch('backend/admin/system_design_editor/getLayoutUpdate');
     $response = $this->_dataHelper->jsonDecode($this->getResponse()->getBody());
     // convert to XML string to the same format as in $result
     if ($isXml) {
         foreach ($response as $code => $data) {
             foreach ($data as $key => $value) {
                 $xml = new Varien_Simplexml_Element($value);
                 $response[$code][$key] = $xml->asNiceXml();
             }
         }
     }
     $this->assertEquals($result, $response);
 }
示例#4
0
 /**
  * Retrieve aliases to classes map if exit
  *
  * @return array
  */
 protected function _getAliasesMap()
 {
     if (is_null($this->_aliasesMap)) {
         $this->_aliasesMap = array();
         $map = $this->_loadMap($this->_pathToMapFile);
         if (!empty($map)) {
             $this->_aliasesMap = $this->_coreHelper->jsonDecode($map);
         }
     }
     return $this->_aliasesMap;
 }