Skip to content

Commit

Permalink
feat: Add support for Doctrine3 (#67)
Browse files Browse the repository at this point in the history
Closes #63.

---------

Co-authored-by: Nicolas Olive <nicolas@gap-referencement.com>
  • Loading branch information
theofidry and nikow13 authored Mar 8, 2024
1 parent aab39b3 commit 9b64895
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 58 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
matrix:
php:
- '8.2'
dependencies: ['highest']
dependencies: ['highest', 'lowest']
symfony:
- 'unchanged'
- '6.4.*'
Expand Down
16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@

"require": {
"php": "^8.2",
"doctrine/doctrine-bundle": "^2.5",
"doctrine/data-fixtures": "^1.5",
"doctrine/orm": "^2.10.0",
"doctrine/persistence": "^2.2 || ^3.0",
"doctrine/doctrine-bundle": "^2.11.3",
"doctrine/data-fixtures": "^1.7",
"doctrine/orm": "^3.1",
"doctrine/persistence": "^3.3.1",
"psr/log": "^1.0 || ^2.0 || ^3.0",
"symfony/finder": "^6.4 || ^7.0",
"symfony/framework-bundle": "^6.4 || ^7.0",
"theofidry/alice-data-fixtures": "^1.5"
"theofidry/alice-data-fixtures": "^1.7"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"phpspec/prophecy": "^1.7",
"symfony/phpunit-bridge": "^6.4 || ^7.0",
"phpunit/phpunit": "^9.6.17",
"phpspec/prophecy": "^1.14.0",
"symfony/phpunit-bridge": "^6.4.4 || ^7.0",
"phpspec/prophecy-phpunit": "^2.0",
"monolog/monolog": "^3.5"
},
Expand Down
21 changes: 10 additions & 11 deletions fixtures/Persistence/FakeDoctrineManagerRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
namespace Hautelook\AliceBundle\Persistence;

use Doctrine\Persistence\ManagerRegistry;
use Doctrine\Persistence\ObjectManager;
use function func_get_args;
use Hautelook\AliceBundle\NotCallableTrait;

Expand All @@ -27,52 +26,52 @@ public function getDefaultConnectionName(): string
$this->__call(__METHOD__, func_get_args());
}

public function getConnection(?string $name = null): object
public function getConnection($name = null): void
{
$this->__call(__METHOD__, func_get_args());
}

public function getConnections(): array
public function getConnections(): void
{
$this->__call(__METHOD__, func_get_args());
}

public function getConnectionNames(): array
public function getConnectionNames(): void
{
$this->__call(__METHOD__, func_get_args());
}

public function getDefaultManagerName(): string
public function getDefaultManagerName(): void
{
$this->__call(__METHOD__, func_get_args());
}

public function getManager(?string $name = null): ObjectManager
public function getManager($name = null): void
{
$this->__call(__METHOD__, func_get_args());
}

public function getManagers(): array
public function getManagers(): void
{
$this->__call(__METHOD__, func_get_args());
}

public function resetManager(?string $name = null): ObjectManager
public function resetManager($name = null): void
{
$this->__call(__METHOD__, func_get_args());
}

public function getManagerNames(): array
public function getManagerNames(): void
{
$this->__call(__METHOD__, func_get_args());
}

public function getRepository(string $persistentObject, ?string $persistentManagerName = null)
public function getRepository($persistentObject, $persistentManagerName = null): void
{
$this->__call(__METHOD__, func_get_args());
}

public function getManagerForClass(string $class): ?ObjectManager
public function getManagerForClass($class): void
{
$this->__call(__METHOD__, func_get_args());
}
Expand Down
57 changes: 20 additions & 37 deletions fixtures/Persistence/ObjectMapper/FakeEntityManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,19 @@

use Doctrine\Common\EventManager;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\LockMode;
use Doctrine\ORM\Cache;
use Doctrine\ORM\Configuration;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Internal\Hydration\AbstractHydrator;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Mapping\ClassMetadataFactory;
use Doctrine\ORM\NativeQuery;
use Doctrine\ORM\Proxy\ProxyFactory;
use Doctrine\ORM\Query;
use Doctrine\ORM\Query\Expr;
use Doctrine\ORM\Query\FilterCollection;
use Doctrine\ORM\Query\ResultSetMapping;
use Doctrine\ORM\QueryBuilder;
use Doctrine\ORM\UnitOfWork;
use Doctrine\Persistence\ObjectRepository;
use function func_get_args;
use Hautelook\AliceBundle\NotCallableTrait;

Expand Down Expand Up @@ -57,7 +55,7 @@ public function beginTransaction(): void
$this->__call(__METHOD__, func_get_args());
}

public function transactional($func): mixed
public function wrapInTransaction($func): mixed
{
$this->__call(__METHOD__, func_get_args());
}
Expand All @@ -77,21 +75,11 @@ public function createQuery($dql = ''): Query
$this->__call(__METHOD__, func_get_args());
}

public function createNamedQuery($name): Query
{
$this->__call(__METHOD__, func_get_args());
}

public function createNativeQuery($sql, ResultSetMapping $rsm): NativeQuery
{
$this->__call(__METHOD__, func_get_args());
}

public function createNamedNativeQuery($name): NativeQuery
{
$this->__call(__METHOD__, func_get_args());
}

public function createQueryBuilder(): QueryBuilder
{
$this->__call(__METHOD__, func_get_args());
Expand All @@ -102,17 +90,12 @@ public function getReference($entityName, $id): ?object
$this->__call(__METHOD__, func_get_args());
}

public function getPartialReference($entityName, $identifier): ?object
{
$this->__call(__METHOD__, func_get_args());
}

public function close(): void
{
$this->__call(__METHOD__, func_get_args());
}

public function copy($entity, $deep = false): object
public function copy($entity, $deep = false): void
{
$this->__call(__METHOD__, func_get_args());
}
Expand All @@ -127,7 +110,7 @@ public function getEventManager(): EventManager
$this->__call(__METHOD__, func_get_args());
}

public function getConfiguration(): Configuration
public function getConfiguration(): \Doctrine\ORM\Configuration
{
$this->__call(__METHOD__, func_get_args());
}
Expand All @@ -137,12 +120,7 @@ public function isOpen(): bool
$this->__call(__METHOD__, func_get_args());
}

public function getUnitOfWork(): UnitOfWork
{
$this->__call(__METHOD__, func_get_args());
}

public function getHydrator($hydrationMode): AbstractHydrator
public function getUnitOfWork(): \Doctrine\ORM\UnitOfWork
{
$this->__call(__METHOD__, func_get_args());
}
Expand All @@ -157,7 +135,7 @@ public function getProxyFactory(): ProxyFactory
$this->__call(__METHOD__, func_get_args());
}

public function getFilters(): FilterCollection
public function getFilters(): Query\FilterCollection
{
$this->__call(__METHOD__, func_get_args());
}
Expand All @@ -172,17 +150,22 @@ public function hasFilters(): bool
$this->__call(__METHOD__, func_get_args());
}

public function find(string $className, $id): ?object
public function find($className, $id, LockMode|int|null $lockMode = null, int|null $lockVersion = null): ?object
{
$this->__call(__METHOD__, func_get_args());
}

public function persist($object): void
{
$this->__call(__METHOD__, func_get_args());
}

public function persist(object $object): void
public function remove($object): void
{
$this->__call(__METHOD__, func_get_args());
}

public function remove(object $object): void
public function merge($object): void
{
$this->__call(__METHOD__, func_get_args());
}
Expand All @@ -192,12 +175,12 @@ public function clear($objectName = null): void
$this->__call(__METHOD__, func_get_args());
}

public function detach(object $object): void
public function detach($object): void
{
$this->__call(__METHOD__, func_get_args());
}

public function refresh(object $object): void
public function refresh($object, LockMode|int|null $lockMode = null): void
{
$this->__call(__METHOD__, func_get_args());
}
Expand All @@ -212,17 +195,17 @@ public function getRepository($className): EntityRepository
$this->__call(__METHOD__, func_get_args());
}

public function getMetadataFactory(): ObjectRepository
public function getMetadataFactory(): ClassMetadataFactory
{
$this->__call(__METHOD__, func_get_args());
}

public function initializeObject(object $obj): void
public function initializeObject($obj): void
{
$this->__call(__METHOD__, func_get_args());
}

public function contains(object $object): bool
public function contains($object): void
{
$this->__call(__METHOD__, func_get_args());
}
Expand Down
1 change: 0 additions & 1 deletion src/PhpUnit/RefreshDatabaseTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ protected static function bootKernel(array $options = []): KernelInterface
->get('doctrine')
->getConnection(FixtureStore::getConnectionName());

$connection->setNestTransactionsWithSavepoints(true);
$connection->beginTransaction();

return $kernel;
Expand Down

0 comments on commit 9b64895

Please sign in to comment.