Skip to content

Commit

Permalink
Merge pull request #279 from Inventis/upgrade-php8
Browse files Browse the repository at this point in the history
upgrade to PHP8
  • Loading branch information
dbu authored Dec 10, 2021
2 parents 4419a7c + e0affa3 commit 83ca1b0
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 19 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/test-application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ jobs:
- php-version: '7.4'
symfony-version: 5.0.*
test-installation: true
- php-version: '8.0'
symfony-version: 5.1.*
test-installation: true

steps:
- name: Checkout project
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
}
],
"require": {
"php": "^7.4",
"php": "^7.4 || ^8.0",
"symfony/framework-bundle": "^4.4 || ^5.0",
"symfony/security-core": "^4.4 || ^5.0"
},
"require-dev": {
"jackalope/jackalope-doctrine-dbal": "^1.3",
"symfony/security-bundle": "^4.4 || ^5.0",
"symfony/phpunit-bridge": "^4.4.34 || ^5.0",
"mockery/mockery": "^0.9.4",
"mockery/mockery": "^1.4.1",
"symfony-cmf/routing-bundle": "^2.1.0",
"symfony-cmf/testing": "^4.0.0",
"doctrine/dbal": "^2.5",
Expand Down
1 change: 1 addition & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

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

</phpunit>
2 changes: 1 addition & 1 deletion tests/Fixtures/App/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
$loader->import(__DIR__.'/config.yml');

$container->loadFromExtension('framework', [
'csrf_protection' => true,
'csrf_protection' => false,
]);
4 changes: 2 additions & 2 deletions tests/Functional/Form/CheckboxUrlLabelFormTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function setUp(): void

public function testFormTwigTemplate()
{
$view = $this->getContainer()->get('form.factory')->createNamedBuilder('name')
$view = $this->getContainer()->get('test.service_container')->get('form.factory')->createNamedBuilder('name')
->add('terms', CheckboxUrlLabelFormType::class, [
'label' => '%a% and %b% and %c%',
'routes' => [
Expand All @@ -51,7 +51,7 @@ public function testFormTwigTemplate()
*/
private function getFormRenderer()
{
$twig = $this->getContainer()->get('twig');
$twig = $this->getContainer()->get('test.service_container')->get('twig');

// BC for Symfony < 3.2 where this runtime does not exists
if (!method_exists(AppVariable::class, 'getToken')) {
Expand Down
13 changes: 9 additions & 4 deletions tests/Functional/PublishWorkflow/PublishWorkflowTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Symfony\Cmf\Bundle\CoreBundle\PublishWorkflow\PublishTimePeriodReadInterface;
use Symfony\Cmf\Bundle\CoreBundle\PublishWorkflow\PublishWorkflowChecker;
use Symfony\Cmf\Component\Testing\Functional\BaseTestCase;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;

Expand All @@ -25,9 +26,15 @@ class PublishWorkflowTest extends BaseTestCase
*/
private $publishWorkflowChecker;

/**
* @var TokenStorageInterface
*/
private $tokenStorage;

public function setUp(): void
{
$this->publishWorkflowChecker = $this->getContainer()->get('cmf_core.publish_workflow.checker');
$this->tokenStorage = $this->getContainer()->get('test.service_container')->get('security.token_storage');
}

public function testPublishable()
Expand Down Expand Up @@ -69,8 +76,7 @@ public function testIgnoreRoleHas()
'ROLE_CAN_VIEW_NON_PUBLISHED',
];
$token = new UsernamePasswordToken('test', 'pass', 'testprovider', $roles);
$tokenStorage = $this->getContainer()->get('security.token_storage');
$tokenStorage->setToken($token);
$this->tokenStorage->setToken($token);

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

$this->assertFalse($this->publishWorkflowChecker->isGranted(PublishWorkflowChecker::VIEW_ATTRIBUTE, $doc));
$this->assertFalse($this->publishWorkflowChecker->isGranted(PublishWorkflowChecker::VIEW_ANONYMOUS_ATTRIBUTE, $doc));
Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/Twig/ServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ServiceTest extends BaseTestCase
public function testContainer()
{
/** @var \Twig\Environment $twig */
$twig = $this->getContainer()->get('twig');
$twig = $this->getContainer()->get('test.service_container')->get('twig');
$ext = $twig->getExtension(method_exists($twig, 'getRuntime') ? CmfExtension::class : 'cmf');
$this->assertNotEmpty($ext);
}
Expand Down
12 changes: 3 additions & 9 deletions tests/Unit/Templating/Helper/CmfTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,10 @@ public function testGetNodeName()
{
$document = new \stdClass();

$this->uow->expects($this->at(0))
$this->uow->expects(self::exactly(2))
->method('getDocumentId')
->with($document)
->will($this->throwException(new \Exception()))
;

$this->uow->expects($this->at(1))
->method('getDocumentId')
->with($document)
->will($this->returnValue('/foo/bar'))
->withConsecutive([$document], [$document])
->willReturnOnConsecutiveCalls($this->throwException(new \Exception()), $this->returnValue('/foo/bar'))
;

$this->assertFalse($this->helper->getNodeName($document));
Expand Down

0 comments on commit 83ca1b0

Please sign in to comment.