Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow Symfony 6 #96

Merged
merged 5 commits into from
Dec 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stability requirement can be removed once Symfony 6.0.1 was released

- 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"
20 changes: 12 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -51,5 +52,8 @@
"branch-alias": {
"dev-master": "3.5.x-dev"
}
},
"conflict": {
"symfony/serializer": "6.0.0"
}
}
6 changes: 6 additions & 0 deletions src/Twig/Extension/PhoneNumberHelperExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public function __construct(PhoneNumberHelper $helper)

/**
* {@inheritdoc}
*
* @return array
*/
public function getFunctions()
{
Expand All @@ -53,6 +55,8 @@ public function getFunctions()

/**
* {@inheritdoc}
*
* @return array
*/
public function getFilters()
{
Expand All @@ -64,6 +68,8 @@ public function getFilters()

/**
* {@inheritdoc}
*
* @return array
*/
public function getTests()
{
Expand Down
3 changes: 3 additions & 0 deletions tests/Doctrine/DBAL/Types/PhoneNumberTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
3 changes: 3 additions & 0 deletions tests/Serializer/Normalizer/PhoneNumberNormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -26,6 +27,8 @@
*/
class PhoneNumberNormalizerTest extends TestCase
{
use ProphecyTrait;

protected function setUp(): void
{
if (!class_exists(Serializer::class)) {
Expand Down
3 changes: 3 additions & 0 deletions tests/Templating/Helper/PhoneNumberHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
38 changes: 26 additions & 12 deletions tests/Validator/Constraints/PhoneNumberValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -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());
}

/**
Expand All @@ -67,14 +67,28 @@ public function testValidate($value, $violates, $type = null, $defaultRegion = n
}

if (true === $violates) {
$constraintViolationBuilder = $this->prophesize(ConstraintViolationBuilderInterface::class);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rewritten because of phpspec/prophecy#527

$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);
Expand Down