diff --git a/.gitignore b/.gitignore index 9253b5f6..809dc4fc 100755 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ /.idea composer.lock vendor/ +/.phpunit.result.cache diff --git a/.travis.yml b/.travis.yml index 4380fb4a..1b16d8e0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,8 @@ cache: php: - 7.1 - 7.2 + - 7.3 + - 7.4 matrix: include: @@ -16,9 +18,7 @@ matrix: before_script: - pecl install xmldiff - - echo "xdebug.max_nesting_level=1000" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini - - if [[ $TRAVIS_PHP_VERSION == '7.'* ]]; then composer --dev require ocramius/package-versions:^1.0 --no-update; fi - + - if [[ $TRAVIS_PHP_VERSION == '7.1' && $COMPOSER_FLAGS == '--prefer-lowest --prefer-stable' ]]; then composer --dev require ocramius/package-versions:^1.0 --no-update; fi - composer update $COMPOSER_FLAGS script: diff --git a/composer.json b/composer.json index 89d7ded5..24528b49 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ "psr/log": "^1.0" }, "require-dev": { - "phpunit/phpunit": "^4.8|^5.0", + "phpunit/phpunit": "^7.0|^8.0", "jms/serializer": "^1.9|^2.0|^3.0", "goetas-webservices/xsd2php-runtime": "^0.2.8@dev", "symfony/validator": "^2.3.24|^3.0|^4.0", diff --git a/tests/Converter/AbstractXsdConverterTest.php b/tests/Converter/AbstractXsdConverterTest.php index ebddea14..55a83825 100644 --- a/tests/Converter/AbstractXsdConverterTest.php +++ b/tests/Converter/AbstractXsdConverterTest.php @@ -1,9 +1,13 @@ converter = $this->getMockForAbstractClass('GoetasWebservices\Xsd\XsdToPhp\AbstractConverter', [new ShortNamingStrategy()]); } @@ -23,7 +27,7 @@ public function testAliases() }; $this->converter->addAliasMap('http://www.example.com', "myType", $f); - $handlers = \PHPUnit_Framework_Assert::readAttribute($this->converter, 'typeAliases'); + $handlers = ReflectionUtils::getObjectAttribute($this->converter, 'typeAliases'); $this->assertArrayHasKey('http://www.example.com', $handlers); $this->assertArrayHasKey('myType', $exmpleHandlers = $handlers['http://www.example.com']); @@ -32,7 +36,7 @@ public function testAliases() public function testDefaultAliases() { - $handlers = \PHPUnit_Framework_Assert::readAttribute($this->converter, 'typeAliases'); + $handlers = ReflectionUtils::getObjectAttribute($this->converter, 'typeAliases'); $this->assertArrayHasKey('http://www.w3.org/2001/XMLSchema', $handlers); $defaultHandlers = $handlers['http://www.w3.org/2001/XMLSchema']; @@ -46,7 +50,7 @@ public function testNamespaces() { $this->converter->addNamespace('http://www.example.com', 'some\php\ns'); - $namespaces = \PHPUnit_Framework_Assert::readAttribute($this->converter, 'namespaces'); + $namespaces = ReflectionUtils::getObjectAttribute($this->converter, 'namespaces'); $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 3000b12f..9b88483a 100644 --- a/tests/Converter/JMS/Xsd2JmsBase.php +++ b/tests/Converter/JMS/Xsd2JmsBase.php @@ -4,8 +4,9 @@ use GoetasWebservices\Xsd\XsdToPhp\Jms\YamlConverter; use GoetasWebservices\Xsd\XsdToPhp\Naming\ShortNamingStrategy; use GoetasWebservices\XML\XSDReader\SchemaReader; +use PHPUnit\Framework\TestCase; -abstract class Xsd2JmsBase extends \PHPUnit_Framework_TestCase +abstract class Xsd2JmsBase extends TestCase { /** * @@ -19,7 +20,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 6b2b09f5..ac0c2385 100644 --- a/tests/Converter/PHP/Xsd2PhpBase.php +++ b/tests/Converter/PHP/Xsd2PhpBase.php @@ -4,8 +4,9 @@ use GoetasWebservices\Xsd\XsdToPhp\Naming\ShortNamingStrategy; use GoetasWebservices\Xsd\XsdToPhp\Php\PhpConverter; use GoetasWebservices\XML\XSDReader\SchemaReader; +use PHPUnit\Framework\TestCase; -abstract class Xsd2PhpBase extends \PHPUnit_Framework_TestCase +abstract class Xsd2PhpBase extends TestCase { /** * @@ -19,7 +20,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 ba0bda17..9557b5ff 100644 --- a/tests/Converter/Validator/Xsd2ValidatorTest.php +++ b/tests/Converter/Validator/Xsd2ValidatorTest.php @@ -5,8 +5,9 @@ use GoetasWebservices\Xsd\XsdToPhp\Jms\YamlValidatorConverter; use GoetasWebservices\Xsd\XsdToPhp\Naming\ShortNamingStrategy; use GoetasWebservices\XML\XSDReader\SchemaReader; +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 513eb630..b3194eef 100644 --- a/tests/Issues/I111/I111Test.php +++ b/tests/Issues/I111/I111Test.php @@ -4,8 +4,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/I22/I22Test.php b/tests/Issues/I22/I22Test.php index 3a62016b..b430a19f 100644 --- a/tests/Issues/I22/I22Test.php +++ b/tests/Issues/I22/I22Test.php @@ -4,8 +4,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 508c73e9..f5955575 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 9ac8cd2d..52e45009 100644 --- a/tests/Issues/I40/I40Test.php +++ b/tests/Issues/I40/I40Test.php @@ -7,8 +7,9 @@ use GoetasWebservices\Xsd\XsdToPhp\Php\Structure\PHPClass; use GoetasWebservices\Xsd\XsdToPhp\Php\Structure\PHPProperty; use GoetasWebservices\XML\XSDReader\SchemaReader; +use PHPUnit\Framework\TestCase; -class I40Test extends \PHPUnit_Framework_TestCase +class I40Test extends TestCase { public function testMissingClass() diff --git a/tests/Issues/I43/.gitignore b/tests/Issues/I43/.gitignore new file mode 100644 index 00000000..c0363794 --- /dev/null +++ b/tests/Issues/I43/.gitignore @@ -0,0 +1 @@ +tmp/ \ No newline at end of file diff --git a/tests/Issues/I43/I43Test.php b/tests/Issues/I43/I43Test.php index e0c69c7c..69a68d1c 100644 --- a/tests/Issues/I43/I43Test.php +++ b/tests/Issues/I43/I43Test.php @@ -6,8 +6,9 @@ use GoetasWebservices\Xsd\XsdToPhp\Php\PhpConverter; 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 4a5f77de..fc117961 100644 --- a/tests/Issues/I57/I57Test.php +++ b/tests/Issues/I57/I57Test.php @@ -5,8 +5,9 @@ use GoetasWebservices\Xsd\XsdToPhp\Naming\ShortNamingStrategy; use GoetasWebservices\Xsd\XsdToPhp\Php\PhpConverter; use GoetasWebservices\XML\XSDReader\SchemaReader; +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 0a595bb0..25e39419 100644 --- a/tests/Issues/I63/I63Test.php +++ b/tests/Issues/I63/I63Test.php @@ -4,8 +4,9 @@ use GoetasWebservices\Xsd\XsdToPhp\Naming\ShortNamingStrategy; use GoetasWebservices\Xsd\XsdToPhp\Php\PhpConverter; use GoetasWebservices\XML\XSDReader\SchemaReader; +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 b7f2259d..400e4650 100644 --- a/tests/Issues/I84/I84Test.php +++ b/tests/Issues/I84/I84Test.php @@ -4,8 +4,9 @@ use GoetasWebservices\Xsd\XsdToPhp\Naming\ShortNamingStrategy; use GoetasWebservices\Xsd\XsdToPhp\Php\PhpConverter; use GoetasWebservices\XML\XSDReader\SchemaReader; +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 0c0b14a6..c92181f7 100644 --- a/tests/JmsSerializer/OTA/OTASerializationTest.php +++ b/tests/JmsSerializer/OTA/OTASerializationTest.php @@ -10,9 +10,10 @@ 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 @@ -27,7 +28,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(); @@ -53,7 +54,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(); @@ -203,6 +204,8 @@ public function testValidation($xml, $xsd, $class) if (@$xmlDom->schemaValidate($xsd)) { $this->assertCount(0, $violations, 'Validation errors in '.$xml); + } else { + $this->assertTrue(true); } } diff --git a/tests/PHP/AnyTypePHPConversionTest.php b/tests/PHP/AnyTypePHPConversionTest.php index 34808e8d..d839a3f2 100644 --- a/tests/PHP/AnyTypePHPConversionTest.php +++ b/tests/PHP/AnyTypePHPConversionTest.php @@ -6,8 +6,9 @@ use GoetasWebservices\Xsd\XsdToPhp\Php\ClassGenerator; use GoetasWebservices\Xsd\XsdToPhp\Php\PhpConverter; use GoetasWebservices\XML\XSDReader\SchemaReader; +use PHPUnit\Framework\TestCase; -class AnyTypePHPConversionTest extends \PHPUnit_Framework_TestCase +class AnyTypePHPConversionTest extends TestCase { /** diff --git a/tests/PHP/PHPConversionTest.php b/tests/PHP/PHPConversionTest.php index d16df851..a52e820e 100644 --- a/tests/PHP/PHPConversionTest.php +++ b/tests/PHP/PHPConversionTest.php @@ -5,8 +5,9 @@ use GoetasWebservices\Xsd\XsdToPhp\Php\ClassGenerator; use GoetasWebservices\Xsd\XsdToPhp\Php\PhpConverter; use GoetasWebservices\XML\XSDReader\SchemaReader; +use PHPUnit\Framework\TestCase; -class PHPConversionTest extends \PHPUnit_Framework_TestCase +class PHPConversionTest extends TestCase { /** diff --git a/tests/PathGenerator/JMSPathGeneratorTest.php b/tests/PathGenerator/JMSPathGeneratorTest.php index 1b288fab..3438874f 100644 --- a/tests/PathGenerator/JMSPathGeneratorTest.php +++ b/tests/PathGenerator/JMSPathGeneratorTest.php @@ -2,12 +2,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(); @@ -23,7 +24,7 @@ public function setUp() public function testNoNs() { - $this->setExpectedException('GoetasWebservices\Xsd\XsdToPhp\PathGenerator\PathGeneratorException'); + $this->expectException('GoetasWebservices\Xsd\XsdToPhp\PathGenerator\PathGeneratorException'); $generator = new Psr4PathGenerator(array( 'myns2\\' => $this->tmpdir )); diff --git a/tests/PathGenerator/PHPPathGeneratorTest.php b/tests/PathGenerator/PHPPathGeneratorTest.php index 55daa333..24593ed3 100644 --- a/tests/PathGenerator/PHPPathGeneratorTest.php +++ b/tests/PathGenerator/PHPPathGeneratorTest.php @@ -4,12 +4,13 @@ use GoetasWebservices\Xsd\XsdToPhp\Php\PathGenerator\Psr4PathGenerator; use GoetasWebservices\Xsd\XsdToPhp\Php\Structure\PHPClass; 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(array( 'myns\\' => $this->tmpdir )); diff --git a/tests/ReflectionUtils.php b/tests/ReflectionUtils.php new file mode 100644 index 00000000..13503fda --- /dev/null +++ b/tests/ReflectionUtils.php @@ -0,0 +1,55 @@ +getProperty($attributeName); + + if (!$attribute || $attribute->isPublic()) { + return $object->$attributeName; + } + + $attribute->setAccessible(true); + $value = $attribute->getValue($object); + $attribute->setAccessible(false); + + return $value; + } catch (\ReflectionException $e) { + } + } while ($reflector = $reflector->getParentClass()); + + throw new Exception( + \sprintf( + 'Attribute "%s" not found in object.', + $attributeName + ) + ); + } +} \ No newline at end of file diff --git a/tests/Validator/ValidatorTest.php b/tests/Validator/ValidatorTest.php index 8e5f0784..b68b4432 100644 --- a/tests/Validator/ValidatorTest.php +++ b/tests/Validator/ValidatorTest.php @@ -2,19 +2,20 @@ namespace GoetasWebservices\Xsd\XsdToPhp\Tests\Php\PathGenerator; use Composer\Autoload\ClassLoader; +use PHPUnit\Framework\TestCase; use Symfony\Component\Validator\Validation; use Symfony\Component\Validator\Validator\ValidatorInterface; use ota\TestNotNullType; -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");