Skip to content

Commit

Permalink
Add Symfony 7 support
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCadien authored and alexander-schranz committed Jun 10, 2024
1 parent 2513db3 commit b8f0b85
Show file tree
Hide file tree
Showing 20 changed files with 928 additions and 92 deletions.
136 changes: 72 additions & 64 deletions .github/workflows/test-application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,37 +21,45 @@ jobs:
fail-fast: false
matrix:
include:
- php-version: '7.3'
lint: false
coverage: false
dependency-versions: 'lowest'
tools: 'composer:v1'
env:
SYMFONY_DEPRECATIONS_HELPER: disabled

- php-version: '7.4'
lint: true
coverage: true
dependency-versions: 'highest'
tools: 'composer:v2'
env:
SYMFONY_DEPRECATIONS_HELPER: weak

- php-version: '8.0'
lint: false
coverage: false
dependency-versions: 'highest'
tools: 'composer:v2'
env:
SYMFONY_DEPRECATIONS_HELPER: weak

- php-version: '8.1'
lint: false
coverage: false
dependency-versions: 'highest'
tools: 'composer:v2'
env:
SYMFONY_DEPRECATIONS_HELPER: weak
- php-version: '8.0'
lint: false
coverage: false
dependency-versions: 'lowest'
tools: 'composer:v2'
env:
SYMFONY_DEPRECATIONS_HELPER: disabled

- php-version: '8.0'
lint: true
coverage: true
dependency-versions: 'highest'
tools: 'composer:v2'
env:
SYMFONY_DEPRECATIONS_HELPER: weak

- php-version: '8.1'
lint: true
coverage: true
dependency-versions: 'highest'
tools: 'composer:v2'
env:
SYMFONY_DEPRECATIONS_HELPER: weak

- php-version: '8.2'
lint: true
coverage: true
dependency-versions: 'highest'
tools: 'composer:v2'
env:
SYMFONY_DEPRECATIONS_HELPER: weak

- php-version: '8.3'
lint: false
coverage: false
dependency-versions: 'highest'
tools: 'composer:v2'
env:
SYMFONY_DEPRECATIONS_HELPER: weak

services:
mysql:
Expand All @@ -63,36 +71,36 @@ jobs:
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5

steps:
- name: Checkout project
uses: actions/checkout@v2

- name: Install and configure PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: ctype, iconv, mysql
coverage: pcov
tools: ${{ matrix.tools }}

- name: Install composer dependencies
uses: ramsey/composer-install@v1
with:
dependency-versions: ${{ matrix.dependency-versions }}
composer-options: ${{ matrix.composer-options }}

- name: Bootstrap test environment
run: composer bootstrap-test-environment

- name: Lint code
if: ${{ matrix.lint }}
run: composer lint

- name: Execute unit test cases
run: composer test -- Tests/Unit --coverage-php var/coverage.php --coverage-html coverage-report --log-junit var/junit.xml

- name: Execute functional test cases
run: composer test -- Tests/Functional --log-junit var/junit.xml

- name: Check code coverage
if: ${{ matrix.coverage }}
run: php vendor/bin/code-coverage-checker "var/coverage.php" "line" "95" "Content"
- name: Checkout project
uses: actions/checkout@v2

- name: Install and configure PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: ctype, iconv, mysql
coverage: pcov
tools: ${{ matrix.tools }}

- name: Install composer dependencies
uses: ramsey/composer-install@v1
with:
dependency-versions: ${{ matrix.dependency-versions }}
composer-options: ${{ matrix.composer-options }}

- name: Bootstrap test environment
run: composer bootstrap-test-environment

- name: Lint code
if: ${{ matrix.lint }}
run: composer lint

- name: Execute unit test cases
run: composer test -- Tests/Unit --coverage-php var/coverage.php --coverage-html coverage-report --log-junit var/junit.xml

- name: Execute functional test cases
run: composer test -- Tests/Functional --log-junit var/junit.xml

- name: Check code coverage
if: ${{ matrix.coverage }}
run: php vendor/bin/code-coverage-checker "var/coverage.php" "line" "95" "Content"
2 changes: 1 addition & 1 deletion Content/Serializer/MediaSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function serialize(MediaInterface $media, string $locale, ?SerializationC
$fileName = \pathinfo($fileName)['filename'] . '.' . $preferredExtension;

// extension brackets cannot be added here because of the urlencoding
$fileName = \pathinfo($fileName)['filename'] . '.' . 'extension';
$fileName = \pathinfo($fileName)['filename'] . '.extension';
$formatUri = $this->formatCache->getMediaUrl(
$formatMediaApi->getId(),
$fileName,
Expand Down
2 changes: 1 addition & 1 deletion Content/StructureResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public function resolveProperties(
}

// the '.' is used to separate the extension name from the property name.
if (false !== \strpos($sourceProperty, '.')) {
if (\str_contains($sourceProperty, '.')) {
[$extensionName, $propertyName] = \explode('.', $sourceProperty);

if (!isset($unresolvedExtensionData[$extensionName][$propertyName])) {
Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

class Configuration implements ConfigurationInterface
{
public function getConfigTreeBuilder()
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('sulu_headless');
$rootNode = $treeBuilder->getRootNode();
Expand Down
20 changes: 14 additions & 6 deletions Tests/Functional/Controller/NavigationControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,45 +112,52 @@ protected function setUp(): void
*/
public function provideAttributes(): \Generator
{
$path = '';
/* Todo Can be removed after ending support of sulu 2.5 */
if (\version_compare(\Composer\InstalledVersions::getVersion('sulu/sulu') ?? '999.999.999', '2.6.0', '<')
) {
$path = '/legacy/';
}

yield [
[],
'navigation__get.json',
$path . 'navigation__get.json',
];

yield [
[
'context' => 'footer',
],
'navigation__get_context_footer.json',
$path . 'navigation__get_context_footer.json',
];

yield [
[
'depth' => 2,
],
'navigation__get_depth_2.json',
$path . 'navigation__get_depth_2.json',
];

yield [
[
'depth' => 2,
'flat' => 'true',
],
'navigation__get_depth_2_flat.json',
$path . 'navigation__get_depth_2_flat.json',
];

yield [
[
'excerpt' => 'true',
],
'navigation__get_excerpt.json',
$path . 'navigation__get_excerpt.json',
];

yield [
[
'uuid' => true,
],
'navigation__get_uuid.json',
$path . 'navigation__get_uuid.json',
];
}

Expand All @@ -173,6 +180,7 @@ public function testGetAction(array $filters, string $expectedPatternFile): void
$this->websiteClient->request('GET', '/api/navigations/' . $context . '?' . \http_build_query($filters));

$response = $this->websiteClient->getResponse();

$this->assertInstanceOf(Response::class, $response);

$this->assertStringContainsString('public', (string) $response->headers->get('Cache-Control'));
Expand Down
56 changes: 56 additions & 0 deletions Tests/Functional/Controller/responses/legacy/navigation__get.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"_embedded": {
"items": [
{
"id": "@uuid@",
"uuid": "@uuid@",
"nodeType": 1,
"publishedState": true,
"published": "@[email protected]()",
"title": "Test 1",
"locale": "de",
"webspaceKey": "sulu_io",
"template": "default",
"parent": "@uuid@",
"url": "/test-1",
"path": "@[email protected](\"/test-1\").optional()",
"urls": {
"de": "/test-1"
},
"author": null,
"authored": "@[email protected]()",
"changer": null,
"changed": "@[email protected]()",
"creator": null,
"created": "@[email protected]()",
"order": 20,
"children": []
},
{
"id": "@uuid@",
"uuid": "@uuid@",
"nodeType": 1,
"publishedState": true,
"published": "@[email protected]()",
"title": "Test 2",
"locale": "de",
"webspaceKey": "sulu_io",
"template": "default",
"parent": "@uuid@",
"path": "@[email protected](\"/test-2\").optional()",
"url": "/test-2",
"urls": {
"de": "/test-2"
},
"author": null,
"authored": "@[email protected]()",
"changer": null,
"changed": "@[email protected]()",
"creator": null,
"created": "@[email protected]()",
"order": 30,
"children": []
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"_embedded": {
"items": [
{
"id": "@uuid@",
"uuid": "@uuid@",
"nodeType": 1,
"publishedState": true,
"published": "@[email protected]()",
"title": "Test 3",
"locale": "de",
"webspaceKey": "sulu_io",
"template": "default",
"parent": "@uuid@",
"path": "@[email protected](\"/test-3\").optional()",
"url": "/test-3",
"urls": {
"de": "/test-3"
},
"author": null,
"authored": "@[email protected]()",
"changer": null,
"changed": "@[email protected]()",
"creator": null,
"created": "@[email protected]()",
"order": 40,
"children": []
}
]
}
}
Loading

0 comments on commit b8f0b85

Please sign in to comment.