Skip to content

Commit

Permalink
Merge pull request #488 from symfony-cmf/sf7
Browse files Browse the repository at this point in the history
Sf7
  • Loading branch information
dbu authored Apr 6, 2024
2 parents e90e861 + 82fd21f commit 389449f
Show file tree
Hide file tree
Showing 18 changed files with 127 additions and 218 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/test-application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ jobs:
fail-fast: false
matrix:
include:
- php-version: '8.0'
- php-version: '8.1'
dependencies: 'lowest'
- php-version: '8.0'
symfony-version: '6.0.*'
- php-version: '8.1'
symfony-version: '6.0.*'
- php-version: '8.2'
- php-version: '8.3'
symfony-version: '7.0.*'

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

- name: Install and configure PHP
uses: shivammathur/setup-php@v2
Expand All @@ -45,7 +45,7 @@ jobs:
composer global require --no-progress --no-scripts --no-plugins symfony/flex
- name: Install dependencies with Composer
uses: ramsey/composer-install@v1
uses: ramsey/composer-install@v2
with:
dependency-versions: ${{ matrix.dependencies }}
composer-options: --prefer-dist
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Changelog
=========

3.1.0
-----

* Symfony 7 support
* Doctrine ORM 3 support
If you use the ORM route entity, you need to migrate your database configuration as the array fields needed to be changed to the `json` type (because `array` has been removed)

3.0.2
-----

Expand Down
40 changes: 20 additions & 20 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,28 @@
}
],
"require": {
"php": "^8.0",
"symfony-cmf/routing": "^3.0",
"symfony/framework-bundle": "^6.0"
"php": "^8.1",
"symfony-cmf/routing": "^3.0.3",
"symfony/framework-bundle": "^6.4 || ^7.0"
},
"require-dev": {
"jackalope/jackalope-doctrine-dbal": "^1.3",
"doctrine/phpcr-odm": "^1.4|^2.0",
"symfony/phpunit-bridge": "^6.0",
"matthiasnoback/symfony-dependency-injection-test": "^4.1.0",
"matthiasnoback/symfony-config-test": "^4.1.0",
"doctrine/orm": "^2.9",
"symfony-cmf/testing": "dev-master as 4.2.0",
"doctrine/data-fixtures": "^1.0.0",
"symfony/form": "^6.0",
"symfony/translation": "^6.0",
"symfony/validator": "^6.0",
"symfony/security-bundle": "^6.0",
"doctrine/doctrine-bundle": "^2.0",
"symfony/twig-bundle": "^6.0",
"doctrine/doctrine-bundle": "^2.8",
"doctrine/orm": "^2.9 || ^3.0",
"doctrine/phpcr-bundle": "^3.0",
"doctrine/phpcr-odm": "^2.0",
"jackalope/jackalope-doctrine-dbal": "^2.0",
"matthiasnoback/symfony-dependency-injection-test": "^4.1.0 || ^5.1.0",
"matthiasnoback/symfony-config-test": "^4.1.0 || ^5.1.0",
"symfony/phpunit-bridge": "^7.0.3",
"symfony/form": "^6.4 || ^7.0",
"symfony/monolog-bundle": "^3.5",
"doctrine/phpcr-bundle": "^2.3",
"symfony/serializer": "^6.0",
"symfony/security-bundle": "^6.4 || ^7.0",
"symfony/serializer": "^6.4 || ^7.0",
"symfony/translation": "^6.4 || ^7.0",
"symfony/validator": "^6.4 || ^7.0",
"symfony/twig-bundle": "^6.4 || ^7.0",
"symfony-cmf/testing": "dev-fix-test-kernel as 5.0.2",
"twig/twig": "^2.4.4 || ^3.0"
},
"suggest": {
Expand All @@ -45,10 +45,10 @@
"doctrine/orm": "To enable support for the ORM entities (^2.5)"
},
"conflict": {
"doctrine/phpcr-odm": "<1.4",
"doctrine/common": "<3.1.1",
"doctrine/persistence": "<1.3.0",
"phpunit/phpunit": "<6"
"symfony/doctrine-bridge": "<6.4.0",
"symfony/security-core": "<6.4.0"
},
"autoload": {
"psr-4": {
Expand Down
23 changes: 10 additions & 13 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,36 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- http://www.phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit
colors="true"
bootstrap="vendor/symfony-cmf/testing/bootstrap/bootstrap.php"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
>

<testsuites>
<testsuite name="unit tests">
<directory>./tests/Unit</directory>
</testsuite>

<testsuite name="functional tests with phpcr">
<directory>./tests/Functional</directory>
<exclude>./tests/Functional/Doctrine/Orm</exclude>
</testsuite>

<testsuite name="functional tests with orm">
<directory>./tests/Functional/Doctrine/Orm</directory>
</testsuite>
</testsuites>

<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<coverage includeUncoveredFiles="true">
<include>
<directory>src/</directory>
<exclude>
<directory>Resources/</directory>
</exclude>
</whitelist>
</filter>
</include>
<exclude>
<directory>src/Resources/</directory>
</exclude>
</coverage>

<php>
<env name="KERNEL_CLASS" value="\Symfony\Cmf\Bundle\RoutingBundle\Tests\Fixtures\App\Kernel" />
<env name="KERNEL_CLASS" value="\Symfony\Cmf\Bundle\RoutingBundle\Tests\Fixtures\App\Kernel"/>
</php>
</phpunit>
9 changes: 2 additions & 7 deletions src/Doctrine/Orm/RedirectRoute.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,11 @@
* {@inheritdoc}
*
* Provides a redirect route stored in the Doctrine ORM and used as content for generic route to provide redirects
*
* @property int $id
*/
class RedirectRoute extends RedirectRouteModel
{
/**
* Unique id of this route.
*
* @var int
*/
protected $id;

protected string $serialisedParameters;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

<mapped-superclass name="Symfony\Component\Routing\Route">
<field name="host" type="string"/>
<field name="schemes" type="array"/>
<field name="methods" type="array"/>
<field name="defaults" type="array"/>
<field name="requirements" type="array"/>
<field name="options" type="array"/>
<field name="schemes" type="json"/>
<field name="methods" type="json"/>
<field name="defaults" type="json"/>
<field name="requirements" type="json"/>
<field name="options" type="json"/>
<field name="condition" column="`condition`" type="string"/>
</mapped-superclass>

Expand Down
22 changes: 6 additions & 16 deletions tests/Fixtures/App/Document/Content.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,21 @@

namespace Symfony\Cmf\Bundle\RoutingBundle\Tests\Fixtures\App\Document;

use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM;
use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCRODM;

/**
* @PHPCRODM\Document(referenceable=true)
*/
#[PHPCRODM\Document(referenceable: true)]
class Content
{
/**
* @PHPCRODM\Id
*/
#[PHPCRODM\Id()]
private $id;

/**
* @PHPCRODM\ParentDocument
*/
#[PHPCRODM\ParentDocument]
private $parent;

/**
* @PHPCRODM\NodeName
*/
#[PHPCRODM\NodeName]
private $name;

/**
* @PHPCRODM\Field(type="string")
*/
#[PHPCRODM\Field(type: 'string')]
private $title;

public function setId($id)
Expand Down
4 changes: 2 additions & 2 deletions tests/Fixtures/App/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

class Kernel extends TestKernel
{
public function configure()
public function configure(): void
{
$this->requireBundleSet('default');

Expand All @@ -39,7 +39,7 @@ public function configure()
}
}

public function registerContainerConfiguration(LoaderInterface $loader)
public function registerContainerConfiguration(LoaderInterface $loader): void
{
$loader->load(__DIR__.'/config/config_'.$this->environment.'.php');
}
Expand Down
4 changes: 1 addition & 3 deletions tests/Fixtures/App/config/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
framework:
serializer:
enable_annotations: false
serializer: ~
property_access: ~
annotations: ~
9 changes: 2 additions & 7 deletions tests/Functional/Doctrine/Orm/RedirectRouteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,21 @@
use Symfony\Cmf\Bundle\RoutingBundle\Controller\RedirectController;
use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Orm\RedirectRoute;
use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Orm\Route;
use Symfony\Component\HttpFoundation\RedirectResponse;

class RedirectRouteTest extends OrmTestCase
{
private $repository;

private $controller;
private RedirectController $controller;

public function setUp(): void
{
parent::setUp();
$this->clearDb(Route::class);
$this->clearDb(RedirectRoute::class);

$this->repository = $this->getContainer()->get('cmf_routing.route_provider');
$this->controller = new RedirectController($this->getContainer()->get('router'));
}

public function testRedirectDoctrine()
public function testRedirectDoctrine(): void
{
$route = $this->createRoute('route1', '/test');

Expand All @@ -52,7 +48,6 @@ public function testRedirectDoctrine()

$response = $this->controller->redirectAction($redirectRoute->getContent());

$this->assertInstanceOf(RedirectResponse::class, $response);
$this->assertSame(301, $response->getStatusCode());
$this->assertSame('http://localhost/test', $response->getTargetUrl());
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/Doctrine/Phpcr/RouteProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function testGetRouteCollectionForRequestFormat()
*/
public function testGetRouteCollectionForRequestNonPhpcrUrl()
{
$routes = $this->repository->getRouteCollectionForRequest(Request::create('http:///'));
$routes = $this->repository->getRouteCollectionForRequest(Request::create('http://localhost/'));
$this->assertInstanceOf(RouteCollection::class, $routes);
$this->assertCount(1, $routes);

Expand Down
25 changes: 2 additions & 23 deletions tests/Unit/Doctrine/Orm/RouteProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,38 +201,17 @@ public function testGetRoutesByNames(): void
];

$this->objectRepositoryMock
->expects($this->at(0))
->method('findOneBy')
->with(['name' => $paths[0]])
->willReturn($this->routeMock)
;
$this->objectRepositoryMock
->expects($this->at(1))
->method('findOneBy')
->with(['name' => $paths[1]])
->willReturn($this->routeMock)
;

$paths[] = '/no-candidate';

$candidatesMock = $this->createMock(CandidatesInterface::class);
$candidatesMock
->expects($this->at(0))
->method('isCandidate')
->with($paths[0])
->willReturn(true)
;
$candidatesMock
->expects($this->at(1))
->method('isCandidate')
->with($paths[1])
->willReturn(true)
;
$candidatesMock
->expects($this->at(2))
->method('isCandidate')
->with($paths[2])
->willReturn(false)
->withConsecutive([$paths[0]], [$paths[1]], [$paths[2]])
->willReturnOnConsecutiveCalls(true, true, false)
;

$routeProvider = new RouteProvider($this->managerRegistryMock, $candidatesMock, 'Route');
Expand Down
Loading

0 comments on commit 389449f

Please sign in to comment.