Skip to content

Commit

Permalink
add minimal test case for goetas-webservices#168
Browse files Browse the repository at this point in the history
  • Loading branch information
BigBadBassMan committed Jan 6, 2025
1 parent 67c49df commit 577c2a8
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/Issues/I168/I168Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace GoetasWebservices\Xsd\XsdToPhp\Tests\Issues\I168;

use GoetasWebservices\XML\XSDReader\SchemaReader;
use GoetasWebservices\Xsd\XsdToPhp\Naming\ShortNamingStrategy;
use GoetasWebservices\Xsd\XsdToPhp\Php\PhpConverter;
use PHPUnit\Framework\TestCase;

class I168Test extends TestCase
{
public function testChoice()
{
$reader = new SchemaReader();
$schema = $reader->readFile(__DIR__ . '/data.xsd');

$phpConv = new PhpConverter(new ShortNamingStrategy());
$phpConv->addNamespace('http://www.example.com/', 'Epa');

$items = $phpConv->convert([$schema]);

$this->assertTrue($items['Epa\ComplexType']->getProperty('key')->getNullable());
$this->assertTrue($items['Epa\ComplexType']->getProperty('stream')->getNullable());
$this->assertTrue($items['Epa\ComplexType']->getProperty('packet')->getNullable());
}
}
14 changes: 14 additions & 0 deletions tests/Issues/I168/data.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/" elementFormDefault="qualified">
<xs:complexType name="ComplexType">
<xs:choice>
<xs:sequence>
<xs:element name="key" type="xs:string"/>
<xs:element name="stream" type="xs:string" minOccurs="0" nillable="true"/>
</xs:sequence>
<xs:sequence>
<xs:element name="packet" type="xs:string" maxOccurs="unbounded"/>
</xs:sequence>
</xs:choice>
</xs:complexType>
</xs:schema>

0 comments on commit 577c2a8

Please sign in to comment.