From 91a947b17929f1cbf65f774447e22cb12f9eb959 Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Mon, 24 Sep 2018 12:53:27 +0200 Subject: [PATCH 1/3] EZP-29139: Added more info about clearing HTTP cache after running cmd (#2456) Added info to ezplatform:urls:regenerate-aliases command about a need to manually clear HTTP cache: - before the command is executed, - after the command ends. --- .../EzPublishCoreBundle/Command/RegenerateUrlAliasesCommand.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/eZ/Bundle/EzPublishCoreBundle/Command/RegenerateUrlAliasesCommand.php b/eZ/Bundle/EzPublishCoreBundle/Command/RegenerateUrlAliasesCommand.php index 66f140d7ba0..e78e4a9b694 100644 --- a/eZ/Bundle/EzPublishCoreBundle/Command/RegenerateUrlAliasesCommand.php +++ b/eZ/Bundle/EzPublishCoreBundle/Command/RegenerateUrlAliasesCommand.php @@ -33,6 +33,7 @@ class RegenerateUrlAliasesCommand extends Command - Take installation offline, during the script execution the database should not be modified. - Run this command without memory limit, i.e. processing of 300k Locations can take up to 1 GB of RAM. - Run this command in production environment using --env=prod +- Manually clear HTTP cache after running this command. EOT; /** @@ -148,6 +149,7 @@ function (Repository $repository) use ($offset, $iterationCount) { $progressBar->finish(); $output->writeln(''); $output->writeln('Done.'); + $output->writeln('Make sure to clear HTTP cache afterwards.'); } /** From b4417cd16179f85f9a7c8f80713e8244dc12126e Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Mon, 24 Sep 2018 16:06:47 +0200 Subject: [PATCH 2/3] Improved code related to EZP-29139 (#2454) * Improved Query selection logic in Content Gateway * [SPI] Improved list of thrown exceptions in PhpDocs of URLAlias Handler --- .../Content/Gateway/DoctrineDatabase.php | 56 +++++++++++-------- .../Legacy/Content/UrlAlias/Handler.php | 10 +++- .../Persistence/Content/UrlAlias/Handler.php | 10 +++- 3 files changed, 47 insertions(+), 29 deletions(-) diff --git a/eZ/Publish/Core/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php b/eZ/Publish/Core/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php index 341c6af2472..e6d5e3d15c6 100644 --- a/eZ/Publish/Core/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php +++ b/eZ/Publish/Core/Persistence/Legacy/Content/Gateway/DoctrineDatabase.php @@ -9,7 +9,6 @@ namespace eZ\Publish\Core\Persistence\Legacy\Content\Gateway; use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Query\QueryBuilder as DoctrineQueryBuilder; use eZ\Publish\Core\Persistence\Legacy\Content\Gateway; use eZ\Publish\Core\Persistence\Legacy\Content\Gateway\DoctrineDatabase\QueryBuilder; use eZ\Publish\Core\Persistence\Database\DatabaseHandler; @@ -954,25 +953,30 @@ private function internalLoadContent(array $contentIds, $version = null, array $ } /** - * @see loadContentInfo(), loadContentInfoByRemoteId(), loadContentInfoList(), loadContentInfoByLocationId() + * Get query builder to load Content Info data. * - * @param \Doctrine\DBAL\Query\QueryBuilder $query + * @see loadContentInfo(), loadContentInfoByRemoteId(), loadContentInfoList(), loadContentInfoByLocationId() * - * @return array + * @return \Doctrine\DBAL\Query\QueryBuilder */ - private function internalLoadContentInfo(DoctrineQueryBuilder $query) + private function createLoadContentInfoQueryBuilder() { - $query + $queryBuilder = $this->connection->createQueryBuilder(); + $expr = $queryBuilder->expr(); + $queryBuilder ->select('c.*', 't.main_node_id AS ezcontentobject_tree_main_node_id') ->from('ezcontentobject', 'c') ->leftJoin( 'c', 'ezcontentobject_tree', 't', - 'c.id = t.contentobject_id AND t.node_id = t.main_node_id' + $expr->andX( + $expr->eq('c.id', 't.contentobject_id'), + $expr->eq('t.node_id', 't.main_node_id') + ) ); - return $query->execute()->fetchAll(); + return $queryBuilder; } /** @@ -989,11 +993,12 @@ private function internalLoadContentInfo(DoctrineQueryBuilder $query) */ public function loadContentInfo($contentId) { - $query = $this->connection->createQueryBuilder(); - $query->where('c.id = :id') - ->setParameter('id', $contentId, PDO::PARAM_INT); + $queryBuilder = $this->createLoadContentInfoQueryBuilder(); + $queryBuilder + ->where('c.id = :id') + ->setParameter('id', $contentId, PDO::PARAM_INT); - $results = $this->internalLoadContentInfo($query); + $results = $queryBuilder->execute()->fetchAll(PDO::FETCH_ASSOC); if (empty($results)) { throw new NotFound('content', "id: $contentId"); } @@ -1003,11 +1008,12 @@ public function loadContentInfo($contentId) public function loadContentInfoList(array $contentIds) { - $query = $this->connection->createQueryBuilder(); - $query->where('c.id IN (:ids)') - ->setParameter('ids', $contentIds, Connection::PARAM_INT_ARRAY); + $queryBuilder = $this->createLoadContentInfoQueryBuilder(); + $queryBuilder + ->where('c.id IN (:ids)') + ->setParameter('ids', $contentIds, Connection::PARAM_INT_ARRAY); - return $this->internalLoadContentInfo($query); + return $queryBuilder->execute()->fetchAll(PDO::FETCH_ASSOC); } /** @@ -1023,11 +1029,12 @@ public function loadContentInfoList(array $contentIds) */ public function loadContentInfoByRemoteId($remoteId) { - $query = $this->connection->createQueryBuilder(); - $query->where('c.remote_id = :id') - ->setParameter('id', $remoteId, PDO::PARAM_STR); + $queryBuilder = $this->createLoadContentInfoQueryBuilder(); + $queryBuilder + ->where('c.remote_id = :id') + ->setParameter('id', $remoteId, PDO::PARAM_STR); - $results = $this->internalLoadContentInfo($query); + $results = $queryBuilder->execute()->fetchAll(PDO::FETCH_ASSOC); if (empty($results)) { throw new NotFound('content', "remote_id: $remoteId"); } @@ -1048,11 +1055,12 @@ public function loadContentInfoByRemoteId($remoteId) */ public function loadContentInfoByLocationId($locationId) { - $query = $this->connection->createQueryBuilder(); - $query->where('t.main_node_id = :id') - ->setParameter('id', $locationId, PDO::PARAM_INT); + $queryBuilder = $this->createLoadContentInfoQueryBuilder(); + $queryBuilder + ->where('t.main_node_id = :id') + ->setParameter('id', $locationId, PDO::PARAM_INT); - $results = $this->internalLoadContentInfo($query); + $results = $queryBuilder->execute()->fetchAll(PDO::FETCH_ASSOC); if (empty($results)) { throw new NotFound('content', "main_node_id: $locationId"); } diff --git a/eZ/Publish/Core/Persistence/Legacy/Content/UrlAlias/Handler.php b/eZ/Publish/Core/Persistence/Legacy/Content/UrlAlias/Handler.php index 172e13eeb9b..29787da8c31 100644 --- a/eZ/Publish/Core/Persistence/Legacy/Content/UrlAlias/Handler.php +++ b/eZ/Publish/Core/Persistence/Legacy/Content/UrlAlias/Handler.php @@ -307,6 +307,10 @@ private function internalPublishUrlAliasForLocation( * If $languageCode is null the $alias is created in the system's default * language. $alwaysAvailable makes the alias available in all languages. * + * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException + * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException + * @throws \eZ\Publish\API\Repository\Exceptions\ForbiddenException + * * @param mixed $locationId * @param string $path * @param bool $forwarding @@ -335,6 +339,8 @@ public function createCustomUrlAlias($locationId, $path, $forwarding = false, $l * language. $alwaysAvailable makes the alias available in all languages. * * @throws \eZ\Publish\API\Repository\Exceptions\ForbiddenException if the path already exists for the given language + * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the path is broken + * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException * * @param string $resource * @param string $path @@ -536,9 +542,7 @@ public function removeURLAliases(array $urlAliases) * Looks up a url alias for the given url. * * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - * @throws \RuntimeException - * @throws \eZ\Publish\Core\Base\Exceptions\NotFoundException - * @throws \eZ\Publish\Core\Base\Exceptions\InvalidArgumentException + * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException * * @param string $url diff --git a/eZ/Publish/SPI/Persistence/Content/UrlAlias/Handler.php b/eZ/Publish/SPI/Persistence/Content/UrlAlias/Handler.php index 70f371434ca..2f95a5c1d92 100644 --- a/eZ/Publish/SPI/Persistence/Content/UrlAlias/Handler.php +++ b/eZ/Publish/SPI/Persistence/Content/UrlAlias/Handler.php @@ -69,6 +69,8 @@ public function createGlobalUrlAlias($resource, $path, $forwarding = false, $lan /** * List global aliases. * + * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if path for any of the global URL aliases is broken + * * @param string|null $languageCode * @param int $offset * @param int $limit @@ -80,6 +82,8 @@ public function listGlobalURLAliases($languageCode = null, $offset = 0, $limit = /** * List of url entries of $urlType, pointing to $locationId. * + * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if any path for the Location is broken + * * @param mixed $locationId * @param bool $custom if true the user generated aliases are listed otherwise the autogenerated * @@ -102,6 +106,8 @@ public function removeURLAliases(array $urlAliases); * Looks up a url alias for the given url. * * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException + * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException + * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the stored path for the given URL is broken * * @param string $url * @@ -112,9 +118,9 @@ public function lookup($url); /** * Loads URL alias by given $id. * - * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException + * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if path for the given URL alias is broken * - * @param string $id + * @param string $id unique identifier in the form of "-" * * @return \eZ\Publish\SPI\Persistence\Content\UrlAlias */ From 7c8b9383b8928062a258ec4fdcdccb7d51581bd5 Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Mon, 24 Sep 2018 16:59:44 +0200 Subject: [PATCH 3/3] [Unit Tests] Replaced deprecated getMock with createMock (#2446) * [Tests] Replaced deprecated getMock with createMock * [Tests] Deprecated PHPUnit5CompatTrait and removed its createMock method Current version requires PHPUnit 5.7, so forward compatibility is no longer needed --- ...ackgroundIndexingTerminateListenerTest.php | 3 --- .../Tests/Imagine/AliasGeneratorTest.php | 3 --- .../Core/Base/Tests/PHPUnit5CompatTrait.php | 21 ++----------------- .../RichText/InternalLinkValidatorTest.php | 3 --- .../Tests/Http/InstantCachePurgerTest.php | 3 --- ...MeRepositoryAuthenticationProviderTest.php | 3 --- .../Cache/Tests/ContentHandlerTest.php | 6 +++--- .../Persistence/Legacy/Tests/TestCase.php | 3 --- .../Tests/Security/CsrfTokenManagerTest.php | 3 --- .../Tests/Security/RestLogoutHandlerTest.php | 3 --- .../Repository/Tests/Service/Mock/Base.php | 10 +-------- .../Service/Mock/RelationProcessorTest.php | 6 +++--- 12 files changed, 9 insertions(+), 58 deletions(-) diff --git a/eZ/Bundle/EzPublishCoreBundle/Tests/EventListener/BackgroundIndexingTerminateListenerTest.php b/eZ/Bundle/EzPublishCoreBundle/Tests/EventListener/BackgroundIndexingTerminateListenerTest.php index 79dba1ecf83..bae0c10e3a7 100644 --- a/eZ/Bundle/EzPublishCoreBundle/Tests/EventListener/BackgroundIndexingTerminateListenerTest.php +++ b/eZ/Bundle/EzPublishCoreBundle/Tests/EventListener/BackgroundIndexingTerminateListenerTest.php @@ -10,7 +10,6 @@ use eZ\Bundle\EzPublishCoreBundle\EventListener\BackgroundIndexingTerminateListener; use eZ\Publish\Core\Base\Exceptions\NotFoundException; -use eZ\Publish\Core\Base\Tests\PHPUnit5CompatTrait; use eZ\Publish\SPI\Persistence\Content; use eZ\Publish\SPI\Persistence\Content\ContentInfo; use eZ\Publish\SPI\Persistence\Content\Location; @@ -23,8 +22,6 @@ class BackgroundIndexingTerminateListenerTest extends TestCase { - use PHPUnit5CompatTrait; - /** * @var \eZ\Bundle\EzPublishCoreBundle\EventListener\BackgroundIndexingTerminateListener */ diff --git a/eZ/Bundle/EzPublishCoreBundle/Tests/Imagine/AliasGeneratorTest.php b/eZ/Bundle/EzPublishCoreBundle/Tests/Imagine/AliasGeneratorTest.php index bbb83a7afc4..be27c0cb445 100644 --- a/eZ/Bundle/EzPublishCoreBundle/Tests/Imagine/AliasGeneratorTest.php +++ b/eZ/Bundle/EzPublishCoreBundle/Tests/Imagine/AliasGeneratorTest.php @@ -12,7 +12,6 @@ use eZ\Bundle\EzPublishCoreBundle\Imagine\Variation\ImagineAwareAliasGenerator; use eZ\Bundle\EzPublishCoreBundle\Imagine\VariationPathGenerator; use eZ\Publish\API\Repository\Values\Content\Field; -use eZ\Publish\Core\Base\Tests\PHPUnit5CompatTrait; use eZ\Publish\Core\FieldType\Image\Value as ImageValue; use eZ\Publish\Core\FieldType\TextLine\Value as TextLineValue; use eZ\Publish\SPI\FieldType\Value as FieldTypeValue; @@ -33,8 +32,6 @@ class AliasGeneratorTest extends TestCase { - use PHPUnit5CompatTrait; - /** * @var \PHPUnit_Framework_MockObject_MockObject|\Liip\ImagineBundle\Binary\Loader\LoaderInterface */ diff --git a/eZ/Publish/Core/Base/Tests/PHPUnit5CompatTrait.php b/eZ/Publish/Core/Base/Tests/PHPUnit5CompatTrait.php index 67ed7aaac2d..d93abd9930e 100644 --- a/eZ/Publish/Core/Base/Tests/PHPUnit5CompatTrait.php +++ b/eZ/Publish/Core/Base/Tests/PHPUnit5CompatTrait.php @@ -9,6 +9,8 @@ /** * Trait for PHPUnit 5 Forward Compatibility, for PHPUnit 4.8 use and up. + * + * @deprecated since 6.13.5, use createMock from PHPUnit package instead. */ trait PHPUnit5CompatTrait { @@ -31,23 +33,4 @@ public function getMock($originalClassName, $methods = array(), array $arguments $proxyTarget ); } - - /** - * Returns a test double for the specified class. - * - * @internal Forward compatibility with PHPUnit 5/6, so unit tests written on 6.7 & backported to 5.4 can use this. - * - * @param string $originalClassName - * - * @return \PHPUnit_Framework_MockObject_MockObject - */ - protected function createMock($originalClassName) - { - return $this->getMockBuilder($originalClassName) - ->disableOriginalConstructor() - ->disableOriginalClone() - ->disableArgumentCloning() - //->disallowMockingUnknownTypes() Not defined in PHPunit 4.8 - ->getMock(); - } } diff --git a/eZ/Publish/Core/FieldType/Tests/RichText/InternalLinkValidatorTest.php b/eZ/Publish/Core/FieldType/Tests/RichText/InternalLinkValidatorTest.php index 3d8c47f7e38..cc1da38f6d7 100644 --- a/eZ/Publish/Core/FieldType/Tests/RichText/InternalLinkValidatorTest.php +++ b/eZ/Publish/Core/FieldType/Tests/RichText/InternalLinkValidatorTest.php @@ -10,15 +10,12 @@ use eZ\Publish\SPI\Persistence\Content\Handler as ContentHandler; use eZ\Publish\SPI\Persistence\Content\Location\Handler as LocationHandler; -use eZ\Publish\Core\Base\Tests\PHPUnit5CompatTrait; use eZ\Publish\Core\Base\Exceptions\NotFoundException; use eZ\Publish\Core\FieldType\RichText\InternalLinkValidator; use PHPUnit\Framework\TestCase; class InternalLinkValidatorTest extends TestCase { - use PHPUnit5CompatTrait; - /** @var \eZ\Publish\SPI\Persistence\Content\Handler|\PHPUnit_Framework_MockObject_MockObject */ private $contentHandler; diff --git a/eZ/Publish/Core/MVC/Symfony/Cache/Tests/Http/InstantCachePurgerTest.php b/eZ/Publish/Core/MVC/Symfony/Cache/Tests/Http/InstantCachePurgerTest.php index 982f6e08971..866b8354690 100644 --- a/eZ/Publish/Core/MVC/Symfony/Cache/Tests/Http/InstantCachePurgerTest.php +++ b/eZ/Publish/Core/MVC/Symfony/Cache/Tests/Http/InstantCachePurgerTest.php @@ -11,7 +11,6 @@ use eZ\Publish\API\Repository\ContentService; use eZ\Publish\API\Repository\Values\Content\ContentInfo; use eZ\Publish\API\Repository\Values\User\UserReference; -use eZ\Publish\Core\Base\Tests\PHPUnit5CompatTrait; use eZ\Publish\Core\MVC\Symfony\Cache\Http\InstantCachePurger; use eZ\Publish\Core\MVC\Symfony\Cache\PurgeClientInterface; use eZ\Publish\Core\MVC\Symfony\Event\ContentCacheClearEvent; @@ -28,8 +27,6 @@ class InstantCachePurgerTest extends TestCase { - use PHPUnit5CompatTrait; - /** * @var \eZ\Publish\Core\MVC\Symfony\Cache\PurgeClientInterface|\PHPUnit_Framework_MockObject_MockObject */ diff --git a/eZ/Publish/Core/MVC/Symfony/Security/Tests/Authentication/RememberMeRepositoryAuthenticationProviderTest.php b/eZ/Publish/Core/MVC/Symfony/Security/Tests/Authentication/RememberMeRepositoryAuthenticationProviderTest.php index 577409029be..291e450fe6f 100644 --- a/eZ/Publish/Core/MVC/Symfony/Security/Tests/Authentication/RememberMeRepositoryAuthenticationProviderTest.php +++ b/eZ/Publish/Core/MVC/Symfony/Security/Tests/Authentication/RememberMeRepositoryAuthenticationProviderTest.php @@ -11,7 +11,6 @@ use eZ\Publish\API\Repository\Repository; use eZ\Publish\API\Repository\Values\User\User as ApiUser; use eZ\Publish\API\Repository\Values\User\UserReference; -use eZ\Publish\Core\Base\Tests\PHPUnit5CompatTrait; use eZ\Publish\Core\MVC\Symfony\Security\Authentication\RememberMeRepositoryAuthenticationProvider; use eZ\Publish\Core\MVC\Symfony\Security\User; use eZ\Publish\Core\Repository\Helper\LimitationService; @@ -26,8 +25,6 @@ class RememberMeRepositoryAuthenticationProviderTest extends TestCase { - use PHPUnit5CompatTrait; - /** * @var RememberMeRepositoryAuthenticationProvider */ diff --git a/eZ/Publish/Core/Persistence/Cache/Tests/ContentHandlerTest.php b/eZ/Publish/Core/Persistence/Cache/Tests/ContentHandlerTest.php index b21954e3838..9934c180bf6 100644 --- a/eZ/Publish/Core/Persistence/Cache/Tests/ContentHandlerTest.php +++ b/eZ/Publish/Core/Persistence/Cache/Tests/ContentHandlerTest.php @@ -303,7 +303,7 @@ public function testLoadContentInfoHasCache() public function testLoadVersionInfoCacheIsMiss() { $this->loggerMock->expects($this->once())->method('logCall'); - $cacheItemMock = $this->getMock(ItemInterface::class); + $cacheItemMock = $this->createMock(ItemInterface::class); $this->cacheMock ->expects($this->once()) ->method('getItem') @@ -320,7 +320,7 @@ public function testLoadVersionInfoCacheIsMiss() ->method('isMiss') ->will($this->returnValue(true)); - $innerHandlerMock = $this->getMock(Handler::class); + $innerHandlerMock = $this->createMock(Handler::class); $this->persistenceHandlerMock ->expects($this->once()) ->method('contentHandler') @@ -357,7 +357,7 @@ public function testLoadVersionInfoCacheIsMiss() public function testLoadVersionInfoHasCache() { $this->loggerMock->expects($this->never())->method($this->anything()); - $cacheItemMock = $this->getMock(ItemInterface::class); + $cacheItemMock = $this->createMock(ItemInterface::class); $this->cacheMock ->expects($this->once()) ->method('getItem') diff --git a/eZ/Publish/Core/Persistence/Legacy/Tests/TestCase.php b/eZ/Publish/Core/Persistence/Legacy/Tests/TestCase.php index 6c484a528a9..3eb57ea7cdd 100644 --- a/eZ/Publish/Core/Persistence/Legacy/Tests/TestCase.php +++ b/eZ/Publish/Core/Persistence/Legacy/Tests/TestCase.php @@ -8,7 +8,6 @@ */ namespace eZ\Publish\Core\Persistence\Legacy\Tests; -use eZ\Publish\Core\Base\Tests\PHPUnit5CompatTrait; use eZ\Publish\Core\Persistence\Doctrine\ConnectionHandler; use eZ\Publish\Core\Persistence\Database\SelectQuery; use PHPUnit\Framework\TestCase as BaseTestCase; @@ -21,8 +20,6 @@ */ abstract class TestCase extends BaseTestCase { - use PHPUnit5CompatTrait; - /** * DSN used for the DB backend. * diff --git a/eZ/Publish/Core/REST/Server/Tests/Security/CsrfTokenManagerTest.php b/eZ/Publish/Core/REST/Server/Tests/Security/CsrfTokenManagerTest.php index a96d88d7a96..faeb513afac 100644 --- a/eZ/Publish/Core/REST/Server/Tests/Security/CsrfTokenManagerTest.php +++ b/eZ/Publish/Core/REST/Server/Tests/Security/CsrfTokenManagerTest.php @@ -8,7 +8,6 @@ */ namespace eZ\Publish\Core\REST\Server\Tests\Security; -use eZ\Publish\Core\Base\Tests\PHPUnit5CompatTrait; use eZ\Publish\Core\REST\Server\Security\CsrfTokenManager; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Request; @@ -18,8 +17,6 @@ class CsrfTokenManagerTest extends TestCase { - use PHPUnit5CompatTrait; - const CSRF_TOKEN_INTENTION = 'csrf'; /** @var \PHPUnit_Framework_MockObject_MockObject|\Symfony\Component\Security\Csrf\TokenStorage\TokenStorageInterface */ diff --git a/eZ/Publish/Core/REST/Server/Tests/Security/RestLogoutHandlerTest.php b/eZ/Publish/Core/REST/Server/Tests/Security/RestLogoutHandlerTest.php index 2fc3a7cb2a9..6979d6c6a20 100644 --- a/eZ/Publish/Core/REST/Server/Tests/Security/RestLogoutHandlerTest.php +++ b/eZ/Publish/Core/REST/Server/Tests/Security/RestLogoutHandlerTest.php @@ -8,7 +8,6 @@ */ namespace eZ\Publish\Core\REST\Server\Tests\Security; -use eZ\Publish\Core\Base\Tests\PHPUnit5CompatTrait; use eZ\Publish\Core\MVC\ConfigResolverInterface; use eZ\Publish\Core\REST\Server\Security\RestLogoutHandler; use PHPUnit\Framework\TestCase; @@ -20,8 +19,6 @@ class RestLogoutHandlerTest extends TestCase { - use PHPUnit5CompatTrait; - /** * @var \PHPUnit_Framework_MockObject_MockObject */ diff --git a/eZ/Publish/Core/Repository/Tests/Service/Mock/Base.php b/eZ/Publish/Core/Repository/Tests/Service/Mock/Base.php index fce26167b3a..f09f6dd3826 100644 --- a/eZ/Publish/Core/Repository/Tests/Service/Mock/Base.php +++ b/eZ/Publish/Core/Repository/Tests/Service/Mock/Base.php @@ -6,7 +6,6 @@ */ namespace eZ\Publish\Core\Repository\Tests\Service\Mock; -use eZ\Publish\Core\Base\Tests\PHPUnit5CompatTrait; use eZ\Publish\Core\Repository\Helper\RelationProcessor; use eZ\Publish\Core\Search\Common\BackgroundIndexer\NullIndexer; use PHPUnit\Framework\TestCase; @@ -21,8 +20,6 @@ */ abstract class Base extends TestCase { - use PHPUnit5CompatTrait; - /** * @var \eZ\Publish\API\Repository\Repository */ @@ -203,12 +200,7 @@ protected function getPersistenceMock() protected function getRelationProcessorMock() { - return $this->getMock(RelationProcessor::class, - array(), - array(), - '', - false - ); + return $this->createMock(RelationProcessor::class); } /** diff --git a/eZ/Publish/Core/Repository/Tests/Service/Mock/RelationProcessorTest.php b/eZ/Publish/Core/Repository/Tests/Service/Mock/RelationProcessorTest.php index 97386d2f386..7b7d279afe7 100644 --- a/eZ/Publish/Core/Repository/Tests/Service/Mock/RelationProcessorTest.php +++ b/eZ/Publish/Core/Repository/Tests/Service/Mock/RelationProcessorTest.php @@ -266,7 +266,7 @@ public function testAppendFieldRelationsLocationMappingWorks() public function testAppendFieldRelationsLogsMissingLocations() { $fieldValueMock = $this->getMockForAbstractClass(Value::class); - $fieldTypeMock = $this->getMock(FieldType::class); + $fieldTypeMock = $this->createMock(FieldType::class); $locationId = 123465; $fieldDefinitionId = 42; @@ -290,9 +290,9 @@ public function testAppendFieldRelationsLogsMissingLocations() ->expects($this->any()) ->method('load') ->with($locationId) - ->willThrowException($this->getMock(NotFoundException::class)); + ->willThrowException($this->createMock(NotFoundException::class)); - $logger = $this->getMock(LoggerInterface::class); + $logger = $this->createMock(LoggerInterface::class); $logger ->expects($this->once()) ->method('error')