diff --git a/Tests/Command/CleanCommandTest.php b/Tests/Command/CleanCommandTest.php index 214495df..ebf3a1a1 100644 --- a/Tests/Command/CleanCommandTest.php +++ b/Tests/Command/CleanCommandTest.php @@ -92,9 +92,9 @@ public function testItShouldRemoveExpiredToken(): void $display = $tester->getDisplay(); - $this->assertContains(sprintf('Removed %d items from %s storage.', $expiredAccessTokens, get_class($this->accessTokenManager)), $display); - $this->assertContains(sprintf('Removed %d items from %s storage.', $expiredRefreshTokens, get_class($this->refreshTokenManager)), $display); - $this->assertContains(sprintf('Removed %d items from %s storage.', $expiredAuthCodes, get_class($this->authCodeManager)), $display); + $this->assertStringContainsString(sprintf('Removed %d items from %s storage.', $expiredAccessTokens, get_class($this->accessTokenManager)), $display); + $this->assertStringContainsString(sprintf('Removed %d items from %s storage.', $expiredRefreshTokens, get_class($this->refreshTokenManager)), $display); + $this->assertStringContainsString(sprintf('Removed %d items from %s storage.', $expiredAuthCodes, get_class($this->authCodeManager)), $display); } /** diff --git a/Tests/CustomAssertions.php b/Tests/CustomAssertions.php new file mode 100644 index 00000000..71f3855e --- /dev/null +++ b/Tests/CustomAssertions.php @@ -0,0 +1,23 @@ +setAccessible(true); + self::assertSame($expected, $prop->getValue($actualObject)); + } +} diff --git a/Tests/DependencyInjection/ConfigurationTest.php b/Tests/DependencyInjection/ConfigurationTest.php index 52fb2607..79fc24dd 100644 --- a/Tests/DependencyInjection/ConfigurationTest.php +++ b/Tests/DependencyInjection/ConfigurationTest.php @@ -14,12 +14,15 @@ namespace FOS\OAuthServerBundle\Tests\DependencyInjection; use FOS\OAuthServerBundle\DependencyInjection\Configuration; +use FOS\OAuthServerBundle\Tests\CustomAssertions; use Symfony\Component\Config\Definition\ConfigurationInterface; use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; use Symfony\Component\Config\Definition\Processor; class ConfigurationTest extends \PHPUnit\Framework\TestCase { + use CustomAssertions; + public function testShouldImplementConfigurationInterface(): void { $rc = new \ReflectionClass(Configuration::class); diff --git a/Tests/Document/AuthCodeManagerTest.php b/Tests/Document/AuthCodeManagerTest.php index 68c5a6b2..335018c4 100644 --- a/Tests/Document/AuthCodeManagerTest.php +++ b/Tests/Document/AuthCodeManagerTest.php @@ -15,10 +15,11 @@ use Doctrine\MongoDB\Query\Builder; use Doctrine\ODM\MongoDB\DocumentManager; -use Doctrine\ODM\MongoDB\DocumentRepository; +use Doctrine\ODM\MongoDB\Repository\DocumentRepository; use Doctrine\ORM\AbstractQuery; use FOS\OAuthServerBundle\Document\AuthCodeManager; use FOS\OAuthServerBundle\Model\AuthCodeInterface; +use FOS\OAuthServerBundle\Tests\CustomAssertions; /** * @group time-sensitive @@ -29,6 +30,8 @@ */ class AuthCodeManagerTest extends \PHPUnit\Framework\TestCase { + use CustomAssertions; + /** * @var \PHPUnit\Framework\MockObject\MockObject|DocumentManager */ diff --git a/Tests/Document/ClientManagerTest.php b/Tests/Document/ClientManagerTest.php index 1bf8bcf4..997829bd 100644 --- a/Tests/Document/ClientManagerTest.php +++ b/Tests/Document/ClientManagerTest.php @@ -17,6 +17,7 @@ use Doctrine\ODM\MongoDB\DocumentRepository; use FOS\OAuthServerBundle\Document\ClientManager; use FOS\OAuthServerBundle\Model\ClientInterface; +use FOS\OAuthServerBundle\Tests\CustomAssertions; /** * Class ClientManagerTest. @@ -25,6 +26,8 @@ */ class ClientManagerTest extends \PHPUnit\Framework\TestCase { + use CustomAssertions; + /** * @var \PHPUnit\Framework\MockObject\MockObject|DocumentManager */ diff --git a/Tests/Entity/AuthCodeManagerTest.php b/Tests/Entity/AuthCodeManagerTest.php index eedacf70..d5b22f75 100644 --- a/Tests/Entity/AuthCodeManagerTest.php +++ b/Tests/Entity/AuthCodeManagerTest.php @@ -20,6 +20,7 @@ use Doctrine\ORM\QueryBuilder; use FOS\OAuthServerBundle\Entity\AuthCodeManager; use FOS\OAuthServerBundle\Model\AuthCodeInterface; +use FOS\OAuthServerBundle\Tests\CustomAssertions; /** * @group time-sensitive @@ -30,6 +31,8 @@ */ class AuthCodeManagerTest extends \PHPUnit\Framework\TestCase { + use CustomAssertions; + /** * @var \PHPUnit\Framework\MockObject\MockObject|EntityManagerInterface */ diff --git a/Tests/Entity/ClientManagerTest.php b/Tests/Entity/ClientManagerTest.php index e4958aa7..e2456be5 100644 --- a/Tests/Entity/ClientManagerTest.php +++ b/Tests/Entity/ClientManagerTest.php @@ -17,6 +17,7 @@ use Doctrine\ORM\EntityRepository; use FOS\OAuthServerBundle\Entity\ClientManager; use FOS\OAuthServerBundle\Model\ClientInterface; +use FOS\OAuthServerBundle\Tests\CustomAssertions; /** * Class ClientManagerTest. @@ -25,6 +26,8 @@ */ class ClientManagerTest extends \PHPUnit\Framework\TestCase { + use CustomAssertions; + /** * @var \PHPUnit\Framework\MockObject\MockObject|EntityManagerInterface */ diff --git a/Tests/Entity/TokenManagerTest.php b/Tests/Entity/TokenManagerTest.php index 1cc2d834..d2dc869d 100644 --- a/Tests/Entity/TokenManagerTest.php +++ b/Tests/Entity/TokenManagerTest.php @@ -21,6 +21,7 @@ use FOS\OAuthServerBundle\Entity\AccessToken; use FOS\OAuthServerBundle\Entity\TokenManager; use FOS\OAuthServerBundle\Model\TokenInterface; +use FOS\OAuthServerBundle\Tests\CustomAssertions; /** * @group time-sensitive @@ -31,6 +32,8 @@ */ class TokenManagerTest extends \PHPUnit\Framework\TestCase { + use CustomAssertions; + /** * @var \PHPUnit\Framework\MockObject\MockObject|EntityManagerInterface */ diff --git a/Tests/Form/Handler/AuthorizeFormHandlerTest.php b/Tests/Form/Handler/AuthorizeFormHandlerTest.php index dd211252..74d5938d 100644 --- a/Tests/Form/Handler/AuthorizeFormHandlerTest.php +++ b/Tests/Form/Handler/AuthorizeFormHandlerTest.php @@ -15,6 +15,7 @@ use FOS\OAuthServerBundle\Form\Handler\AuthorizeFormHandler; use FOS\OAuthServerBundle\Form\Model\Authorize; +use FOS\OAuthServerBundle\Tests\CustomAssertions; use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\Serialization\Author; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\Form\FormInterface; @@ -29,6 +30,8 @@ */ class AuthorizeFormHandlerTest extends \PHPUnit\Framework\TestCase { + use CustomAssertions; + /** * @var FormInterface&\PHPUnit\Framework\MockObject\MockObject */ diff --git a/Tests/Functional/config/config.yml b/Tests/Functional/config/config.yml index ae7bb4f7..6fc71560 100644 --- a/Tests/Functional/config/config.yml +++ b/Tests/Functional/config/config.yml @@ -3,6 +3,7 @@ framework: secret: test router: resource: '%kernel.project_dir%/Tests/Functional/config/routing.yml' + utf8: true twig: exception_controller: null diff --git a/composer.json b/composer.json index f3dc487a..6146f128 100644 --- a/composer.json +++ b/composer.json @@ -31,6 +31,7 @@ "twig/twig": "<1.40 || >=2.0,<2.9" }, "require-dev": { + "dms/phpunit-arraysubset-asserts": "^0.1 || ^0.2", "doctrine/doctrine-bundle": "^2.0", "doctrine/mongodb-odm": "~1.0", "doctrine/orm": "~2.2", diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 5192b311..7ea557b2 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -27,4 +27,8 @@ + + + +