From 9628f49647f22ac78dcf34af905af0dd871b55e2 Mon Sep 17 00:00:00 2001 From: Nattfarinn Date: Tue, 1 Sep 2015 14:20:56 +0200 Subject: [PATCH] EZP-24750 fix: call to /api/ezp/v2/content/locations/1 caused server error Reason: missing ownerId for fake ContentInfo --- .../Repository/Tests/LocationServiceTest.php | 55 +++++++++++++++++++ .../Core/Repository/Helper/DomainMapper.php | 9 +++ 2 files changed, 64 insertions(+) diff --git a/eZ/Publish/API/Repository/Tests/LocationServiceTest.php b/eZ/Publish/API/Repository/Tests/LocationServiceTest.php index 8ad16baffe3..04d1d0c2796 100644 --- a/eZ/Publish/API/Repository/Tests/LocationServiceTest.php +++ b/eZ/Publish/API/Repository/Tests/LocationServiceTest.php @@ -333,6 +333,61 @@ public function testLoadLocation() return $location; } + /** + * Test for the loadLocation() method. + * + * @see \eZ\Publish\API\Repository\LocationService::loadLocation() + * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocation + */ + public function testLoadLocationRootStructValues() + { + $repository = $this->getRepository(); + $locationService = $repository->getLocationService(); + $location = $locationService->loadLocation($this->generateId('location', 1)); + + $legacyDateTime = new \DateTime(); + $legacyDateTime->setTimestamp(1030968000); + + // $location + $this->assertPropertiesCorrect( + array( + 'id' => $this->generateId('location', 1), + 'status' => 1, + 'priority' => 0, + 'hidden' => false, + 'invisible' => false, + 'remoteId' => '629709ba256fe317c3ddcee35453a96a', + 'parentLocationId' => $this->generateId('location', 1), + 'pathString' => '/1/', + 'depth' => 0, + 'sortField' => 1, + 'sortOrder' => 1, + ), + $location + ); + + // $location->contentInfo + $this->assertInstanceOf('\\eZ\\Publish\\API\\Repository\\Values\\Content\\ContentInfo', $location->contentInfo); + $this->assertPropertiesCorrect( + array( + 'id' => $this->generateId('content', 0), + 'name' => 'Top Level Nodes', + 'sectionId' => 1, + 'mainLocationId' => 1, + 'contentTypeId' => 1, + 'currentVersionNo' => 1, + 'published' => 1, + 'ownerId' => 14, + 'modificationDate' => $legacyDateTime, + 'publishedDate' => $legacyDateTime, + 'alwaysAvailable' => 1, + 'remoteId' => null, + 'mainLanguageCode' => 'eng-GB', + ), + $location->contentInfo + ); + } + /** * Test for the loadLocation() method. * diff --git a/eZ/Publish/Core/Repository/Helper/DomainMapper.php b/eZ/Publish/Core/Repository/Helper/DomainMapper.php index 5ec8afa670a..1622b0b89be 100644 --- a/eZ/Publish/Core/Repository/Helper/DomainMapper.php +++ b/eZ/Publish/Core/Repository/Helper/DomainMapper.php @@ -276,6 +276,7 @@ public function buildLocationDomainObject(SPILocation $spiLocation) { // TODO: this is hardcoded workaround for missing ContentInfo on root location if ($spiLocation->id == 1) { + $legacyDateTime = $this->getDateTime(1030968000); // first known commit of eZ Publish 3.x $contentInfo = new ContentInfo( array( 'id' => 0, @@ -283,6 +284,14 @@ public function buildLocationDomainObject(SPILocation $spiLocation) 'sectionId' => 1, 'mainLocationId' => 1, 'contentTypeId' => 1, + 'currentVersionNo' => 1, + 'published' => 1, + 'ownerId' => 14, // admin user + 'modificationDate' => $legacyDateTime, + 'publishedDate' => $legacyDateTime, + 'alwaysAvailable' => 1, + 'remoteId' => null, + 'mainLanguageCode' => 'eng-GB', ) ); } else {