From 2d497348ffaa4e9afe63be3f5f43b98fe2b4c33c Mon Sep 17 00:00:00 2001 From: Ismael Ambrosi Date: Sun, 19 Jan 2020 01:44:11 -0300 Subject: [PATCH 1/4] Updated tests to use Prophecy These tests now support PHP 7.2, 7.3 and 7.4, as there no error about calling the deprecated method ReflectionType::__toString(); --- .../Bridge/Container/BuildContainerTest.php | 14 +++++------ .../Container/ProviderContainerTest.php | 6 ++--- .../Bridge/Container/ServiceContainerTest.php | 18 +++++++-------- .../Bridge/Container/StoreContainerTest.php | 6 ++--- .../Bridge/Container/SystemContainerTest.php | 10 ++++---- ...OwnEntityDescriptorProviderFactoryTest.php | 23 +++++++++---------- 6 files changed, 38 insertions(+), 39 deletions(-) diff --git a/tests/LightSaml/SymfonyBridgeBundle/Tests/Bridge/Container/BuildContainerTest.php b/tests/LightSaml/SymfonyBridgeBundle/Tests/Bridge/Container/BuildContainerTest.php index e80b2a6..26be4cf 100644 --- a/tests/LightSaml/SymfonyBridgeBundle/Tests/Bridge/Container/BuildContainerTest.php +++ b/tests/LightSaml/SymfonyBridgeBundle/Tests/Bridge/Container/BuildContainerTest.php @@ -17,13 +17,13 @@ class BuildContainerTest extends TestCase public function test_constructs_with_all_containers() { new BuildContainer( - $this->getMockBuilder(SystemContainerInterface::class)->getMock(), - $this->getMockBuilder(PartyContainerInterface::class)->getMock(), - $this->getMockBuilder(StoreContainerInterface::class)->getMock(), - $this->getMockBuilder(ProviderContainerInterface::class)->getMock(), - $this->getMockBuilder(CredentialContainerInterface::class)->getMock(), - $this->getMockBuilder(ServiceContainerInterface::class)->getMock(), - $this->getMockBuilder(OwnContainerInterface::class)->getMock() + $this->prophesize(SystemContainerInterface::class)->reveal(), + $this->prophesize(PartyContainerInterface::class)->reveal(), + $this->prophesize(StoreContainerInterface::class)->reveal(), + $this->prophesize(ProviderContainerInterface::class)->reveal(), + $this->prophesize(CredentialContainerInterface::class)->reveal(), + $this->prophesize(ServiceContainerInterface::class)->reveal(), + $this->prophesize(OwnContainerInterface::class)->reveal() ); } } diff --git a/tests/LightSaml/SymfonyBridgeBundle/Tests/Bridge/Container/ProviderContainerTest.php b/tests/LightSaml/SymfonyBridgeBundle/Tests/Bridge/Container/ProviderContainerTest.php index 3bb0217..7e07895 100644 --- a/tests/LightSaml/SymfonyBridgeBundle/Tests/Bridge/Container/ProviderContainerTest.php +++ b/tests/LightSaml/SymfonyBridgeBundle/Tests/Bridge/Container/ProviderContainerTest.php @@ -13,9 +13,9 @@ class ProviderContainerTest extends TestCase public function test_constructs_with_all_arguments() { new ProviderContainer( - $this->getMockBuilder(AttributeValueProviderInterface::class)->getMock(), - $this->getMockBuilder(SessionInfoProviderInterface::class)->getMock(), - $this->getMockBuilder(NameIdProviderInterface::class)->getMock() + $this->prophesize(AttributeValueProviderInterface::class)->reveal(), + $this->prophesize(SessionInfoProviderInterface::class)->reveal(), + $this->prophesize(NameIdProviderInterface::class)->reveal() ); } } diff --git a/tests/LightSaml/SymfonyBridgeBundle/Tests/Bridge/Container/ServiceContainerTest.php b/tests/LightSaml/SymfonyBridgeBundle/Tests/Bridge/Container/ServiceContainerTest.php index 04c4ed5..d91261e 100644 --- a/tests/LightSaml/SymfonyBridgeBundle/Tests/Bridge/Container/ServiceContainerTest.php +++ b/tests/LightSaml/SymfonyBridgeBundle/Tests/Bridge/Container/ServiceContainerTest.php @@ -19,15 +19,15 @@ class ServiceContainerTest extends TestCase public function test_constructs_with_all_arguments() { new ServiceContainer( - $this->getMockBuilder(AssertionValidatorInterface::class)->getMock(), - $this->getMockBuilder(AssertionTimeValidatorInterface::class)->getMock(), - $this->getMockBuilder(SignatureResolverInterface::class)->getMock(), - $this->getMockBuilder(EndpointResolverInterface::class)->getMock(), - $this->getMockBuilder(NameIdValidatorInterface::class)->getMock(), - $this->getMockBuilder(BindingFactoryInterface::class)->getMock(), - $this->getMockBuilder(SignatureValidatorInterface::class)->getMock(), - $this->getMockBuilder(CredentialResolverInterface::class)->getMock(), - $this->getMockBuilder(SessionProcessorInterface::class)->getMock() + $this->prophesize(AssertionValidatorInterface::class)->reveal(), + $this->prophesize(AssertionTimeValidatorInterface::class)->reveal(), + $this->prophesize(SignatureResolverInterface::class)->reveal(), + $this->prophesize(EndpointResolverInterface::class)->reveal(), + $this->prophesize(NameIdValidatorInterface::class)->reveal(), + $this->prophesize(BindingFactoryInterface::class)->reveal(), + $this->prophesize(SignatureValidatorInterface::class)->reveal(), + $this->prophesize(CredentialResolverInterface::class)->reveal(), + $this->prophesize(SessionProcessorInterface::class)->reveal() ); } } diff --git a/tests/LightSaml/SymfonyBridgeBundle/Tests/Bridge/Container/StoreContainerTest.php b/tests/LightSaml/SymfonyBridgeBundle/Tests/Bridge/Container/StoreContainerTest.php index d0f0c31..939c9c3 100644 --- a/tests/LightSaml/SymfonyBridgeBundle/Tests/Bridge/Container/StoreContainerTest.php +++ b/tests/LightSaml/SymfonyBridgeBundle/Tests/Bridge/Container/StoreContainerTest.php @@ -13,9 +13,9 @@ class StoreContainerTest extends TestCase public function test_constructs_with_all_arguments() { new StoreContainer( - $this->getMockBuilder(RequestStateStoreInterface::class)->getMock(), - $this->getMockBuilder(IdStoreInterface::class)->getMock(), - $this->getMockBuilder(SsoStateStoreInterface::class)->getMock() + $this->prophesize(RequestStateStoreInterface::class)->reveal(), + $this->prophesize(IdStoreInterface::class)->reveal(), + $this->prophesize(SsoStateStoreInterface::class)->reveal() ); } } diff --git a/tests/LightSaml/SymfonyBridgeBundle/Tests/Bridge/Container/SystemContainerTest.php b/tests/LightSaml/SymfonyBridgeBundle/Tests/Bridge/Container/SystemContainerTest.php index be80870..5778574 100644 --- a/tests/LightSaml/SymfonyBridgeBundle/Tests/Bridge/Container/SystemContainerTest.php +++ b/tests/LightSaml/SymfonyBridgeBundle/Tests/Bridge/Container/SystemContainerTest.php @@ -15,11 +15,11 @@ class SystemContainerTest extends TestCase public function test_constructs_with_all_arguments() { new SystemContainer( - $this->getMockBuilder(RequestStack::class)->getMock(), - $this->getMockBuilder(SessionInterface::class)->getMock(), - $this->getMockBuilder(TimeProviderInterface::class)->getMock(), - $this->getMockBuilder(EventDispatcherInterface::class)->getMock(), - $this->getMockBuilder(LoggerInterface::class)->getMock() + $this->prophesize(RequestStack::class)->reveal(), + $this->prophesize(SessionInterface::class)->reveal(), + $this->prophesize(TimeProviderInterface::class)->reveal(), + $this->prophesize(EventDispatcherInterface::class)->reveal(), + $this->prophesize(LoggerInterface::class)->reveal() ); } } diff --git a/tests/LightSaml/SymfonyBridgeBundle/Tests/Factory/OwnEntityDescriptorProviderFactoryTest.php b/tests/LightSaml/SymfonyBridgeBundle/Tests/Factory/OwnEntityDescriptorProviderFactoryTest.php index d54d3fc..5856a5c 100644 --- a/tests/LightSaml/SymfonyBridgeBundle/Tests/Factory/OwnEntityDescriptorProviderFactoryTest.php +++ b/tests/LightSaml/SymfonyBridgeBundle/Tests/Factory/OwnEntityDescriptorProviderFactoryTest.php @@ -8,6 +8,7 @@ use LightSaml\Store\Credential\CredentialStoreInterface; use LightSaml\SymfonyBridgeBundle\Factory\OwnEntityDescriptorProviderFactory; use PHPUnit\Framework\TestCase; +use Prophecy\Argument; use Symfony\Component\Routing\RouterInterface; class OwnEntityDescriptorProviderFactoryTest extends TestCase @@ -16,26 +17,24 @@ public function test_returns_entity_descriptor_builder() { $factory = new OwnEntityDescriptorProviderFactory(); - $routerMock = $this->getMockBuilder(RouterInterface::class)->getMock(); - $routerMock->expects($this->exactly(2)) - ->method('generate') - ->with($this->isType('string'), [], RouterInterface::ABSOLUTE_URL) + $routerMock = $this->prophesize(RouterInterface::class); + $routerMock->generate(Argument::type('string'), [], RouterInterface::ABSOLUTE_URL) + ->shouldBeCalledTimes(2) ->willReturn('http://localhost'); - $credentialStoreMock = $this->getMockBuilder(CredentialStoreInterface::class)->getMock(); - $credentialStoreMock->method('getByEntityId') - ->with($ownEntityId = 'own-id') - ->willReturn([$credentialMock = $this->getMockBuilder(X509CredentialInterface::class)->getMock()]); + $credentialStoreMock = $this->prophesize(CredentialStoreInterface::class); + $credentialStoreMock->getByEntityId($ownEntityId = 'own-id') + ->willReturn([$credentialMock = $this->prophesize(X509CredentialInterface::class)]); - $credentialMock->method('getCertificate') - ->willReturn($this->getMockBuilder(X509Certificate::class)->getMock()); + $credentialMock->getCertificate() + ->willReturn($this->prophesize(X509Certificate::class)); $value = $factory->build( $ownEntityId, - $routerMock, + $routerMock->reveal(), 'acs', 'sso', - $credentialStoreMock + $credentialStoreMock->reveal() ); $this->assertInstanceOf(EntityDescriptorProviderInterface::class, $value); From de5446a8c6e5a49da8568d1b6a4dda62c0ca11a5 Mon Sep 17 00:00:00 2001 From: Ismael Ambrosi Date: Sun, 19 Jan 2020 02:16:28 -0300 Subject: [PATCH 2/4] Added support for Symfony 5 --- composer.json | 14 +++++++------- .../DependencyInjection/Configuration.php | 7 +++++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index fcdde70..8f0b7da 100644 --- a/composer.json +++ b/composer.json @@ -20,16 +20,16 @@ }, "require": { "php": ">=5.5.1", - "symfony/framework-bundle": "~2.7|~3.0|~4.0", - "symfony/dependency-injection": "~2.7|~3.0|~4.0", - "symfony/yaml": "~2.7|~3.0|~4.0", + "symfony/framework-bundle": "~2.7|~3.0|~4.0|~5.0", + "symfony/dependency-injection": "~2.7|~3.0|~4.0|~5.0", + "symfony/yaml": "~2.7|~3.0|~4.0|~5.0", "lightsaml/lightsaml": "~1.1" }, "require-dev": { - "symfony/browser-kit": "~2.7|~3.0|~4.0", - "symfony/finder": "~2.7|~3.0|~4.0", - "symfony/filesystem": "~2.7|~3.0|~4.0", - "symfony/routing": "~2.7|~3.0|~4.0", + "symfony/browser-kit": "~2.7|~3.0|~4.0|~5.0", + "symfony/finder": "~2.7|~3.0|~4.0|~5.0", + "symfony/filesystem": "~2.7|~3.0|~4.0|~5.0", + "symfony/routing": "~2.7|~3.0|~4.0|~5.0", "phpunit/phpunit": "^5.7" }, "config": { diff --git a/src/LightSaml/SymfonyBridgeBundle/DependencyInjection/Configuration.php b/src/LightSaml/SymfonyBridgeBundle/DependencyInjection/Configuration.php index a4cc7d6..59073c1 100644 --- a/src/LightSaml/SymfonyBridgeBundle/DependencyInjection/Configuration.php +++ b/src/LightSaml/SymfonyBridgeBundle/DependencyInjection/Configuration.php @@ -23,8 +23,11 @@ class Configuration implements ConfigurationInterface */ public function getConfigTreeBuilder() { - $treeBuilder = new TreeBuilder(); - $root = $treeBuilder->root('light_saml_symfony_bridge'); + $treeBuilder = new TreeBuilder('light_saml_symfony_bridge'); + + $root = method_exists($treeBuilder, 'getRootNode') + ? $treeBuilder->getRootNode() + : $treeBuilder->root('light_saml_symfony_bridge'); $root->children() ->arrayNode('own') From 491a83ae350417c7e1ff28b692b6324c88968547 Mon Sep 17 00:00:00 2001 From: Ismael Ambrosi Date: Sun, 19 Jan 2020 02:24:06 -0300 Subject: [PATCH 3/4] Test in newer versions of PHP --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 0cb7952..d036672 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,9 @@ php: - 5.6 - 7.0 - 7.1 + - 7.2 + - 7.3 + - 7.4 matrix: include: From 9393900e4c38bafea23129bfc9e990bd829b3e52 Mon Sep 17 00:00:00 2001 From: Ismael Ambrosi Date: Sun, 19 Jan 2020 02:36:12 -0300 Subject: [PATCH 4/4] Run composer without memory limit fixing errors in PHP 5.6 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d036672..7d7a1f6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,7 +21,7 @@ before_install: - if [ "$TRAVIS_PHP_VERSION" == "7.0" ]; then wget https://github.com/php-coveralls/php-coveralls/releases/download/v2.1.0/php-coveralls.phar; fi install: - - COMPOSER_ROOT_VERSION=dev-master composer update --prefer-source $COMPOSER_FLAGS + - COMPOSER_ROOT_VERSION=dev-master COMPOSER_MEMORY_LIMIT=-1 composer update --prefer-source $COMPOSER_FLAGS script: - if [ "$TRAVIS_PHP_VERSION" == "7.0" ]; then php php-cs-fixer.phar fix --dry-run -v; fi