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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
--TEST--
Reader_Partial 001 - Read and skip elements based on their ID
--FILE--
<?php
namespace phpdotnet\phd;
require_once __DIR__ . "/../setup.php";
$xml = <<<XML
<?xml version="1.0" encoding="utf-8"?>
<section>
<emptyNode xml:id="renderThis1"></emptyNode>
<nonEmptyNode xml:id="renderThis2">
<title>Title here</title>
<content>Some content with <node xml:id="skipThis1">nodes</node></content>
</nonEmptyNode>
<anotherNonEmptyNode>
<content></content>
<content xml:id="renderThis3">
Some more content <node xml:id="skipThis2">but this is not read</node>
</content>
<content></content>
<content xml:id="renderThis4">
Some more content <node>and this is read</node>
</content>
</anotherNonEmptyNode>
</section>
XML;
try {
$reader = new Reader_Partial($outputHandler, []);
} catch (\Exception $e) {
var_dump($e->getMessage());
}
$renderIds = [
"renderThis1" => 1,
"renderThis2" => 1,
"renderThis3" => 1,
"renderThis4" => 1
];
$skipIds = [
"skipThis1" => 1,
"skipThis2" => 1
];
$parentIds = [];
$reader = new Reader_Partial($outputHandler, $renderIds, $skipIds, $parentIds);
$reader->XML($xml);
while ($reader->read()) {
}
?>
--EXPECTF--
string(26) "Didn't get any IDs to seek"
%s[%d:%d:%d - Partial Reading ]%s Starting renderThis1...
%s[%d:%d:%d - Partial Reading ]%s renderThis1 done
%s[%d:%d:%d - Partial Reading ]%s Starting renderThis2...
%s[%d:%d:%d - Partial Reading ]%s Skipping skipThis1...
%s[%d:%d:%d - Partial Reading ]%s skipThis1 done
%s[%d:%d:%d - Partial Reading ]%s renderThis2 done
%s[%d:%d:%d - Partial Reading ]%s Starting renderThis3...
%s[%d:%d:%d - Partial Reading ]%s Skipping skipThis2...
%s[%d:%d:%d - Partial Reading ]%s skipThis2 done
%s[%d:%d:%d - Partial Reading ]%s renderThis3 done
%s[%d:%d:%d - Partial Reading ]%s Starting renderThis4...
%s[%d:%d:%d - Partial Reading ]%s renderThis4 done
|