diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 988beb6b..dbe953f8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,18 +14,36 @@ jobs: matrix: include: - php: '7.4' + symfony-require: 4.4.* - php: '8.0' + symfony-require: 5.3.* + - php: '8.0' + symfony-require: 6.0.* + stability: dev - php: '8.1' - mode: experimental + fail-fast: false steps: - name: Checkout uses: actions/checkout@v2 - - name: "Install dependencies with Composer" - uses: "ramsey/composer-install@v1" + - name: Setup PHP + uses: shivammathur/setup-php@v2 with: - composer-options: "--prefer-dist" + php-version: "${{ matrix.php }}" + coverage: none + + - name: Configure Composer minimum stability + if: matrix.stability + run: composer config minimum-stability ${{ matrix.stability }} + + - name: Install symfony/flex + run: composer global require symfony/flex + + - name: Install dependencies + env: + SYMFONY_REQUIRE: "${{ matrix.symfony-require }}" + run: composer update --prefer-dist - name: "Run PHPUnit" run: "vendor/bin/phpunit" diff --git a/composer.json b/composer.json index 53ddbada..00f12867 100644 --- a/composer.json +++ b/composer.json @@ -14,17 +14,18 @@ "require": { "php": ">=7.4", "giggsey/libphonenumber-for-php": "^8.0", - "symfony/framework-bundle": "^4.4|^5.3", - "symfony/intl": "^4.4|^5.3" + "symfony/framework-bundle": "^4.4|^5.3|^6.0", + "symfony/intl": "^4.4|^5.3|^6.0" }, "require-dev": { "doctrine/doctrine-bundle": "^1.12|^2.0", - "phpunit/phpunit": "^8.4", - "symfony/form": "^4.4|^5.3", - "symfony/property-access": "^4.4|^5.3", - "symfony/serializer": "^4.4|^5.3", - "symfony/twig-bundle": "^4.4|^5.3", - "symfony/validator": "^4.4|^5.3" + "phpspec/prophecy-phpunit": "^2.0", + "phpunit/phpunit": "^9.5", + "symfony/form": "^4.4|^5.3|^6.0", + "symfony/property-access": "^4.4|^5.3|^6.0", + "symfony/serializer": "^4.4|^5.3|^6.0.1", + "symfony/twig-bundle": "^4.4|^5.3|^6.0", + "symfony/validator": "^4.4|^5.3|^6.0" }, "suggest": { "doctrine/doctrine-bundle": "Add a DBAL mapping type", @@ -51,5 +52,8 @@ "branch-alias": { "dev-master": "3.5.x-dev" } + }, + "conflict": { + "symfony/serializer": "6.0.0" } } diff --git a/src/Twig/Extension/PhoneNumberHelperExtension.php b/src/Twig/Extension/PhoneNumberHelperExtension.php index 71bbbf44..bb7f6e3a 100644 --- a/src/Twig/Extension/PhoneNumberHelperExtension.php +++ b/src/Twig/Extension/PhoneNumberHelperExtension.php @@ -41,6 +41,8 @@ public function __construct(PhoneNumberHelper $helper) /** * {@inheritdoc} + * + * @return array */ public function getFunctions() { @@ -53,6 +55,8 @@ public function getFunctions() /** * {@inheritdoc} + * + * @return array */ public function getFilters() { @@ -64,6 +68,8 @@ public function getFilters() /** * {@inheritdoc} + * + * @return array */ public function getTests() { diff --git a/tests/Doctrine/DBAL/Types/PhoneNumberTypeTest.php b/tests/Doctrine/DBAL/Types/PhoneNumberTypeTest.php index d6c5fbe2..ba5e64ed 100644 --- a/tests/Doctrine/DBAL/Types/PhoneNumberTypeTest.php +++ b/tests/Doctrine/DBAL/Types/PhoneNumberTypeTest.php @@ -18,12 +18,15 @@ use libphonenumber\PhoneNumberUtil; use Misd\PhoneNumberBundle\Doctrine\DBAL\Types\PhoneNumberType; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; /** * Phone number type test. */ class PhoneNumberTypeTest extends TestCase { + use ProphecyTrait; + /** * @var AbstractPlatform */ diff --git a/tests/Serializer/Normalizer/PhoneNumberNormalizerTest.php b/tests/Serializer/Normalizer/PhoneNumberNormalizerTest.php index 36626ace..20abdebe 100644 --- a/tests/Serializer/Normalizer/PhoneNumberNormalizerTest.php +++ b/tests/Serializer/Normalizer/PhoneNumberNormalizerTest.php @@ -18,6 +18,7 @@ use Misd\PhoneNumberBundle\Serializer\Normalizer\PhoneNumberNormalizer; use PHPUnit\Framework\TestCase; use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Component\Serializer\Exception\UnexpectedValueException; use Symfony\Component\Serializer\Serializer; @@ -26,6 +27,8 @@ */ class PhoneNumberNormalizerTest extends TestCase { + use ProphecyTrait; + protected function setUp(): void { if (!class_exists(Serializer::class)) { diff --git a/tests/Templating/Helper/PhoneNumberHelperTest.php b/tests/Templating/Helper/PhoneNumberHelperTest.php index 7a923cad..4a97b986 100644 --- a/tests/Templating/Helper/PhoneNumberHelperTest.php +++ b/tests/Templating/Helper/PhoneNumberHelperTest.php @@ -17,12 +17,15 @@ use Misd\PhoneNumberBundle\Exception\InvalidArgumentException; use Misd\PhoneNumberBundle\Templating\Helper\PhoneNumberHelper; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; /** * Phone number templating helper test. */ class PhoneNumberHelperTest extends TestCase { + use ProphecyTrait; + protected $phoneNumberUtil; protected $helper; diff --git a/tests/Validator/Constraints/PhoneNumberValidatorTest.php b/tests/Validator/Constraints/PhoneNumberValidatorTest.php index 654555f2..d417455d 100644 --- a/tests/Validator/Constraints/PhoneNumberValidatorTest.php +++ b/tests/Validator/Constraints/PhoneNumberValidatorTest.php @@ -14,8 +14,8 @@ use libphonenumber\PhoneNumberUtil; use Misd\PhoneNumberBundle\Validator\Constraints\PhoneNumber; use Misd\PhoneNumberBundle\Validator\Constraints\PhoneNumberValidator; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -use Prophecy\Argument; use Symfony\Component\Validator\Context\ExecutionContextInterface; use Symfony\Component\Validator\Exception\UnexpectedTypeException; use Symfony\Component\Validator\Mapping\ClassMetadata; @@ -28,7 +28,7 @@ class PhoneNumberValidatorTest extends TestCase { /** - * @var \Symfony\Component\Validator\Context\ExecutionContextInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Symfony\Component\Validator\Context\ExecutionContextInterface|MockObject */ protected $context; @@ -39,12 +39,12 @@ class PhoneNumberValidatorTest extends TestCase protected function setUp(): void { - $this->context = $this->prophesize(ExecutionContextInterface::class); + $this->context = $this->createMock(ExecutionContextInterface::class); $this->validator = new PhoneNumberValidator(PhoneNumberUtil::getInstance()); - $this->validator->initialize($this->context->reveal()); + $this->validator->initialize($this->context); - $this->context->getObject()->willReturn(new Foo()); + $this->context->method('getObject')->willReturn(new Foo()); } /** @@ -67,14 +67,28 @@ public function testValidate($value, $violates, $type = null, $defaultRegion = n } if (true === $violates) { - $constraintViolationBuilder = $this->prophesize(ConstraintViolationBuilderInterface::class); - $constraintViolationBuilder->setParameter(Argument::type('string'), Argument::type('string'))->willReturn($constraintViolationBuilder->reveal()); - $constraintViolationBuilder->setCode(Argument::type('string'))->willReturn($constraintViolationBuilder->reveal()); - $constraintViolationBuilder->addViolation()->willReturn($constraintViolationBuilder->reveal()); - - $this->context->buildViolation($constraint->getMessage())->shouldBeCalledTimes(1)->willReturn($constraintViolationBuilder->reveal()); + $constraintViolationBuilder = $this->createMock(ConstraintViolationBuilderInterface::class); + $constraintViolationBuilder + ->expects($this->exactly(2)) + ->method('setParameter') + ->with($this->isType('string'), $this->isType('string')) + ->willReturn($constraintViolationBuilder); + $constraintViolationBuilder + ->expects($this->once()) + ->method('setCode') + ->with($this->isType('string')) + ->willReturn($constraintViolationBuilder); + $constraintViolationBuilder + ->method('addViolation') + ->willReturn($constraintViolationBuilder); + + $this->context + ->expects($this->once()) + ->method('buildViolation') + ->with($constraint->getMessage()) + ->willReturn($constraintViolationBuilder); } else { - $this->context->buildViolation()->shouldNotBeCalled(); + $this->context->expects($this->never())->method('buildViolation'); } $this->validator->validate($value, $constraint);