File: 202.solrdocument_new_serialize.phpt

package info (click to toggle)
php-solr 2.6.0%2B2.4.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 4,956 kB
  • sloc: ansic: 40,168; xml: 2,223; php: 1,987; pascal: 8; makefile: 3
file content (49 lines) | stat: -rw-r--r-- 1,048 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
--TEST--
SolrDocument - new serialize api
--SKIPIF--
<?php if (PHP_VERSION_ID < 80100) die("skip PHP 8.1+ only"); ?>
--FILE--
<?php

$old = 'C:12:"SolrDocument":172:{<?xml version="1.0" encoding="UTF-8"?>
<solr_document>
  <fields>
    <field name="id">
      <field_value>parent_2</field_value>
    </field>
  </fields>
</solr_document>
}';
$new = 'O:12:"SolrDocument":1:{s:3:"xml";s:172:"<?xml version="1.0" encoding="UTF-8"?>
<solr_document>
  <fields>
    <field name="id">
      <field_value>parent_2</field_value>
    </field>
  </fields>
</solr_document>
";}';

/** @var SolrDocument $docOld */
$docOld = unserialize($old);
/** @var SolrDocument $docNew */
$docNew = unserialize($new);
var_dump(
	json_encode($docOld->toArray()) === json_encode($docNew->toArray())
);
var_dump($docNew->__serialize());
?>
--EXPECT--
bool(true)
array(1) {
  ["xml"]=>
  string(172) "<?xml version="1.0" encoding="UTF-8"?>
<solr_document>
  <fields>
    <field name="id">
      <field_value>parent_2</field_value>
    </field>
  </fields>
</solr_document>
"
}