feature: Beispiele des Parsers erstellen
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use TorstenHettstedt\SaxXmlExample\TutorsReader;
|
||||
use TorstenHettstedt\XmlReader\Sax\XmlSaxParser;
|
||||
|
||||
require_once '../vendor/autoload.php';
|
||||
|
||||
const SHOULD_TEXT = <<<TXT
|
||||
|
||||
course Name - Android
|
||||
Country - India
|
||||
Email - contact@tutorialspoint.com
|
||||
Phone - 123456789
|
||||
|
||||
course Name - Java
|
||||
Country - India
|
||||
Email - contact@tutorialspoint.com
|
||||
Phone - 123456789
|
||||
|
||||
course Name - HTML
|
||||
Country - India
|
||||
Email - contact@tutorialspoint.com
|
||||
Phone - 123456789
|
||||
|
||||
TXT;
|
||||
|
||||
|
||||
foreach (glob('../xml/*.xml') as $file_path) {
|
||||
$tutors = new TutorsReader();
|
||||
$parser = new XmlSaxParser($tutors);
|
||||
$parser->parseFile($file_path);
|
||||
unset($parser);
|
||||
printf(PHP_EOL . '## %s', $file_path);
|
||||
echo $tutors->printTutors();
|
||||
assert($tutors->printTutors() === SHOULD_TEXT);
|
||||
}
|
||||
Reference in New Issue
Block a user