Skip to content

Commit

Permalink
Add Symfony 6.x support (#15)
Browse files Browse the repository at this point in the history
* Add support for Symfony 6.3

* Revert backward compatibility

* SUPPORT-85540 - add symfony 6 support

* SUPPORT-85540 - fixed PR comments

* SUPPORT-85540 - fixed PR comments

* Update phpunit.xml.dist

Co-authored-by: Boril Yordanov <[email protected]>

* Update phpunit.xml.dist

Co-authored-by: Boril Yordanov <[email protected]>

---------

Co-authored-by: Nikolay Haralambiev <[email protected]>
Co-authored-by: Yuri Gaidoba <[email protected]>
Co-authored-by: Boril Yordanov <[email protected]>
  • Loading branch information
4 people authored Nov 27, 2023
1 parent f6f6b0b commit cdae2cf
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 37 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ build/
phpunit.xml
composer.lock
bin/

.phpunit.result.cache
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 1.4.0
### Added
- Added support for `Symfony 6.x`

### Changed
- Bumped `PHP` to `^7.1`
- Bumped `doctrine/orm` to `^2.5`

### Removed
- Removed support for `Symfony 2`

## 1.3.0
### Added
- Support for PHP 8.
Expand Down
10 changes: 6 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@
}
},
"require": {
"php": ">=7.0|>=8.0",
"doctrine/orm": "^2.0",
"php": "^7.1|^8.0",
"doctrine/orm": "^2.5",
"psr/log": "^1.0|^2.0",
"symfony/property-access": "^2.8|^3.0|^4.0|^5.0",
"symfony/property-access": "^3.0|^4.0|^5.0|^6.0",
"ext-json": "*"
},
"require-dev": {
"phpunit/phpunit": "^6.0|^9.0"
"doctrine/annotations": "^1.0 || ^2.0",
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.5",
"symfony/cache": "^3.0|^4.0|^5.0|^6.0"
},
"config": {
"bin-dir": "bin"
Expand Down
27 changes: 9 additions & 18 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- http://www.phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit
backupGlobals = "false"
backupStaticAttributes = "false"
colors = "true"
convertErrorsToExceptions = "true"
convertNoticesToExceptions = "true"
convertWarningsToExceptions = "true"
processIsolation = "false"
stopOnFailure = "false"
syntaxCheck = "false"
bootstrap = "vendor/autoload.php" >
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
bootstrap="vendor/autoload.php">

<coverage>
<include>
<directory>./src</directory>
</include>
</coverage>

<testsuites>
<testsuite name="Project Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>./src</directory>
</whitelist>
</filter>
</phpunit>
12 changes: 5 additions & 7 deletions tests/Functional/Service/Doctrine/DoctrineTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
namespace Paysera\Pagination\Tests\Functional\Service\Doctrine;

use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\AnnotationRegistry;
use Doctrine\Common\Cache\ArrayCache;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Mapping\Driver\AnnotationDriver;
use Doctrine\ORM\Tools\SchemaTool;
Expand All @@ -14,10 +12,11 @@
use Paysera\Pagination\Tests\Functional\Fixtures\ParentTestEntity;
use PHPUnit\Framework\TestCase;
use Doctrine\ORM\Configuration;
use Symfony\Component\Cache\Adapter\ArrayAdapter;

abstract class DoctrineTestCase extends TestCase
{
protected function createTestEntityManager()
protected function createTestEntityManager(): EntityManager
{
if (!extension_loaded('pdo_sqlite')) {
$this->markTestSkipped('Extension pdo_sqlite is required.');
Expand All @@ -40,17 +39,16 @@ protected function createTestEntityManager()
return $entityManager;
}

protected function createTestConfiguration()
protected function createTestConfiguration(): Configuration
{
$config = new Configuration();
$config->setEntityNamespaces(['PaginationTest' => 'Paysera\Pagination\Tests\Functional\Fixtures']);
$config->setAutoGenerateProxyClasses(true);
$config->setProxyDir(sys_get_temp_dir());
$config->setProxyNamespace('PaginationTest\Doctrine');
$config->setMetadataDriverImpl(new AnnotationDriver(new AnnotationReader()));
$config->setQueryCacheImpl(new ArrayCache());
$config->setMetadataCacheImpl(new ArrayCache());
AnnotationRegistry::registerLoader('class_exists');
$config->setQueryCache(new ArrayAdapter());
$config->setMetadataCache(new ArrayAdapter());

return $config;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/Service/Doctrine/ResultIteratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ResultIteratorTest extends DoctrineTestCase
*/
private $logger;

protected function setUp()
protected function setUp(): void
{
parent::setUp();

Expand Down
17 changes: 12 additions & 5 deletions tests/Functional/Service/Doctrine/ResultProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@
namespace Paysera\Pagination\Tests\Functional\Service\Doctrine;

use DateTime;
use Doctrine\DBAL\Exception;
use Doctrine\ORM\Exception\MissingMappingDriverImplementation;
use Doctrine\ORM\Exception\ORMException;
use Doctrine\ORM\OptimisticLockException;
use Doctrine\ORM\QueryBuilder;
use Doctrine\ORM\Tools\ToolsException;
use Doctrine\Persistence\Mapping\MappingException;
use Paysera\Pagination\Entity\OrderingConfiguration;
use Doctrine\ORM\EntityManager;
use Paysera\Pagination\Exception\InvalidGroupByException;
Expand All @@ -20,6 +26,7 @@
use Paysera\Pagination\Tests\Functional\Fixtures\ChildTestEntity;
use Paysera\Pagination\Tests\Functional\Fixtures\DateTimeEntity;
use Paysera\Pagination\Tests\Functional\Fixtures\ParentTestEntity;
use ReflectionException;
use Symfony\Component\PropertyAccess\PropertyAccess;

class ResultProviderTest extends DoctrineTestCase
Expand All @@ -29,7 +36,7 @@ class ResultProviderTest extends DoctrineTestCase
*/
private $resultProvider;

protected function setUp()
protected function setUp(): void
{
parent::setUp();

Expand Down Expand Up @@ -146,7 +153,7 @@ public function testGetResultForQuery(Result $expectedResult, Pager $pager, $tot
$this->assertEquals($expectedResult, $result);
}

public function getResultProvider()
public function getResultProvider(): array
{
return [
'default' => [
Expand Down Expand Up @@ -403,7 +410,7 @@ private function createHierarchicalData(EntityManager $entityManager)
$entityManager->flush();
}

public function getResultProviderForSeveralLevelOrdering()
public function getResultProviderForSeveralLevelOrdering(): array
{
return [
'name asc, parent_name asc, id asc' => [
Expand Down Expand Up @@ -559,7 +566,7 @@ private function createDateTimeRelatedData(EntityManager $entityManager)
$entityManager->flush();
}

public function getResultProviderForDateTimeField()
public function getResultProviderForDateTimeField(): array
{
return [
'first page' => [
Expand Down Expand Up @@ -748,7 +755,7 @@ public function testGetTotalCountForQueryGetsCorrectCountWhenNoNullsAreInResult(
$this->assertSame(30, $this->resultProvider->getTotalCountForQuery($configuredQuery));
}

public function getResultProviderForGetTotalCountForQuery()
public function getResultProviderForGetTotalCountForQuery(): array
{
$entityManager = $this->createTestEntityManager();
$this->createTestData($entityManager);
Expand Down
5 changes: 3 additions & 2 deletions tests/Unit/Service/Doctrine/QueryAnalyserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Query\Expr\Andx;
use Doctrine\ORM\QueryBuilder;
use InvalidArgumentException;
use Paysera\Pagination\Entity\Doctrine\ConfiguredQuery;
use Paysera\Pagination\Entity\Pager;
use Paysera\Pagination\Service\Doctrine\QueryAnalyser;
Expand All @@ -15,11 +16,11 @@ class QueryAnalyserTest extends TestCase
{
/**
* @dataProvider providerForInvalidData
* @expectedException \InvalidArgumentException
* @param QueryBuilder $queryBuilder
*/
public function testAnalyseQueryWithInvalidData(QueryBuilder $queryBuilder)
{
$this->expectException(InvalidArgumentException::class);
$analyser = new QueryAnalyser();

$configuredQuery = new ConfiguredQuery($queryBuilder);
Expand All @@ -28,7 +29,7 @@ public function testAnalyseQueryWithInvalidData(QueryBuilder $queryBuilder)
$analyser->analyseQuery($configuredQuery, $pager);
}

public function providerForInvalidData()
public function providerForInvalidData(): array
{
return [
'Without select part' => [
Expand Down

0 comments on commit cdae2cf

Please sign in to comment.