Beispiel #1
0
 /**
  * @group long
  */
 public function testOpcGeneration()
 {
     $nss = array("http://schemas.openxmlformats.org/package/2006/metadata/core-properties" => "Iag/ECMA376/Package/Model/CoreProperties/", "http://purl.org/dc/elements/1.1/" => "Iag/ECMA376/Package/Model/CoreProperties/DcElements/", "http://purl.org/dc/terms/" => "Iag/ECMA376/Package/Model/CoreProperties/DcTerms/", "http://purl.org/dc/dcmitype/" => "Iag/ECMA376/Package/Model/CoreProperties/DcMiType/");
     $reader = new SchemaReader();
     $reader->addKnownSchemaLocation('http://dublincore.org/schemas/xmls/qdc/2003/04/02/dc.xsd', __DIR__ . '/opc/dc.xsd');
     $reader->addKnownSchemaLocation('http://dublincore.org/schemas/xmls/qdc/2003/04/02/dcterms.xsd', __DIR__ . '/opc/dcterms.xsd');
     $reader->addKnownSchemaLocation('http://dublincore.org/schemas/xmls/qdc/2003/04/02/dcterms.xsd', __DIR__ . '/opc/dcterms.xsd');
     $reader->addKnownSchemaLocation('http://dublincore.org/schemas/xmls/qdc/2003/04/02/dcmitype.xsd', __DIR__ . '/opc/dcmitype.xsd');
     $schema = $reader->readFile(__DIR__ . '/opc/opc-coreProperties.xsd');
     $generator = new Generator($nss);
     list($phpClasses, $yamlItems) = $generator->getData([$schema]);
     $this->assertEquals(count($phpClasses), count($yamlItems));
     $this->assertGreaterThan(0, count($phpClasses));
 }
 /**
  * @group slow
  * @dataProvider getTestFiles
  */
 public function testConversion($xml, $xsd, $class)
 {
     $serializer = self::$generator->buildSerializer(function (HandlerRegistryInterface $h) {
         $h->registerSubscribingHandler(new XmlSchemaDateHandler());
         $h->registerSubscribingHandler(new OTASchemaDateHandler());
         $h->registerSubscribingHandler(new BaseTypesHandler());
     });
     $original = $this->clearXML(file_get_contents($xml));
     $object = $serializer->deserialize($original, $class, 'xml');
     $new = $serializer->serialize($object, 'xml');
     $new = $this->clearXML($new);
     $differ = new \XMLDiff\Memory();
     $diff = $differ->diff($original, $new);
     $notEqual = strpos($diff, '<dm:copy count="1"/>') === false || strlen($diff) > 110;
     if (0 && $notEqual) {
         file_put_contents("a.xml", $original);
         file_put_contents("b.xml", $new);
         file_put_contents("c.xml", $diff);
         exit;
     }
     $this->assertFalse($notEqual);
 }