Skip to content

rename internal repository to StatementStorage #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ CHANGELOG
0.4.0
-----

* renamed the `StatementRepository` interface to `StatementStorage` and moved
it to the `XApi\Repository\Doctrine\Storage` namespace
* made the package compatible with `3.x` releases of `ramsey/uuid`
* allow `2.x` releases of the `php-xapi/model` package too

Expand Down
4 changes: 2 additions & 2 deletions src/Repository/StatementRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use Xabbuh\XApi\Model\Uuid as ModelUuid;
use XApi\Repository\Api\StatementRepositoryInterface;
use XApi\Repository\Doctrine\Mapping\Statement as MappedStatement;
use XApi\Repository\Doctrine\Repository\Mapping\StatementRepository as MappedStatementRepository;
use XApi\Repository\Doctrine\Storage\StatementStorage;

/**
* Doctrine based {@link Statement} repository.
Expand All @@ -31,7 +31,7 @@ final class StatementRepository implements StatementRepositoryInterface
{
private $repository;

public function __construct(MappedStatementRepository $repository)
public function __construct(StatementStorage $repository)
{
$this->repository = $repository;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace XApi\Repository\Doctrine\Repository\Mapping;
namespace XApi\Repository\Doctrine\Storage;

use XApi\Repository\Doctrine\Mapping\Statement;

Expand All @@ -18,7 +18,7 @@
*
* @author Christian Flothmann <[email protected]>
*/
interface StatementRepository
interface StatementStorage
{
/**
* @param array $criteria
Expand Down
14 changes: 7 additions & 7 deletions src/Test/Functional/StatementRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

use Doctrine\Common\Persistence\ObjectManager;
use XApi\Repository\Api\Test\Functional\StatementRepositoryTest as BaseStatementRepositoryTest;
use XApi\Repository\Doctrine\Repository\Mapping\StatementRepository as MappedStatementRepository;
use XApi\Repository\Doctrine\Repository\StatementRepository;
use XApi\Repository\Doctrine\Storage\StatementStorage;
use XApi\Repository\Doctrine\Test\StatementRepository as FreshStatementRepository;

/**
Expand All @@ -28,26 +28,26 @@ abstract class StatementRepositoryTest extends BaseStatementRepositoryTest
protected $objectManager;

/**
* @var MappedStatementRepository
* @var StatementStorage
*/
protected $repository;
protected $storage;

protected function setUp()
{
$this->objectManager = $this->createObjectManager();
$this->repository = $this->createRepository();
$this->storage = $this->createStorage();

parent::setUp();
}

protected function createStatementRepository()
{
return new FreshStatementRepository(new StatementRepository($this->repository), $this->objectManager);
return new FreshStatementRepository(new StatementRepository($this->storage), $this->objectManager);
}

protected function cleanDatabase()
{
foreach ($this->repository->findStatements(array()) as $statement) {
foreach ($this->storage->findStatements(array()) as $statement) {
$this->objectManager->remove($statement);
}

Expand All @@ -64,7 +64,7 @@ abstract protected function createObjectManager();
*/
abstract protected function getStatementClassName();

private function createRepository()
private function createStorage()
{
return $this->objectManager->getRepository($this->getStatementClassName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
* file that was distributed with this source code.
*/

namespace XApi\Repository\Doctrine\Test\Unit\Repository\Mapping;
namespace XApi\Repository\Doctrine\Test\Unit\Storage;

use PHPUnit\Framework\TestCase;
use Xabbuh\XApi\DataFixtures\StatementFixtures;
use XApi\Repository\Doctrine\Mapping\Statement;
use XApi\Repository\Doctrine\Repository\Mapping\StatementRepository;
use XApi\Repository\Doctrine\Storage\StatementStorage;

/**
* @author Christian Flothmann <[email protected]>
*/
abstract class StatementRepositoryTest extends TestCase
abstract class StatementStorageTest extends TestCase
{
/**
* @var \PHPUnit_Framework_MockObject_MockObject
Expand All @@ -37,16 +37,16 @@ abstract class StatementRepositoryTest extends TestCase
private $classMetadata;

/**
* @var StatementRepository
* @var StatementStorage
*/
private $repository;
private $storage;

protected function setUp()
{
$this->objectManager = $this->createObjectManagerMock();
$this->unitOfWork = $this->createUnitOfWorkMock();
$this->classMetadata = $this->createClassMetadataMock();
$this->repository = $this->createMappedStatementRepository($this->objectManager, $this->unitOfWork, $this->classMetadata);
$this->storage = $this->createStatementStorage($this->objectManager, $this->unitOfWork, $this->classMetadata);
}

public function testStatementDocumentIsPersisted()
Expand All @@ -59,7 +59,7 @@ public function testStatementDocumentIsPersisted()
;

$mappedStatement = Statement::fromModel(StatementFixtures::getMinimalStatement());
$this->repository->storeStatement($mappedStatement, true);
$this->storage->storeStatement($mappedStatement, true);
}

public function testFlushIsCalledByDefault()
Expand All @@ -71,7 +71,7 @@ public function testFlushIsCalledByDefault()
;

$mappedStatement = Statement::fromModel(StatementFixtures::getMinimalStatement());
$this->repository->storeStatement($mappedStatement);
$this->storage->storeStatement($mappedStatement);
}

public function testCallToFlushCanBeSuppressed()
Expand All @@ -83,7 +83,7 @@ public function testCallToFlushCanBeSuppressed()
;

$mappedStatement = Statement::fromModel(StatementFixtures::getMinimalStatement());
$this->repository->storeStatement($mappedStatement, false);
$this->storage->storeStatement($mappedStatement, false);
}

abstract protected function getObjectManagerClass();
Expand Down Expand Up @@ -116,5 +116,5 @@ protected function createClassMetadataMock()
->getMock();
}

abstract protected function createMappedStatementRepository($objectManager, $unitOfWork, $classMetadata);
abstract protected function createStatementStorage($objectManager, $unitOfWork, $classMetadata);
}
7 changes: 4 additions & 3 deletions tests/Unit/Repository/StatementRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@
use Xabbuh\XApi\Model\Uuid as ModelUuid;
use XApi\Repository\Doctrine\Mapping\Statement as MappedStatement;
use XApi\Repository\Doctrine\Repository\StatementRepository;
use XApi\Repository\Doctrine\Storage\StatementStorage;

/**
* @author Christian Flothmann <[email protected]>
*/
class StatementRepositoryTest extends TestCase
{
/**
* @var \PHPUnit_Framework_MockObject_MockObject|\XApi\Repository\Doctrine\Repository\Mapping\StatementRepository
* @var \PHPUnit_Framework_MockObject_MockObject|StatementStorage
*/
private $mappedStatementRepository;

Expand Down Expand Up @@ -119,12 +120,12 @@ public function testSaveWithoutFlush()
}

/**
* @return \PHPUnit_Framework_MockObject_MockObject|\XApi\Repository\Doctrine\Repository\Mapping\StatementRepository
* @return \PHPUnit_Framework_MockObject_MockObject|StatementStorage
*/
protected function createMappedStatementRepositoryMock()
{
return $this
->getMockBuilder('\XApi\Repository\Doctrine\Repository\Mapping\StatementRepository')
->getMockBuilder('\XApi\Repository\Doctrine\Storage\StatementStorage')
->getMock();
}
}