public function testMissingClass()
 {
     $expectedItems = array('Epa\\Schema\\AdditionalIdentifier', 'Epa\\Schema\\AdditionalIdentifierType', 'Epa\\Schema\\AdditionalIdentifierTypes', 'Epa\\Schema\\AdditionalIdentifiers');
     $expectedItems = array_combine($expectedItems, $expectedItems);
     $reader = new SchemaReader();
     $schema = $reader->readFile(__DIR__ . '/data.xsd');
     $yamlConv = new YamlConverter(new ShortNamingStrategy());
     $yamlConv->addNamespace('', 'Epa\\Schema');
     $yamlItems = $yamlConv->convert([$schema]);
     $this->assertCount(count($expectedItems), $yamlItems);
     $this->assertEmpty(array_diff_key($expectedItems, $yamlItems));
     $phpConv = new PhpConverter(new ShortNamingStrategy());
     $phpConv->addNamespace('', 'Epa\\Schema');
     $phpClasses = $phpConv->convert([$schema]);
     $this->assertCount(count($expectedItems), $phpClasses);
     $this->assertEmpty(array_diff_key($expectedItems, $phpClasses));
     $yamlClass = $yamlItems['Epa\\Schema\\AdditionalIdentifier']['Epa\\Schema\\AdditionalIdentifier'];
     $yamlProperty = $yamlClass['properties']['additionalIdentifierType'];
     /** @var PHPClass $phpClass */
     $phpClass = $phpClasses['Epa\\Schema\\AdditionalIdentifier'];
     /** @var PHPProperty $phpProperty */
     $phpProperty = $phpClass->getProperty('additionalIdentifierType');
     /** @var PHPClass $phpType */
     $phpType = $phpProperty->getType();
     $this->assertSame($yamlProperty['type'], $phpType->getFullName());
 }
 /**
  *
  * @param mixed $xml
  * @return \Zend\Code\Generator\ClassGenerator[]
  */
 protected function getPhpClasses($xml, array $types = array())
 {
     $creator = new PhpConverter(new ShortNamingStrategy());
     $creator->addNamespace('', 'Example');
     foreach ($types as $typeData) {
         list($ns, $name, $type) = $typeData;
         $creator->addAliasMapType($ns, $name, $type);
     }
     $generator = new ClassGenerator();
     $reader = new SchemaReader();
     if (!is_array($xml)) {
         $xml = ['schema.xsd' => $xml];
     }
     $schemas = [];
     foreach ($xml as $name => $str) {
         $schemas[] = $reader->readString($str, $name);
     }
     $items = $creator->convert($schemas);
     $classes = array();
     foreach ($items as $k => $item) {
         if ($codegen = $generator->generate($item)) {
             $classes[$k] = $codegen;
         }
     }
     return $classes;
 }
 public function testNaming()
 {
     $reader = new SchemaReader();
     $schema = $reader->readFile(__DIR__ . '/data.xsd');
     $phpConv = new PhpConverter(new ShortNamingStrategy());
     $phpConv->addNamespace('http://www.example.com/', 'Epa');
     $phpClasses = $phpConv->convert([$schema]);
     $this->assertEquals('convertToReseller', $phpClasses['Epa\\Two']->getProperty('convertToReseller')->getType()->getArg()->getName());
 }
 public function testNaming()
 {
     $reader = new SchemaReader();
     $schema = $reader->readFile(__DIR__ . '/data.xsd');
     $phpConv = new PhpConverter(new ShortNamingStrategy());
     $phpConv->addNamespace('http://www.example.com/', 'Epa');
     $phpClasses = $phpConv->convert([$schema]);
     $this->assertArrayHasKey('Epa\\ABType', $phpClasses);
     $class = $phpClasses['Epa\\ABType'];
     $this->assertArrayHasKey('cDe', $class->getProperties());
     $this->assertArrayHasKey('fGh', $class->getProperties());
 }
 public function testMissingClass()
 {
     $expectedItems = array('Epa\\Job', 'Epa\\Item', 'Epa\\Item\\PriceAType');
     $reader = new SchemaReader();
     $schema = $reader->readFile(__DIR__ . '/data.xsd');
     $yamlConv = new YamlConverter(new ShortNamingStrategy());
     $yamlConv->addNamespace('http://www.trogon.si/Schemas/2010/JobXML/2.0', 'Epa');
     $yamlItems = $yamlConv->convert([$schema]);
     $yamlItems = array_keys($yamlItems);
     $this->assertEmpty(array_diff($expectedItems, $yamlItems));
     $phpConv = new PhpConverter(new ShortNamingStrategy());
     $phpConv->addNamespace('http://www.trogon.si/Schemas/2010/JobXML/2.0', 'Epa');
     $phpClasses = $phpConv->convert([$schema]);
     $phpClasses = array_keys($phpClasses);
     $this->assertEmpty(array_diff_key($expectedItems, $phpClasses));
 }
 /**
  *
  * @param mixed $xml
  * @return \Zend\Code\Generator\ClassGenerator[]
  */
 protected function getClasses($xml)
 {
     $phpcreator = new PhpConverter(new ShortNamingStrategy());
     $phpcreator->addNamespace('http://www.example.com', 'Example');
     $generator = new ClassGenerator();
     $reader = new SchemaReader();
     if (!is_array($xml)) {
         $xml = ['schema.xsd' => $xml];
     }
     $schemas = [];
     foreach ($xml as $name => $str) {
         $schemas[] = $reader->readString($str, $name);
     }
     $items = $phpcreator->convert($schemas);
     $classes = array();
     foreach ($items as $k => $item) {
         if ($codegen = $generator->generate($item)) {
             $classes[$k] = $codegen;
         }
     }
     return $classes;
 }
 protected function getClasses($xml)
 {
     $schema = $this->reader->readString($xml);
     return $this->converter->convert(array($schema));
 }