Skip to content

Commit

Permalink
fixed xsd test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
goetas committed Sep 16, 2016
1 parent 43dfa1b commit 02dcd7f
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 47 deletions.
2 changes: 1 addition & 1 deletion src/Php/PathGenerator/Psr4PathGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function getPath(ClassGenerator $php)
}
}

throw new PathGeneratorException("Can't find a defined location where save '$php' object");
throw new PathGeneratorException("Can't find a defined location where save '{$php->getNamespaceName()}\\{$php->getName()}' object");
}
}

7 changes: 5 additions & 2 deletions tests/AbstractGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
use GoetasWebservices\Xsd\XsdToPhp\AbstractConverter;
use GoetasWebservices\Xsd\XsdToPhp\Jms\PathGenerator\Psr4PathGenerator as JmsPsr4PathGenerator;
use GoetasWebservices\Xsd\XsdToPhp\Naming\ShortNamingStrategy;
use GoetasWebservices\Xsd\XsdToPhp\Php\ClassGenerator;
use GoetasWebservices\Xsd\XsdToPhp\Php\PathGenerator\Psr4PathGenerator as PhpPsr4PathGenerator;
use GoetasWebservices\Xsd\XsdToPhp\Writer\JMSWriter;
use GoetasWebservices\Xsd\XsdToPhp\Writer\PHPClassWriter;
use GoetasWebservices\Xsd\XsdToPhp\Writer\PHPWriter;
use JMS\Serializer\Handler\HandlerRegistryInterface;

Expand Down Expand Up @@ -128,7 +130,8 @@ protected function writePHP(array $items)

$pathGenerator = new PhpPsr4PathGenerator($paths);

$writer = new PHPWriter($pathGenerator);
$classWriter = new PHPClassWriter($pathGenerator);
$writer = new PHPWriter($classWriter, new ClassGenerator());
$writer->write($items);
}

Expand All @@ -147,4 +150,4 @@ protected function writeJMS(array $items)
$writer = new JMSWriter($pathGenerator);
$writer->write($items);
}
}
}
5 changes: 2 additions & 3 deletions tests/PHP/AnyTypePHPConversionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ protected function getPhpClasses($xml, array $types = array())

$classes = array();
foreach ($items as $k => $item) {
$codegen = new \Zend\Code\Generator\ClassGenerator();
if ($generator->generate($codegen, $item)) {
if ($codegen = $generator->generate($item)) {
$classes[$k] = $codegen;
}
}
Expand Down Expand Up @@ -146,4 +145,4 @@ public function testSimpleAnyTypeYaml()
)
), $single);
}
}
}
5 changes: 2 additions & 3 deletions tests/PHP/PHPConversionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ protected function getClasses($xml)

$classes = array();
foreach ($items as $k => $item) {
$codegen = new \Zend\Code\Generator\ClassGenerator();
if ($generator->generate($codegen, $item)) {
if ($codegen = $generator->generate($item)) {
$classes[$k] = $codegen;
}
}
Expand Down Expand Up @@ -245,4 +244,4 @@ public function testSimpleMulteplicity()
$this->assertTrue($single->hasMethod('getId'));
$this->assertTrue($single->hasMethod('setId'));
}
}
}
18 changes: 1 addition & 17 deletions tests/PathGenerator/JMSPathGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,4 @@ public function testWriter()

$this->assertEquals($path, $this->tmpdir . "/Bar.yml");
}

public function testNonExistingDir()
{
$this->setExpectedException('GoetasWebservices\Xsd\XsdToPhp\PathGenerator\PathGeneratorException');
new Psr4PathGenerator(array(
'myns\\' => "aaaa"
));
}

public function testInvalidNs()
{
$this->setExpectedException('GoetasWebservices\Xsd\XsdToPhp\PathGenerator\PathGeneratorException');
new Psr4PathGenerator(array(
'myns' => "aaaa"
));
}
}
}
29 changes: 8 additions & 21 deletions tests/PathGenerator/PHPPathGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use GoetasWebservices\Xsd\XsdToPhp\Php\PathGenerator\Psr4PathGenerator;
use GoetasWebservices\Xsd\XsdToPhp\Php\Structure\PHPClass;
use Zend\Code\Generator\ClassGenerator;

class PHPPathGeneratorTest extends \PHPUnit_Framework_TestCase
{
Expand All @@ -28,7 +29,8 @@ public function testNoNs()
$generator = new Psr4PathGenerator(array(
'myns\\' => $this->tmpdir
));
$generator->getPath(new PHPClass('Bar', 'myns2'));
$class = new ClassGenerator('Bar', 'myns2');
$generator->getPath($class);
}

public function testWriterLong()
Expand All @@ -37,7 +39,8 @@ public function testWriterLong()
'myns\\' => $this->tmpdir
));

$path = $generator->getPath(new PHPClass('Bar', 'myns\foo'));
$class = new ClassGenerator('Bar', 'myns\foo');
$path = $generator->getPath($class);

$this->assertEquals($path, $this->tmpdir . "/foo/Bar.php");
}
Expand All @@ -47,25 +50,9 @@ public function testWriter()
$generator = new Psr4PathGenerator(array(
'myns\\' => $this->tmpdir
));

$path = $generator->getPath(new PHPClass('Bar', 'myns'));
$class = new ClassGenerator('Bar', 'myns');
$path = $generator->getPath($class);

$this->assertEquals($path, $this->tmpdir . "/Bar.php");
}

public function testNonExistingDir()
{
$this->setExpectedException('GoetasWebservices\Xsd\XsdToPhp\PathGenerator\PathGeneratorException');
new Psr4PathGenerator(array(
'myns\\' => "aaaa"
));
}

public function testInvalidNs()
{
$this->setExpectedException('GoetasWebservices\Xsd\XsdToPhp\PathGenerator\PathGeneratorException');
new Psr4PathGenerator(array(
'myns' => "aaaa"
));
}
}
}

0 comments on commit 02dcd7f

Please sign in to comment.