Skip to content

Commit e0affa3

Browse files
author
Jonas Reymen
committed
upgrade to PHP8
1 parent 4419a7c commit e0affa3

File tree

8 files changed

+22
-19
lines changed

8 files changed

+22
-19
lines changed

.github/workflows/test-application.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ jobs:
3030
- php-version: '7.4'
3131
symfony-version: 5.0.*
3232
test-installation: true
33+
- php-version: '8.0'
34+
symfony-version: 5.1.*
35+
test-installation: true
3336

3437
steps:
3538
- name: Checkout project

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
}
1515
],
1616
"require": {
17-
"php": "^7.4",
17+
"php": "^7.4 || ^8.0",
1818
"symfony/framework-bundle": "^4.4 || ^5.0",
1919
"symfony/security-core": "^4.4 || ^5.0"
2020
},
2121
"require-dev": {
2222
"jackalope/jackalope-doctrine-dbal": "^1.3",
2323
"symfony/security-bundle": "^4.4 || ^5.0",
2424
"symfony/phpunit-bridge": "^4.4.34 || ^5.0",
25-
"mockery/mockery": "^0.9.4",
25+
"mockery/mockery": "^1.4.1",
2626
"symfony-cmf/routing-bundle": "^2.1.0",
2727
"symfony-cmf/testing": "^4.0.0",
2828
"doctrine/dbal": "^2.5",

phpunit.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
<php>
3030
<server name="KERNEL_CLASS" value="\Symfony\Cmf\Bundle\CoreBundle\Tests\Fixtures\App\Kernel" />
31+
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0&amp;max[direct]=52"/>
3132
</php>
3233

3334
</phpunit>

tests/Fixtures/App/config/config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@
1717
$loader->import(__DIR__.'/config.yml');
1818

1919
$container->loadFromExtension('framework', [
20-
'csrf_protection' => true,
20+
'csrf_protection' => false,
2121
]);

tests/Functional/Form/CheckboxUrlLabelFormTypeTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function setUp(): void
3030

3131
public function testFormTwigTemplate()
3232
{
33-
$view = $this->getContainer()->get('form.factory')->createNamedBuilder('name')
33+
$view = $this->getContainer()->get('test.service_container')->get('form.factory')->createNamedBuilder('name')
3434
->add('terms', CheckboxUrlLabelFormType::class, [
3535
'label' => '%a% and %b% and %c%',
3636
'routes' => [
@@ -51,7 +51,7 @@ public function testFormTwigTemplate()
5151
*/
5252
private function getFormRenderer()
5353
{
54-
$twig = $this->getContainer()->get('twig');
54+
$twig = $this->getContainer()->get('test.service_container')->get('twig');
5555

5656
// BC for Symfony < 3.2 where this runtime does not exists
5757
if (!method_exists(AppVariable::class, 'getToken')) {

tests/Functional/PublishWorkflow/PublishWorkflowTest.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Cmf\Bundle\CoreBundle\PublishWorkflow\PublishTimePeriodReadInterface;
1616
use Symfony\Cmf\Bundle\CoreBundle\PublishWorkflow\PublishWorkflowChecker;
1717
use Symfony\Cmf\Component\Testing\Functional\BaseTestCase;
18+
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
1819
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
1920
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
2021

@@ -25,9 +26,15 @@ class PublishWorkflowTest extends BaseTestCase
2526
*/
2627
private $publishWorkflowChecker;
2728

29+
/**
30+
* @var TokenStorageInterface
31+
*/
32+
private $tokenStorage;
33+
2834
public function setUp(): void
2935
{
3036
$this->publishWorkflowChecker = $this->getContainer()->get('cmf_core.publish_workflow.checker');
37+
$this->tokenStorage = $this->getContainer()->get('test.service_container')->get('security.token_storage');
3138
}
3239

3340
public function testPublishable()
@@ -69,8 +76,7 @@ public function testIgnoreRoleHas()
6976
'ROLE_CAN_VIEW_NON_PUBLISHED',
7077
];
7178
$token = new UsernamePasswordToken('test', 'pass', 'testprovider', $roles);
72-
$tokenStorage = $this->getContainer()->get('security.token_storage');
73-
$tokenStorage->setToken($token);
79+
$this->tokenStorage->setToken($token);
7480

7581
$this->assertTrue($this->publishWorkflowChecker->isGranted(PublishWorkflowChecker::VIEW_ATTRIBUTE, $doc));
7682
$this->assertFalse($this->publishWorkflowChecker->isGranted(PublishWorkflowChecker::VIEW_ANONYMOUS_ATTRIBUTE, $doc));
@@ -87,8 +93,7 @@ public function testIgnoreRoleNotHas()
8793
'OTHER_ROLE',
8894
];
8995
$token = new UsernamePasswordToken('test', 'pass', 'testprovider', $roles);
90-
$tokenStorage = $this->getContainer()->get('security.token_storage');
91-
$tokenStorage->setToken($token);
96+
$this->tokenStorage->setToken($token);
9297

9398
$this->assertFalse($this->publishWorkflowChecker->isGranted(PublishWorkflowChecker::VIEW_ATTRIBUTE, $doc));
9499
$this->assertFalse($this->publishWorkflowChecker->isGranted(PublishWorkflowChecker::VIEW_ANONYMOUS_ATTRIBUTE, $doc));

tests/Functional/Twig/ServiceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class ServiceTest extends BaseTestCase
1919
public function testContainer()
2020
{
2121
/** @var \Twig\Environment $twig */
22-
$twig = $this->getContainer()->get('twig');
22+
$twig = $this->getContainer()->get('test.service_container')->get('twig');
2323
$ext = $twig->getExtension(method_exists($twig, 'getRuntime') ? CmfExtension::class : 'cmf');
2424
$this->assertNotEmpty($ext);
2525
}

tests/Unit/Templating/Helper/CmfTest.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,10 @@ public function testGetNodeName()
6767
{
6868
$document = new \stdClass();
6969

70-
$this->uow->expects($this->at(0))
70+
$this->uow->expects(self::exactly(2))
7171
->method('getDocumentId')
72-
->with($document)
73-
->will($this->throwException(new \Exception()))
74-
;
75-
76-
$this->uow->expects($this->at(1))
77-
->method('getDocumentId')
78-
->with($document)
79-
->will($this->returnValue('/foo/bar'))
72+
->withConsecutive([$document], [$document])
73+
->willReturnOnConsecutiveCalls($this->throwException(new \Exception()), $this->returnValue('/foo/bar'))
8074
;
8175

8276
$this->assertFalse($this->helper->getNodeName($document));

0 commit comments

Comments
 (0)