Skip to content

Commit

Permalink
Class constants in Base and Content tests (ezsystems#2228)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarioBlazek authored and andrerom committed Jan 29, 2018
1 parent 6b864a1 commit ec2aaaa
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 88 deletions.
28 changes: 10 additions & 18 deletions eZ/Publish/Core/Repository/Tests/Service/Mock/Base.php
Expand Up @@ -13,7 +13,12 @@
use eZ\Publish\Core\Repository\Values\Content\Content;
use eZ\Publish\Core\Repository\Values\Content\VersionInfo;
use eZ\Publish\API\Repository\Values\Content\ContentInfo;
use eZ\Publish\API\Repository\Repository as APIRepository;
use eZ\Publish\Core\Repository\Values\User\User;
use eZ\Publish\Core\Repository\FieldTypeService;
use eZ\Publish\Core\Repository\Helper\FieldTypeRegistry;
use eZ\Publish\Core\Repository\Helper\NameableFieldTypeRegistry;
use eZ\Publish\SPI\Persistence\Handler;

/**
* Base test case for tests on services using Mock testing.
Expand Down Expand Up @@ -82,10 +87,7 @@ protected function getRepository(array $serviceSettings = array())
protected function getFieldTypeServiceMock()
{
if (!isset($this->fieldTypeServiceMock)) {
$this->fieldTypeServiceMock = $this
->getMockBuilder('eZ\\Publish\\Core\\Repository\\FieldTypeService')
->disableOriginalConstructor()
->getMock();
$this->fieldTypeServiceMock = $this->createMock(FieldTypeService::class);
}

return $this->fieldTypeServiceMock;
Expand All @@ -99,10 +101,7 @@ protected function getFieldTypeServiceMock()
protected function getFieldTypeRegistryMock()
{
if (!isset($this->fieldTypeRegistryMock)) {
$this->fieldTypeRegistryMock = $this
->getMockBuilder('eZ\\Publish\\Core\\Repository\\Helper\\FieldTypeRegistry')
->disableOriginalConstructor()
->getMock();
$this->fieldTypeRegistryMock = $this->createMock(FieldTypeRegistry::class);
}

return $this->fieldTypeRegistryMock;
Expand All @@ -116,10 +115,7 @@ protected function getFieldTypeRegistryMock()
protected function getNameableFieldTypeRegistryMock()
{
if (!isset($this->nameableFieldTypeRegistryMock)) {
$this->nameableFieldTypeRegistryMock = $this
->getMockBuilder('eZ\\Publish\\Core\\Repository\\Helper\\NameableFieldTypeRegistry')
->disableOriginalConstructor()
->getMock();
$this->nameableFieldTypeRegistryMock = $this->createMock(NameableFieldTypeRegistry::class);
}

return $this->nameableFieldTypeRegistryMock;
Expand All @@ -131,7 +127,7 @@ protected function getNameableFieldTypeRegistryMock()
protected function getRepositoryMock()
{
if (!isset($this->repositoryMock)) {
$this->repositoryMock = self::createMock('eZ\\Publish\\API\\Repository\\Repository');
$this->repositoryMock = self::createMock(APIRepository::class);
}

return $this->repositoryMock;
Expand All @@ -145,16 +141,12 @@ protected function getRepositoryMock()
protected function getPersistenceMock()
{
if (!isset($this->persistenceMock)) {
$this->persistenceMock = $this->createMock('eZ\\Publish\\SPI\\Persistence\\Handler');
$this->persistenceMock = $this->createMock(Handler::class);

$this->persistenceMock->expects($this->any())
->method('contentHandler')
->will($this->returnValue($this->getPersistenceMockHandler('Content\\Handler')));

// $this->persistenceMock->expects($this->any())
// ->method('searchHandler')
// ->will($this->returnValue($this->getSPIMockHandler('Search\\Handler')));

$this->persistenceMock->expects($this->any())
->method('contentTypeHandler')
->will($this->returnValue($this->getPersistenceMockHandler('Content\\Type\\Handler')));
Expand Down

0 comments on commit ec2aaaa

Please sign in to comment.