Skip to content

Commit

Permalink
use dummy persistence instead of mocking dbal connection
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubkulhan committed May 24, 2024
1 parent a667bdb commit c58932a
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 4 deletions.
8 changes: 4 additions & 4 deletions data-access-kit-symfony/test/DataAccessKitBundleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

namespace DataAccessKit\Symfony;

use DataAccessKit\Persistence;
use DataAccessKit\Symfony\Fixture\DummyPersistence;
use DataAccessKit\Symfony\Fixture\FooRepository;
use DataAccessKit\Symfony\Fixture\FooRepositoryInterface;
use DataAccessKit\Symfony\Fixture\FooService;
use Doctrine\DBAL\Connection;
use PHPUnit\Framework\TestCase;
use ReflectionClass;
use Symfony\Component\Config\Loader\LoaderInterface;
Expand Down Expand Up @@ -51,9 +52,8 @@ public function registerBundles(): iterable
public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load(function (ContainerBuilder $container) {
$connDef = new Definition(Connection::class);
$connDef->setAutowired(false);
$container->setDefinition(Connection::class, $connDef);
$persistenceDef = new Definition(DummyPersistence::class);
$container->setDefinition(Persistence::class, $persistenceDef);

$svcDef = new Definition(FooService::class);
$svcDef->setAutowired(true);
Expand Down
59 changes: 59 additions & 0 deletions data-access-kit-symfony/test/Fixture/DummyPersistence.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php declare(strict_types=1);

namespace DataAccessKit\Symfony\Fixture;

use DataAccessKit\PersistenceInterface;
use LogicException;

class DummyPersistence implements PersistenceInterface
{
public function query(string $className, string $sql, array $parameters = [], array $parameterTypes = []): iterable
{
throw new LogicException("Not implemented");
}

public function select(string $className, string $alias = "t", ?callable $callback = null): iterable
{
throw new LogicException("Not implemented");
}

public function insert(object $object): void
{
throw new LogicException("Not implemented");
}

public function insertAll(array $objects): void
{
throw new LogicException("Not implemented");
}

public function upsert(object $object, ?array $columns = null): void
{
throw new LogicException("Not implemented");
}

public function upsertAll(array $objects, ?array $columns = null): void
{
throw new LogicException("Not implemented");
}

public function update(object $object, ?array $columns = null): void
{
throw new LogicException("Not implemented");
}

public function delete(object $object): void
{
throw new LogicException("Not implemented");
}

public function deleteAll(array $objects): void
{
throw new LogicException("Not implemented");
}

public function transactional(callable $callback): mixed
{
throw new LogicException("Not implemented");
}
}

0 comments on commit c58932a

Please sign in to comment.