Skip to content

Commit

Permalink
EZP-24750 fix: call to /api/ezp/v2/content/locations/1 caused server …
Browse files Browse the repository at this point in the history
…error

Reason: missing ownerId for fake ContentInfo
  • Loading branch information
Nattfarinn committed Sep 2, 2015
1 parent cf1d107 commit 9628f49
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
55 changes: 55 additions & 0 deletions eZ/Publish/API/Repository/Tests/LocationServiceTest.php
Expand Up @@ -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.
*
Expand Down
9 changes: 9 additions & 0 deletions eZ/Publish/Core/Repository/Helper/DomainMapper.php
Expand Up @@ -276,13 +276,22 @@ 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,
'name' => 'Top Level Nodes',
'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 {
Expand Down

0 comments on commit 9628f49

Please sign in to comment.