1--TEST-- 2SolrUtils::digestJsonResponse() - Digest JSON Response 3--FILE-- 4<?php 5$responseString = ' 6{ 7 "responseHeader":{ 8 "status":0, 9 "QTime":1, 10 "params":{ 11 "indent":"on", 12 "wt":"json", 13 "q":"lucene", 14 "version":"2.2"}}, 15 "response":{"numFound":1,"start":0,"docs":[ 16 { 17 "id":"SOLR1000", 18 "name":"Solr, the Enterprise Search Server", 19 "manu":"Apache Software Foundation", 20 "cat":["software", 21 "search"], 22 "features":["Advanced Full-Text Search Capabilities using Lucene", 23 "Optimized for High Volume Web Traffic", 24 "Standards Based Open Interfaces - XML and HTTP", 25 "Comprehensive HTML Administration Interfaces", 26 "Scalability - Efficient Replication to other Solr Search Servers", 27 "Flexible and Adaptable with XML configuration and Schema", 28 "Good unicode support: hello (hello with an accent over the e)"], 29 "price":0.0, 30 "price_c":"0,USD", 31 "popularity":10, 32 "inStock":true, 33 "incubationdate_dt":"2006-01-17T00:00:00Z", 34 "_version_":1460602453694087168}] 35 }}'; 36if (!json_decode($responseString)) { 37 echo "PHP JSON DECODE failed with: ". json_last_error_msg().PHP_EOL; 38} 39$response = SolrUtils::digestJsonResponse($responseString); 40var_dump($response instanceof SolrObject); 41var_dump($response); 42var_dump($response->response->docs[0]->_version_ == 1460602453694087168); 43?> 44--EXPECTF-- 45bool(true) 46object(SolrObject)#%d (2) { 47 ["responseHeader"]=> 48 object(SolrObject)#4 (3) { 49 ["status"]=> 50 int(0) 51 ["QTime"]=> 52 int(1) 53 ["params"]=> 54 object(SolrObject)#5 (4) { 55 ["indent"]=> 56 string(2) "on" 57 ["wt"]=> 58 string(4) "json" 59 ["q"]=> 60 string(6) "lucene" 61 ["version"]=> 62 string(3) "2.2" 63 } 64 } 65 ["response"]=> 66 object(SolrObject)#%d (3) { 67 ["numFound"]=> 68 int(1) 69 ["start"]=> 70 int(0) 71 ["docs"]=> 72 array(1) { 73 [0]=> 74 object(SolrObject)#%d (11) { 75 ["id"]=> 76 string(8) "SOLR1000" 77 ["name"]=> 78 string(34) "Solr, the Enterprise Search Server" 79 ["manu"]=> 80 string(26) "Apache Software Foundation" 81 ["cat"]=> 82 array(2) { 83 [0]=> 84 string(8) "software" 85 [1]=> 86 string(6) "search" 87 } 88 ["features"]=> 89 array(7) { 90 [0]=> 91 string(51) "Advanced Full-Text Search Capabilities using Lucene" 92 [1]=> 93 string(37) "Optimized for High Volume Web Traffic" 94 [2]=> 95 string(46) "Standards Based Open Interfaces - XML and HTTP" 96 [3]=> 97 string(44) "Comprehensive HTML Administration Interfaces" 98 [4]=> 99 string(64) "Scalability - Efficient Replication to other Solr Search Servers" 100 [5]=> 101 string(56) "Flexible and Adaptable with XML configuration and Schema" 102 [6]=> 103 string(61) "Good unicode support: hello (hello with an accent over the e)" 104 } 105 ["price"]=> 106 float(0) 107 ["price_c"]=> 108 string(5) "0,USD" 109 ["popularity"]=> 110 int(10) 111 ["inStock"]=> 112 bool(true) 113 ["incubationdate_dt"]=> 114 string(20) "2006-01-17T00:00:00Z" 115 ["_version_"]=> 116 %s 117 } 118 } 119 } 120} 121bool(true)