From 93a78d40bd543db00470bb7e5ecb895dac800717 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 9 Feb 2022 15:54:22 +0100 Subject: [PATCH] :arrow_up: update dependencies --- .travis.yml | 2 ++ composer.json | 20 +++++++++---------- src/AbstractConverter.php | 5 +++++ src/Jms/YamlConverter.php | 12 ++++++----- src/Naming/AbstractNamingStrategy.php | 10 +++++++--- src/Naming/LongNamingStrategy.php | 1 - src/Naming/NoConflictLongNamingStrategy.php | 1 - src/Naming/ShortNamingStrategy.php | 1 - src/Php/ClassGenerator.php | 17 ++++++++++------ tests/Converter/AbstractXsdConverterTest.php | 14 +++++++------ tests/Converter/JMS/Xsd2JmsBase.php | 5 +++-- tests/Converter/PHP/Xsd2PhpBase.php | 5 +++-- .../Converter/Validator/Xsd2ValidatorTest.php | 5 +++-- tests/Issues/I111/I111Test.php | 3 ++- tests/Issues/I138/I138Test.php | 4 ++-- tests/Issues/I22/I22Test.php | 3 ++- tests/Issues/I26/I26Test.php | 3 ++- tests/Issues/I40/I40Test.php | 10 ++++++---- tests/Issues/I43/I43Test.php | 3 ++- tests/Issues/I57/I57Test.php | 3 ++- tests/Issues/I63/I63Test.php | 3 ++- tests/Issues/I84/I84Test.php | 3 ++- .../OTA/OTASerializationTest.php | 14 ++++++++----- tests/PHP/AnyTypePHPConversionTest.php | 3 ++- tests/PHP/PHPConversionTest.php | 3 ++- tests/PathGenerator/JMSPathGeneratorTest.php | 7 ++++--- tests/PathGenerator/PHPPathGeneratorTest.php | 7 ++++--- tests/Validator/ValidatorTest.php | 5 +++-- tests/VeryShortNamingStrategy.php | 8 +++++--- 29 files changed, 110 insertions(+), 70 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9af61554..a6ae6d28 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,8 @@ php: - 7.2 - 7.3 - 7.4 + - 8.0 + - 8.1 matrix: include: diff --git a/composer.json b/composer.json index 0617f77e..bf530df8 100644 --- a/composer.json +++ b/composer.json @@ -18,22 +18,22 @@ ], "license": "MIT", "require": { - "php": ">=7.1", - "symfony/console": "^2.7|^3.0|^4.0|^5.0", - "symfony/dependency-injection": "^2.2|^3.0|^4.0|^5.0", - "symfony/yaml": "^2.2|^3.0|^4.0|^5.0", - "symfony/config": "^2.2|^3.0|^4.0|^5.0", + "php": ">=7.2", + "symfony/console": "^2.7|^3.0|^4.0|^5.0|^6.0", + "symfony/dependency-injection": "^2.2|^3.0|^4.0|^5.0|^6.0", + "symfony/yaml": "^2.2|^3.0|^4.0|^5.0|^6.0", + "symfony/config": "^2.2|^3.0|^4.0|^5.0|^6.0", "goetas-webservices/xsd-reader": "^0.3.7", - "doctrine/inflector": "^1.0", - "laminas/laminas-code": "^3.3.2", - + "doctrine/inflector": "^2.0", + "laminas/laminas-code": "^3.3.2|^4.0", "psr/log": "^1.0" }, "require-dev": { - "phpunit/phpunit": "^5.0", + "phpunit/phpunit": "^6.0|^7.0|^8.0|^9.0", "jms/serializer": "^1.9|^2.0|^3.0", "goetas-webservices/xsd2php-runtime": "^0.2.13@dev", - "symfony/validator": "^2.3.24|^3.0|^4.0" + "symfony/validator": "^2.3.24|^3.0|^4.0|^5.0|^6.0", + "dms/phpunit-arraysubset-asserts": "^0.3.1" }, "autoload": { "psr-4": { diff --git a/src/AbstractConverter.php b/src/AbstractConverter.php index af3e9c79..92318ee8 100644 --- a/src/AbstractConverter.php +++ b/src/AbstractConverter.php @@ -51,6 +51,11 @@ public function addAliasMapType($ns, $name, $type) }); } + public function getTypeAliases(): array + { + return $this->typeAliases; + } + public function getTypeAlias($type, Schema $schemapos = null) { $schema = $schemapos ?: $type->getSchema(); diff --git a/src/Jms/YamlConverter.php b/src/Jms/YamlConverter.php index 9a3ed80f..d38ff16c 100644 --- a/src/Jms/YamlConverter.php +++ b/src/Jms/YamlConverter.php @@ -2,7 +2,7 @@ namespace GoetasWebservices\Xsd\XsdToPhp\Jms; -use Doctrine\Common\Inflector\Inflector; +use Doctrine\Inflector\InflectorFactory; use Exception; use GoetasWebservices\XML\XSDReader\Schema\Attribute\AttributeContainer; use GoetasWebservices\XML\XSDReader\Schema\Attribute\AttributeItem; @@ -379,8 +379,9 @@ protected function &visitAttribute(&$class, Schema $schema, AttributeItem $attri $property['access_type'] = 'public_method'; $property['serialized_name'] = $attribute->getName(); - $property['accessor']['getter'] = 'get' . Inflector::classify($this->getNamingStrategy()->getPropertyName($attribute)); - $property['accessor']['setter'] = 'set' . Inflector::classify($this->getNamingStrategy()->getPropertyName($attribute)); + $inflector = InflectorFactory::create()->build(); + $property['accessor']['getter'] = 'get' . $inflector->classify($this->getNamingStrategy()->getPropertyName($attribute)); + $property['accessor']['setter'] = 'set' . $inflector->classify($this->getNamingStrategy()->getPropertyName($attribute)); $property['xml_attribute'] = true; @@ -496,8 +497,9 @@ protected function &visitElement(&$class, Schema $schema, ElementItem $element, $property['xml_element']['namespace'] = $elementNamespace; } - $property['accessor']['getter'] = 'get' . Inflector::classify($this->getNamingStrategy()->getPropertyName($element)); - $property['accessor']['setter'] = 'set' . Inflector::classify($this->getNamingStrategy()->getPropertyName($element)); + $inflector = InflectorFactory::create()->build(); + $property['accessor']['getter'] = 'get' . $inflector->classify($this->getNamingStrategy()->getPropertyName($element)); + $property['accessor']['setter'] = 'set' . $inflector->classify($this->getNamingStrategy()->getPropertyName($element)); $t = $element->getType(); if ($arrayize) { diff --git a/src/Naming/AbstractNamingStrategy.php b/src/Naming/AbstractNamingStrategy.php index 5c9bbc18..ff3f3350 100644 --- a/src/Naming/AbstractNamingStrategy.php +++ b/src/Naming/AbstractNamingStrategy.php @@ -2,7 +2,7 @@ namespace GoetasWebservices\Xsd\XsdToPhp\Naming; -use Doctrine\Common\Inflector\Inflector; +use Doctrine\Inflector\InflectorFactory; use GoetasWebservices\XML\XSDReader\Schema\Item; use GoetasWebservices\XML\XSDReader\Schema\Type\Type; @@ -99,11 +99,15 @@ public function getItemName(Item $item) public function getPropertyName($item) { - return Inflector::camelize(str_replace('.', ' ', $item->getName())); + $inflector = InflectorFactory::create()->build(); + + return $inflector->camelize(str_replace('.', ' ', $item->getName())); } protected function classify($name) { - return Inflector::classify(str_replace('.', ' ', $name)); + $inflector = InflectorFactory::create()->build(); + + return $inflector->classify(str_replace('.', ' ', $name)); } } diff --git a/src/Naming/LongNamingStrategy.php b/src/Naming/LongNamingStrategy.php index 022eedd7..1d74206e 100644 --- a/src/Naming/LongNamingStrategy.php +++ b/src/Naming/LongNamingStrategy.php @@ -2,7 +2,6 @@ namespace GoetasWebservices\Xsd\XsdToPhp\Naming; -use Doctrine\Common\Inflector\Inflector; use GoetasWebservices\XML\XSDReader\Schema\Item; use GoetasWebservices\XML\XSDReader\Schema\Type\Type; diff --git a/src/Naming/NoConflictLongNamingStrategy.php b/src/Naming/NoConflictLongNamingStrategy.php index 080528d9..e11135a6 100644 --- a/src/Naming/NoConflictLongNamingStrategy.php +++ b/src/Naming/NoConflictLongNamingStrategy.php @@ -2,7 +2,6 @@ namespace GoetasWebservices\Xsd\XsdToPhp\Naming; -use Doctrine\Common\Inflector\Inflector; use GoetasWebservices\XML\XSDReader\Schema\Item; use GoetasWebservices\XML\XSDReader\Schema\Type\Type; diff --git a/src/Naming/ShortNamingStrategy.php b/src/Naming/ShortNamingStrategy.php index a5ca1c2e..29eacf8c 100644 --- a/src/Naming/ShortNamingStrategy.php +++ b/src/Naming/ShortNamingStrategy.php @@ -2,7 +2,6 @@ namespace GoetasWebservices\Xsd\XsdToPhp\Naming; -use Doctrine\Common\Inflector\Inflector; use GoetasWebservices\XML\XSDReader\Schema\Item; use GoetasWebservices\XML\XSDReader\Schema\Type\Type; diff --git a/src/Php/ClassGenerator.php b/src/Php/ClassGenerator.php index ce35c266..bf06da58 100644 --- a/src/Php/ClassGenerator.php +++ b/src/Php/ClassGenerator.php @@ -2,7 +2,7 @@ namespace GoetasWebservices\Xsd\XsdToPhp\Php; -use Doctrine\Common\Inflector\Inflector; +use Doctrine\Inflector\InflectorFactory; use GoetasWebservices\Xsd\XsdToPhp\Php\Structure\PHPClass; use GoetasWebservices\Xsd\XsdToPhp\Php\Structure\PHPClassOf; use GoetasWebservices\Xsd\XsdToPhp\Php\Structure\PHPProperty; @@ -125,7 +125,8 @@ private function handleSetter(Generator\ClassGenerator $generator, PHPProperty $ $type = $prop->getType(); - $method = new MethodGenerator('set' . Inflector::classify($prop->getName())); + $inflector = InflectorFactory::create()->build(); + $method = new MethodGenerator('set' . $inflector->classify($prop->getName())); $parameter = new ParameterGenerator($prop->getName()); @@ -171,6 +172,8 @@ private function handleSetter(Generator\ClassGenerator $generator, PHPProperty $ private function handleGetter(Generator\ClassGenerator $generator, PHPProperty $prop, PHPClass $class) { + $inflector = InflectorFactory::create()->build(); + if ($prop->getType() instanceof PHPClassOf) { $docblock = new DocBlockGenerator(); $docblock->setWordWrap(false); @@ -186,7 +189,8 @@ private function handleGetter(Generator\ClassGenerator $generator, PHPProperty $ $paramIndex = new ParameterGenerator('index'); - $method = new MethodGenerator('isset' . Inflector::classify($prop->getName()), [$paramIndex]); + + $method = new MethodGenerator('isset' . $inflector->classify($prop->getName()), [$paramIndex]); $method->setDocBlock($docblock); $method->setBody('return isset($this->' . $prop->getName() . '[$index]);'); $generator->addMethodFromGenerator($method); @@ -204,7 +208,7 @@ private function handleGetter(Generator\ClassGenerator $generator, PHPProperty $ $docblock->setTag(new ReturnTag('void')); - $method = new MethodGenerator('unset' . Inflector::classify($prop->getName()), [$paramIndex]); + $method = new MethodGenerator('unset' . $inflector->classify($prop->getName()), [$paramIndex]); $method->setDocBlock($docblock); $method->setBody('unset($this->' . $prop->getName() . '[$index]);'); $generator->addMethodFromGenerator($method); @@ -242,7 +246,7 @@ private function handleGetter(Generator\ClassGenerator $generator, PHPProperty $ $docblock->setTag($tag); - $method = new MethodGenerator('get' . Inflector::classify($prop->getName())); + $method = new MethodGenerator('get' . $inflector->classify($prop->getName())); $method->setDocBlock($docblock); $method->setBody('return $this->' . $prop->getName() . ';'); @@ -269,7 +273,8 @@ private function handleAdder(Generator\ClassGenerator $generator, PHPProperty $p $patramTag = new ParamTag($propName, $type->getArg()->getType()->getPhpType()); $docblock->setTag($patramTag); - $method = new MethodGenerator('addTo' . Inflector::classify($prop->getName())); + $inflector = InflectorFactory::create()->build(); + $method = new MethodGenerator('addTo' . $inflector->classify($prop->getName())); $parameter = new ParameterGenerator($propName); $tt = $type->getArg()->getType(); diff --git a/tests/Converter/AbstractXsdConverterTest.php b/tests/Converter/AbstractXsdConverterTest.php index 181a559f..e66a73cd 100644 --- a/tests/Converter/AbstractXsdConverterTest.php +++ b/tests/Converter/AbstractXsdConverterTest.php @@ -2,18 +2,20 @@ namespace GoetasWebservices\Xsd\XsdToPhp\Tests\Converter; +use GoetasWebservices\Xsd\XsdToPhp\AbstractConverter; use GoetasWebservices\Xsd\XsdToPhp\Naming\ShortNamingStrategy; +use PHPUnit\Framework\TestCase; -class AbstractXsdConverterTest extends \PHPUnit_Framework_TestCase +class AbstractXsdConverterTest extends TestCase { /** * @var AbstractConverter */ protected $converter; - public function setUp() + public function setUp(): void { - $this->converter = $this->getMockForAbstractClass('GoetasWebservices\Xsd\XsdToPhp\AbstractConverter', [new ShortNamingStrategy()]); + $this->converter = $this->getMockForAbstractClass(AbstractConverter::class, [new ShortNamingStrategy()]); } public function testAliases() @@ -22,7 +24,7 @@ public function testAliases() }; $this->converter->addAliasMap('http://www.example.com', 'myType', $f); - $handlers = \PHPUnit_Framework_Assert::readAttribute($this->converter, 'typeAliases'); + $handlers = $this->converter->getTypeAliases(); $this->assertArrayHasKey('http://www.example.com', $handlers); $this->assertArrayHasKey('myType', $exmpleHandlers = $handlers['http://www.example.com']); @@ -31,7 +33,7 @@ public function testAliases() public function testDefaultAliases() { - $handlers = \PHPUnit_Framework_Assert::readAttribute($this->converter, 'typeAliases'); + $handlers = $this->converter->getTypeAliases(); $this->assertArrayHasKey('http://www.w3.org/2001/XMLSchema', $handlers); $defaultHandlers = $handlers['http://www.w3.org/2001/XMLSchema']; @@ -45,7 +47,7 @@ public function testNamespaces() { $this->converter->addNamespace('http://www.example.com', 'some\php\ns'); - $namespaces = \PHPUnit_Framework_Assert::readAttribute($this->converter, 'namespaces'); + $namespaces = $this->converter->getNameSpaces(); $this->assertArrayHasKey('http://www.example.com', $namespaces); $this->assertEquals('some\php\ns', $namespaces['http://www.example.com']); diff --git a/tests/Converter/JMS/Xsd2JmsBase.php b/tests/Converter/JMS/Xsd2JmsBase.php index 17f74a42..6d6c7d22 100644 --- a/tests/Converter/JMS/Xsd2JmsBase.php +++ b/tests/Converter/JMS/Xsd2JmsBase.php @@ -5,8 +5,9 @@ use GoetasWebservices\XML\XSDReader\SchemaReader; use GoetasWebservices\Xsd\XsdToPhp\Jms\YamlConverter; use GoetasWebservices\Xsd\XsdToPhp\Naming\ShortNamingStrategy; +use PHPUnit\Framework\TestCase; -abstract class Xsd2JmsBase extends \PHPUnit_Framework_TestCase +abstract class Xsd2JmsBase extends TestCase { /** * @var YamlConverter @@ -18,7 +19,7 @@ abstract class Xsd2JmsBase extends \PHPUnit_Framework_TestCase */ protected $reader; - public function setUp() + public function setUp(): void { $this->converter = new YamlConverter(new ShortNamingStrategy()); $this->converter->addNamespace('http://www.example.com', 'Example'); diff --git a/tests/Converter/PHP/Xsd2PhpBase.php b/tests/Converter/PHP/Xsd2PhpBase.php index 6fc83740..63150e49 100644 --- a/tests/Converter/PHP/Xsd2PhpBase.php +++ b/tests/Converter/PHP/Xsd2PhpBase.php @@ -5,8 +5,9 @@ use GoetasWebservices\XML\XSDReader\SchemaReader; use GoetasWebservices\Xsd\XsdToPhp\Naming\ShortNamingStrategy; use GoetasWebservices\Xsd\XsdToPhp\Php\PhpConverter; +use PHPUnit\Framework\TestCase; -abstract class Xsd2PhpBase extends \PHPUnit_Framework_TestCase +abstract class Xsd2PhpBase extends TestCase { /** * @var PhpConverter @@ -18,7 +19,7 @@ abstract class Xsd2PhpBase extends \PHPUnit_Framework_TestCase */ protected $reader; - public function setUp() + public function setUp(): void { $this->converter = new PhpConverter(new ShortNamingStrategy()); $this->converter->addNamespace('http://www.example.com', 'Example'); diff --git a/tests/Converter/Validator/Xsd2ValidatorTest.php b/tests/Converter/Validator/Xsd2ValidatorTest.php index 34a4bcb4..f6e6805f 100644 --- a/tests/Converter/Validator/Xsd2ValidatorTest.php +++ b/tests/Converter/Validator/Xsd2ValidatorTest.php @@ -5,8 +5,9 @@ use GoetasWebservices\XML\XSDReader\SchemaReader; use GoetasWebservices\Xsd\XsdToPhp\Jms\YamlValidatorConverter; use GoetasWebservices\Xsd\XsdToPhp\Naming\ShortNamingStrategy; +use PHPUnit\Framework\TestCase; -class Xsd2ValidatorTest extends \PHPUnit_Framework_TestCase +class Xsd2ValidatorTest extends TestCase { /** * @var YamlValidatorConverter @@ -21,7 +22,7 @@ class Xsd2ValidatorTest extends \PHPUnit_Framework_TestCase /** * Set up converter and reader properties. */ - public function setUp() + public function setUp(): void { $this->converter = new YamlValidatorConverter(new ShortNamingStrategy()); $this->converter->addNamespace('http://www.example.com', 'Example'); diff --git a/tests/Issues/I111/I111Test.php b/tests/Issues/I111/I111Test.php index 636d308b..359c8eb6 100644 --- a/tests/Issues/I111/I111Test.php +++ b/tests/Issues/I111/I111Test.php @@ -5,8 +5,9 @@ use GoetasWebservices\XML\XSDReader\SchemaReader; use GoetasWebservices\Xsd\XsdToPhp\Jms\YamlConverter; use GoetasWebservices\Xsd\XsdToPhp\Naming\ShortNamingStrategy; +use PHPUnit\Framework\TestCase; -class I111Test extends \PHPUnit_Framework_TestCase +class I111Test extends TestCase { public function testNamespace() { diff --git a/tests/Issues/I138/I138Test.php b/tests/Issues/I138/I138Test.php index 4a563441..5ac8e147 100644 --- a/tests/Issues/I138/I138Test.php +++ b/tests/Issues/I138/I138Test.php @@ -4,10 +4,10 @@ use GoetasWebservices\Xsd\XsdToPhp\Naming\ShortNamingStrategy; use GoetasWebservices\Xsd\XsdToPhp\Php\PhpConverter; use GoetasWebservices\XML\XSDReader\SchemaReader; +use PHPUnit\Framework\TestCase; -class I138Test extends \PHPUnit_Framework_TestCase +class I138Test extends TestCase { - public function testChioce() { $reader = new SchemaReader(); diff --git a/tests/Issues/I22/I22Test.php b/tests/Issues/I22/I22Test.php index b2062db7..561a3d11 100644 --- a/tests/Issues/I22/I22Test.php +++ b/tests/Issues/I22/I22Test.php @@ -5,8 +5,9 @@ use GoetasWebservices\XML\XSDReader\SchemaReader; use GoetasWebservices\Xsd\XsdToPhp\Jms\YamlConverter; use GoetasWebservices\Xsd\XsdToPhp\Naming\ShortNamingStrategy; +use PHPUnit\Framework\TestCase; -class I22Test extends \PHPUnit_Framework_TestCase +class I22Test extends TestCase { public function testNamespace() { diff --git a/tests/Issues/I26/I26Test.php b/tests/Issues/I26/I26Test.php index c3da18a0..896b8d97 100644 --- a/tests/Issues/I26/I26Test.php +++ b/tests/Issues/I26/I26Test.php @@ -5,8 +5,9 @@ use GoetasWebservices\XML\XSDReader\SchemaReader; use GoetasWebservices\Xsd\XsdToPhp\Jms\YamlConverter; use GoetasWebservices\Xsd\XsdToPhp\Naming\ShortNamingStrategy; +use PHPUnit\Framework\TestCase; -class I26Test extends \PHPUnit_Framework_TestCase +class I26Test extends TestCase { public function testSkipWhenEmptyOnOptionalAndRequiredLists() { diff --git a/tests/Issues/I40/I40Test.php b/tests/Issues/I40/I40Test.php index c8de5c8f..879f22e0 100644 --- a/tests/Issues/I40/I40Test.php +++ b/tests/Issues/I40/I40Test.php @@ -2,12 +2,14 @@ namespace GoetasWebservices\Xsd\XsdToPhp\Tests\Issues\I40; +use DMS\PHPUnitExtensions\ArraySubset\Assert; use GoetasWebservices\XML\XSDReader\SchemaReader; use GoetasWebservices\Xsd\XsdToPhp\Jms\YamlConverter; use GoetasWebservices\Xsd\XsdToPhp\Naming\ShortNamingStrategy; use GoetasWebservices\Xsd\XsdToPhp\Php\PhpConverter; +use PHPUnit\Framework\TestCase; -class I40Test extends \PHPUnit_Framework_TestCase +class I40Test extends TestCase { public function testMissingClass() { @@ -122,7 +124,7 @@ public function testMissingClass() $this->assertCount(count($yamlItems), $phpClasses); ksort($yamlItems); ksort($phpClasses); - $this->assertArraySubset(array_keys($yamlItems), array_keys($phpClasses)); + Assert::assertArraySubset(array_keys($yamlItems), array_keys($phpClasses)); } @@ -317,7 +319,7 @@ public function testDetectSimpleParentsWithAttributesZ(string $f, string $t, arr $this->assertCount(count($yamlItems), $phpClasses); ksort($yamlItems); ksort($phpClasses); - $this->assertArraySubset(array_keys($yamlItems), array_keys($phpClasses)); + Assert::assertArraySubset(array_keys($yamlItems), array_keys($phpClasses)); } public function testDetectSimpleParentsWithAttributesInTheMiddle() @@ -406,6 +408,6 @@ public function testDetectSimpleParentsWithAttributesInTheMiddle() ksort($phpClasses); $this->assertCount(count($yamlItems), $phpClasses); - $this->assertArraySubset(array_keys($yamlItems), array_keys($phpClasses)); + Assert::assertArraySubset(array_keys($yamlItems), array_keys($phpClasses)); } } diff --git a/tests/Issues/I43/I43Test.php b/tests/Issues/I43/I43Test.php index 2591efee..115f29b5 100644 --- a/tests/Issues/I43/I43Test.php +++ b/tests/Issues/I43/I43Test.php @@ -4,8 +4,9 @@ use GoetasWebservices\XML\XSDReader\SchemaReader; use GoetasWebservices\Xsd\XsdToPhp\Tests\Generator; +use PHPUnit\Framework\TestCase; -class I43Test extends \PHPUnit_Framework_TestCase +class I43Test extends TestCase { /** * @group long diff --git a/tests/Issues/I57/I57Test.php b/tests/Issues/I57/I57Test.php index 35d05c4f..b49eb2bc 100644 --- a/tests/Issues/I57/I57Test.php +++ b/tests/Issues/I57/I57Test.php @@ -6,8 +6,9 @@ use GoetasWebservices\Xsd\XsdToPhp\Jms\YamlConverter; use GoetasWebservices\Xsd\XsdToPhp\Naming\ShortNamingStrategy; use GoetasWebservices\Xsd\XsdToPhp\Php\PhpConverter; +use PHPUnit\Framework\TestCase; -class I57Test extends \PHPUnit_Framework_TestCase +class I57Test extends TestCase { public function testMissingClass() { diff --git a/tests/Issues/I63/I63Test.php b/tests/Issues/I63/I63Test.php index 9c48838e..c505ddb7 100644 --- a/tests/Issues/I63/I63Test.php +++ b/tests/Issues/I63/I63Test.php @@ -5,8 +5,9 @@ use GoetasWebservices\XML\XSDReader\SchemaReader; use GoetasWebservices\Xsd\XsdToPhp\Naming\ShortNamingStrategy; use GoetasWebservices\Xsd\XsdToPhp\Php\PhpConverter; +use PHPUnit\Framework\TestCase; -class I63Test extends \PHPUnit_Framework_TestCase +class I63Test extends TestCase { public function testNaming() { diff --git a/tests/Issues/I84/I84Test.php b/tests/Issues/I84/I84Test.php index bb7841a1..80ea9a29 100644 --- a/tests/Issues/I84/I84Test.php +++ b/tests/Issues/I84/I84Test.php @@ -5,8 +5,9 @@ use GoetasWebservices\XML\XSDReader\SchemaReader; use GoetasWebservices\Xsd\XsdToPhp\Naming\ShortNamingStrategy; use GoetasWebservices\Xsd\XsdToPhp\Php\PhpConverter; +use PHPUnit\Framework\TestCase; -class I84Test extends \PHPUnit_Framework_TestCase +class I84Test extends TestCase { public function testNaming() { diff --git a/tests/JmsSerializer/OTA/OTASerializationTest.php b/tests/JmsSerializer/OTA/OTASerializationTest.php index fbd816d7..311ec057 100644 --- a/tests/JmsSerializer/OTA/OTASerializationTest.php +++ b/tests/JmsSerializer/OTA/OTASerializationTest.php @@ -2,16 +2,17 @@ namespace GoetasWebservices\Xsd\XsdToPhp\Tests\JmsSerializer\OTA; -use Doctrine\Common\Inflector\Inflector; +use Doctrine\Inflector\InflectorFactory; use GoetasWebservices\XML\XSDReader\SchemaReader; use GoetasWebservices\Xsd\XsdToPhp\Tests\Generator; use GoetasWebservices\Xsd\XsdToPhpRuntime\Jms\Handler\BaseTypesHandler; use GoetasWebservices\Xsd\XsdToPhpRuntime\Jms\Handler\XmlSchemaDateHandler; use JMS\Serializer\Handler\HandlerRegistryInterface; use PackageVersions\Versions; +use PHPUnit\Framework\TestCase; use Symfony\Component\Validator\Validator\ValidatorInterface; -class OTASerializationTest extends \PHPUnit_Framework_TestCase +class OTASerializationTest extends TestCase { /** * @var Generator @@ -26,7 +27,7 @@ class OTASerializationTest extends \PHPUnit_Framework_TestCase private static $namespace = 'OTA'; private static $files = []; - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { if (!self::$files) { self::$files = self::getXmlFiles(); @@ -52,7 +53,7 @@ public static function setUpBeforeClass() self::$validator = self::$generator->getValidator($schemas); } - public static function tearDownAfterClass() + public static function tearDownAfterClass(): void { self::$generator->unRegisterAutoloader(); self::$generator->cleanDirectories(); @@ -219,12 +220,15 @@ private static function getXmlFiles() $name = basename($file); $dir = dirname($file); + $name = str_replace('.xml', '.xsd', $name); $name = preg_replace('/[0-9]+/', '', $name); if (is_file($dir . '/' . $name)) { + $inflector = InflectorFactory::create()->build(); + $tests[$n][0] = $file; $tests[$n][1] = $dir . '/' . $name; - $tests[$n][2] = self::$namespace . '\\' . Inflector::classify(str_replace('.xsd', '', $name)); + $tests[$n][2] = self::$namespace . '\\' . $inflector->classify(str_replace('.xsd', '', $name)); } } diff --git a/tests/PHP/AnyTypePHPConversionTest.php b/tests/PHP/AnyTypePHPConversionTest.php index c70c7723..f4f01c93 100644 --- a/tests/PHP/AnyTypePHPConversionTest.php +++ b/tests/PHP/AnyTypePHPConversionTest.php @@ -7,8 +7,9 @@ use GoetasWebservices\Xsd\XsdToPhp\Naming\ShortNamingStrategy; use GoetasWebservices\Xsd\XsdToPhp\Php\ClassGenerator; use GoetasWebservices\Xsd\XsdToPhp\Php\PhpConverter; +use PHPUnit\Framework\TestCase; -class AnyTypePHPConversionTest extends \PHPUnit_Framework_TestCase +class AnyTypePHPConversionTest extends TestCase { /** * @param mixed $xml diff --git a/tests/PHP/PHPConversionTest.php b/tests/PHP/PHPConversionTest.php index 5f00a978..37e9b494 100644 --- a/tests/PHP/PHPConversionTest.php +++ b/tests/PHP/PHPConversionTest.php @@ -6,8 +6,9 @@ use GoetasWebservices\Xsd\XsdToPhp\Naming\ShortNamingStrategy; use GoetasWebservices\Xsd\XsdToPhp\Php\ClassGenerator; use GoetasWebservices\Xsd\XsdToPhp\Php\PhpConverter; +use PHPUnit\Framework\TestCase; -class PHPConversionTest extends \PHPUnit_Framework_TestCase +class PHPConversionTest extends TestCase { /** * @param mixed $xml diff --git a/tests/PathGenerator/JMSPathGeneratorTest.php b/tests/PathGenerator/JMSPathGeneratorTest.php index a0dbf573..8d07060d 100644 --- a/tests/PathGenerator/JMSPathGeneratorTest.php +++ b/tests/PathGenerator/JMSPathGeneratorTest.php @@ -3,12 +3,13 @@ namespace GoetasWebservices\Xsd\XsdToPhp\Tests\Php\PathGenerator; use GoetasWebservices\Xsd\XsdToPhp\Jms\PathGenerator\Psr4PathGenerator; +use PHPUnit\Framework\TestCase; -class JMSPathGeneratorTest extends \PHPUnit_Framework_TestCase +class JMSPathGeneratorTest extends TestCase { protected $tmpdir; - public function setUp() + public function setUp(): void { $tmp = sys_get_temp_dir(); @@ -24,7 +25,7 @@ public function setUp() public function testNoNs() { - $this->setExpectedException('GoetasWebservices\Xsd\XsdToPhp\PathGenerator\PathGeneratorException'); + $this->expectException('GoetasWebservices\Xsd\XsdToPhp\PathGenerator\PathGeneratorException'); $generator = new Psr4PathGenerator([ 'myns2\\' => $this->tmpdir, ]); diff --git a/tests/PathGenerator/PHPPathGeneratorTest.php b/tests/PathGenerator/PHPPathGeneratorTest.php index b68d8311..d86dfb96 100644 --- a/tests/PathGenerator/PHPPathGeneratorTest.php +++ b/tests/PathGenerator/PHPPathGeneratorTest.php @@ -4,12 +4,13 @@ use GoetasWebservices\Xsd\XsdToPhp\Php\PathGenerator\Psr4PathGenerator; use Laminas\Code\Generator\ClassGenerator; +use PHPUnit\Framework\TestCase; -class PHPPathGeneratorTest extends \PHPUnit_Framework_TestCase +class PHPPathGeneratorTest extends TestCase { protected $tmpdir; - public function setUp() + public function setUp(): void { $tmp = sys_get_temp_dir(); @@ -25,7 +26,7 @@ public function setUp() public function testNoNs() { - $this->setExpectedException('GoetasWebservices\Xsd\XsdToPhp\PathGenerator\PathGeneratorException'); + $this->expectException('GoetasWebservices\Xsd\XsdToPhp\PathGenerator\PathGeneratorException'); $generator = new Psr4PathGenerator([ 'myns\\' => $this->tmpdir, ]); diff --git a/tests/Validator/ValidatorTest.php b/tests/Validator/ValidatorTest.php index f3f0b71e..c910f7af 100644 --- a/tests/Validator/ValidatorTest.php +++ b/tests/Validator/ValidatorTest.php @@ -4,17 +4,18 @@ use Composer\Autoload\ClassLoader; use ota\TestNotNullType; +use PHPUnit\Framework\TestCase; use Symfony\Component\Validator\Validation; use Symfony\Component\Validator\Validator\ValidatorInterface; -class ValidatorTest extends \PHPUnit_Framework_TestCase +class ValidatorTest extends TestCase { /** * @var ValidatorInterface */ protected $validator; - public function setUp() + public function setUp(): void { $loader = new ClassLoader(); $loader->addPsr4('ota\\', __DIR__ . '/ota/php'); diff --git a/tests/VeryShortNamingStrategy.php b/tests/VeryShortNamingStrategy.php index ca5877fb..973f7ef8 100644 --- a/tests/VeryShortNamingStrategy.php +++ b/tests/VeryShortNamingStrategy.php @@ -2,7 +2,7 @@ namespace GoetasWebservices\Xsd\XsdToPhp\Tests; -use Doctrine\Common\Inflector\Inflector; +use Doctrine\Inflector\InflectorFactory; use GoetasWebservices\XML\XSDReader\Schema\Type\Type; use GoetasWebservices\Xsd\XsdToPhp\Naming\ShortNamingStrategy; @@ -48,8 +48,10 @@ public function getAnonymousTypeName(Type $type, $parentName) * * @return string */ - private function classify($name) + protected function classify($name) { - return Inflector::classify(str_replace('.', ' ', $name)); + $inflector = InflectorFactory::create()->build(); + + return $inflector->classify(str_replace('.', ' ', $name)); } }