Skip to content

Commit 2164f44

Browse files
authored
Merge pull request #32 from Orbitale/php8
Php 8 & Symfony 6
2 parents 807e4d9 + b57710e commit 2164f44

File tree

8 files changed

+73
-55
lines changed

8 files changed

+73
-55
lines changed

.github/workflows/php.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,18 @@ jobs:
1414
- '8.0'
1515
- '8.1'
1616

17-
name: PHP ${{ matrix.php-version }} on ${{ matrix.operating-system }}
17+
symfony-version:
18+
- '5.3'
19+
- '5.4'
20+
- '6.0'
21+
22+
exclude:
23+
- php-version: 7.3
24+
symfony-version: 6.0
25+
- php-version: 7.4
26+
symfony-version: 6.0
27+
28+
name: PHP ${{ matrix.php-version }} and Symfony ${{ matrix.symfony-version }}
1829
steps:
1930
- uses: actions/checkout@v2
2031

@@ -34,6 +45,12 @@ jobs:
3445
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
3546
restore-keys: ${{ runner.os }}-composer-
3647

48+
- name: Update Symfony version
49+
run: |
50+
sed -i composer.json -e 's/\^5\.0\(.[0-9]\+\)\?[|]\^6\.0/${{ matrix.symfony-version }}.*/g'
51+
3752
- run: composer install
3853

54+
- run: vendor/bin/simple-phpunit --version
55+
3956
- run: vendor/bin/simple-phpunit

Tests/AbstractTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function setUp(): void
2222
static::bootKernel();
2323

2424
/** @var Connection $c */
25-
$c = static::$container->get(Connection::class);
25+
$c = self::getContainer()->get(Connection::class);
2626
$c->query('delete from orbitale_cms_pages where 1');
2727
$c->query('delete from orbitale_cms_categories where 1');
2828
static::ensureKernelShutdown();

Tests/Controller/CategoryControllerTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ class CategoryControllerTest extends AbstractTestCase
2020
{
2121
public function testNoCategoryWithSlug()
2222
{
23-
$client = static::createClient();
23+
$client = self::createClient();
2424
$client->request('GET', '/category/inexistent-slug');
2525
static::assertEquals(404, $client->getResponse()->getStatusCode());
2626
}
2727

2828
public function testSingleCategory()
2929
{
30-
$client = static::createClient();
30+
$client = self::createClient();
3131

3232
$category = new Category();
3333
$category->setSlug('default');
@@ -36,7 +36,7 @@ public function testSingleCategory()
3636
$category->setEnabled(true);
3737

3838
/** @var EntityManagerInterface $em */
39-
$em = static::$container->get(EntityManagerInterface::class);
39+
$em = self::getContainer()->get(EntityManagerInterface::class);
4040
$em->persist($category);
4141
$em->flush();
4242

@@ -53,9 +53,9 @@ public function testSingleCategory()
5353

5454
public function testTree()
5555
{
56-
$client = static::createClient();
56+
$client = self::createClient();
5757
/** @var EntityManagerInterface $em */
58-
$em = static::$container->get(EntityManagerInterface::class);
58+
$em = self::getContainer()->get(EntityManagerInterface::class);
5959

6060
// Prepare 3 pages : the root, the first level, and the third one that's disabled
6161
$parent = new Category();
@@ -100,7 +100,7 @@ public function testTree()
100100

101101
public function testWithPages()
102102
{
103-
$client = static::createClient();
103+
$client = self::createClient();
104104

105105
$category = new Category();
106106
$category->setSlug('default');
@@ -109,7 +109,7 @@ public function testWithPages()
109109
$category->setEnabled(true);
110110

111111
/** @var EntityManagerInterface $em */
112-
$em = static::$container->get(EntityManagerInterface::class);
112+
$em = self::getContainer()->get(EntityManagerInterface::class);
113113
$em->persist($category);
114114
$em->flush();
115115

Tests/Controller/PageControllerTest.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,22 @@ class PageControllerTest extends AbstractTestCase
2020
public function testNoHomepage(): void
2121
{
2222
$error = 'No homepage has been configured. Please check your existing pages or create a homepage in your application. (404 Not Found)';
23-
$client = static::createClient();
23+
$client = self::createClient();
2424
$crawler = $client->request('GET', '/page/');
2525
static::assertEquals($error, trim($crawler->filter('title')->html()));
2626
static::assertEquals(404, $client->getResponse()->getStatusCode());
2727
}
2828

2929
public function testNoPageWithSlug(): void
3030
{
31-
$client = static::createClient();
31+
$client = self::createClient();
3232
$client->request('GET', '/page/inexistent-slug');
3333
static::assertEquals(404, $client->getResponse()->getStatusCode());
3434
}
3535

3636
public function testOneHomepage(): void
3737
{
38-
$client = static::createClient();
38+
$client = self::createClient();
3939

4040
$homepage = $this->createPage([
4141
'homepage' => true,
@@ -47,7 +47,7 @@ public function testOneHomepage(): void
4747
]);
4848

4949
/** @var EntityManagerInterface $em */
50-
$em = static::$container->get(EntityManagerInterface::class);
50+
$em = self::getContainer()->get(EntityManagerInterface::class);
5151
$em->persist($homepage);
5252
$em->flush();
5353

@@ -74,7 +74,7 @@ public function testOneHomepage(): void
7474

7575
public function testOneHomepageWithLocale(): void
7676
{
77-
$client = static::createClient();
77+
$client = self::createClient();
7878

7979
$homepage = $this->createPage([
8080
'homepage' => true,
@@ -87,7 +87,7 @@ public function testOneHomepageWithLocale(): void
8787
]);
8888

8989
/** @var EntityManagerInterface $em */
90-
$em = static::$container->get(EntityManagerInterface::class);
90+
$em = self::getContainer()->get(EntityManagerInterface::class);
9191
$em->persist($homepage);
9292
$em->flush();
9393

@@ -114,10 +114,10 @@ public function testOneHomepageWithLocale(): void
114114

115115
public function testTree(): void
116116
{
117-
$client = static::createClient();
117+
$client = self::createClient();
118118

119119
/** @var EntityManagerInterface $em */
120-
$em = static::$container->get(EntityManagerInterface::class);
120+
$em = self::getContainer()->get(EntityManagerInterface::class);
121121

122122
// Prepare 3 pages : the root, the first level, and the third one that's disabled
123123
$root = $this->createPage([
@@ -163,10 +163,10 @@ public function testTree(): void
163163

164164
public function testMetas(): void
165165
{
166-
$client = static::createClient();
166+
$client = self::createClient();
167167

168168
/** @var EntityManagerInterface $em */
169-
$em = static::$container->get(EntityManagerInterface::class);
169+
$em = self::getContainer()->get(EntityManagerInterface::class);
170170

171171
$page = $this->createPage([
172172
'homepage' => true,
@@ -198,9 +198,9 @@ public function testMetas(): void
198198

199199
public function testParentAndChildrenDontReverse(): void
200200
{
201-
$client = static::createClient();
201+
$client = self::createClient();
202202
/** @var EntityManagerInterface $em */
203-
$em = static::$container->get(EntityManagerInterface::class);
203+
$em = self::getContainer()->get(EntityManagerInterface::class);
204204

205205
$parent = $this->createPage([
206206
'enabled' => true,
@@ -236,10 +236,10 @@ public function testParentAndChildrenDontReverse(): void
236236
*/
237237
public function testAllTypesOfPagesForHomepage(): void
238238
{
239-
$client = static::createClient();
239+
$client = self::createClient();
240240

241241
/** @var EntityManagerInterface $em */
242-
$em = static::$container->get(EntityManagerInterface::class);
242+
$em = self::getContainer()->get(EntityManagerInterface::class);
243243

244244
// First, create the pages
245245
/** @var Page[] $pages */
@@ -290,10 +290,10 @@ public function testAllTypesOfPagesForHomepage(): void
290290

291291
public function testBreadcrumbsDesign(): void
292292
{
293-
$client = static::createClient(['environment' => 'design_breadcrumbs']);
293+
$client = self::createClient(['environment' => 'design_breadcrumbs']);
294294

295295
/** @var EntityManagerInterface $em */
296-
$em = static::$container->get(EntityManagerInterface::class);
296+
$em = self::getContainer()->get(EntityManagerInterface::class);
297297

298298
$page = $this->createPage(['enabled' => true, 'slug' => 'parent', 'title' => 'Parent page']);
299299
$em->persist($page);

Tests/Controller/PostsControllerTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,31 @@ class PostsControllerTest extends AbstractTestCase
99
{
1010
public function testNoSlug(): void
1111
{
12-
$client = static::createClient();
12+
$client = self::createClient();
1313
$client->request('GET', '/posts/2020-01-19/');
1414
static::assertResponseStatusCodeSame(404);
1515
static::assertPageTitleContains('No page identifier provided');
1616
}
1717

1818
public function testNoPostWithSlug(): void
1919
{
20-
$client = static::createClient();
20+
$client = self::createClient();
2121
$client->request('GET', '/posts/2019-12-19/inexistent-slug');
2222
static::assertResponseStatusCodeSame(404);
2323
static::assertPageTitleContains('Post not found');
2424
}
2525

2626
public function testInvalidDateFormat(): void
2727
{
28-
$client = static::createClient();
28+
$client = self::createClient();
2929
$client->request('GET', '/posts/0-0-0/inexistent-slug');
3030
static::assertResponseStatusCodeSame(404);
3131
static::assertPageTitleContains('Invalid date format provided');
3232
}
3333

3434
public function testDateUrlDoesNotMatchPageDate(): void
3535
{
36-
$client = static::createClient();
36+
$client = self::createClient();
3737

3838
$page = $this->createPage([
3939
'createdAt' => new \DateTimeImmutable(),
@@ -43,7 +43,7 @@ public function testDateUrlDoesNotMatchPageDate(): void
4343
]);
4444

4545
/** @var EntityManagerInterface $em */
46-
$em = static::$container->get(EntityManagerInterface::class);
46+
$em = self::getContainer()->get(EntityManagerInterface::class);
4747
$em->persist($page);
4848
$em->flush();
4949

@@ -54,7 +54,7 @@ public function testDateUrlDoesNotMatchPageDate(): void
5454

5555
public function testSuccessfulPost(): void
5656
{
57-
$client = static::createClient();
57+
$client = self::createClient();
5858

5959
$page = $this->createPage([
6060
'createdAt' => $now = new \DateTimeImmutable(),
@@ -64,7 +64,7 @@ public function testSuccessfulPost(): void
6464
]);
6565

6666
/** @var EntityManagerInterface $em */
67-
$em = static::$container->get(EntityManagerInterface::class);
67+
$em = self::getContainer()->get(EntityManagerInterface::class);
6868
$em->persist($page);
6969
$em->flush();
7070

Tests/EventListener/LayoutsListenerTest.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,18 @@
1414
use Doctrine\ORM\EntityManagerInterface;
1515
use Orbitale\Bundle\CmsBundle\Tests\AbstractTestCase;
1616
use Orbitale\Bundle\CmsBundle\Tests\Fixtures\TestBundle\Entity\Page;
17+
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
1718
use Twig\Environment;
1819
use Twig\Error\LoaderError;
1920

2021
class LayoutsListenerTest extends AbstractTestCase
2122
{
2223
public function testDifferentLayout(): void
2324
{
24-
$client = static::createClient(['environment' => 'layout']);
25+
$client = self::createClient(['environment' => 'layout']);
2526

2627
/** @var Environment $twig */
27-
$twig = static::$container->get(Environment::class);
28+
$twig = self::getContainer()->get(Environment::class);
2829
$twig->resolveTemplate('test_layout.html.twig');
2930

3031
$crawler = $client->request('GET', '/page/');
@@ -35,7 +36,7 @@ public function testDifferentLayout(): void
3536

3637
public function testHostLayout(): void
3738
{
38-
$client = static::createClient(['environment' => 'layout'], ['HTTP_HOST' => 'local.host']);
39+
$client = self::createClient(['environment' => 'layout'], ['HTTP_HOST' => 'local.host']);
3940

4041
$crawler = $client->request('GET', '/page/');
4142

@@ -46,13 +47,13 @@ public function testLayoutWrong(): void
4647
{
4748
$this->expectException(LoaderError::class);
4849
$this->expectExceptionMessage('Unable to find template this_layout_does_not_exist.html.twig for layout front. The "layout" parameter must be a valid twig view to be used as a layout in "this_layout_does_not_exist.html.twig".');
49-
static::createClient(['environment' => 'layout_wrong'])->request('GET', '/page/');
50+
self::createClient(['environment' => 'layout_wrong'])->request('GET', '/page/');
5051
}
5152

5253
/**
5354
* {@inheritdoc}
5455
*/
55-
protected static function createClient(array $options = [], array $server = [])
56+
protected static function createClient(array $options = [], array $server = []): KernelBrowser
5657
{
5758
$client = parent::createClient($options, $server);
5859

@@ -65,7 +66,7 @@ protected static function createClient(array $options = [], array $server = [])
6566
$homepage->setContent('Hello world!');
6667

6768
/** @var EntityManagerInterface $em */
68-
$em = static::$container->get(EntityManagerInterface::class);
69+
$em = self::getContainer()->get(EntityManagerInterface::class);
6970
$em->persist($homepage);
7071
$em->flush();
7172

Tests/Fixtures/App/AppKernel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
class AppKernel extends Kernel
2020
{
21-
public function registerBundles()
21+
public function registerBundles(): iterable
2222
{
2323
return [
2424
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
@@ -30,7 +30,7 @@ public function registerBundles()
3030
];
3131
}
3232

33-
public function registerContainerConfiguration(LoaderInterface $loader)
33+
public function registerContainerConfiguration(LoaderInterface $loader): void
3434
{
3535
$loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yaml');
3636

composer.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,24 @@
1010
"doctrine/annotations": "^1.8",
1111
"doctrine/doctrine-bundle": "^2.0",
1212
"doctrine/orm": "^2.5.1",
13-
"symfony/asset": "^5.0",
14-
"symfony/config": "^5.0",
15-
"symfony/dependency-injection": "^5.0",
16-
"symfony/framework-bundle": "^5.0",
17-
"symfony/http-foundation": "^5.0",
18-
"symfony/http-kernel": "^5.0.1",
19-
"symfony/translation": "^5.0",
20-
"symfony/twig-bundle": "^5.0",
21-
"symfony/validator": "^5.0",
13+
"symfony/asset": "^5.3|^6.0",
14+
"symfony/config": "^5.3|^6.0",
15+
"symfony/dependency-injection": "^5.3|^6.0",
16+
"symfony/framework-bundle": "^5.3|^6.0",
17+
"symfony/http-foundation": "^5.3|^6.0",
18+
"symfony/http-kernel": "^5.3|^6.0",
19+
"symfony/translation": "^5.3|^6.0",
20+
"symfony/twig-bundle": "^5.3|^6.0",
21+
"symfony/validator": "^5.3|^6.0",
2222
"twig/twig": "^2.7|^3.0",
23-
"symfony/string": "^5.0"
23+
"symfony/string": "^5.3|^6.0"
2424
},
2525
"require-dev": {
26-
"symfony/browser-kit": "^5.0",
27-
"symfony/css-selector": "^5.0",
28-
"symfony/dom-crawler": "^5.0",
29-
"symfony/phpunit-bridge": "^5.0",
30-
"symfony/yaml": "^5.0"
26+
"symfony/browser-kit": "^5.3|^6.0",
27+
"symfony/css-selector": "^5.3|^6.0",
28+
"symfony/dom-crawler": "^5.3|^6.0",
29+
"symfony/phpunit-bridge": "^5.3|^6.0",
30+
"symfony/yaml": "^5.3|^6.0"
3131
},
3232
"suggest": {
3333
"javiereguiluz/easyadmin-bundle": "To manage your pages directly inside your CMS (view documentation)."

0 commit comments

Comments
 (0)