Skip to content

Commit

Permalink
Merge branch '6.13' into 7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
andrerom committed Sep 10, 2018
2 parents 900a7f1 + c7cf3a6 commit 367de37
Show file tree
Hide file tree
Showing 27 changed files with 186 additions and 148 deletions.
7 changes: 7 additions & 0 deletions eZ/Bundle/EzPublishCoreBundle/Command/ReindexCommand.php
Expand Up @@ -45,6 +45,11 @@ class ReindexCommand extends ContainerAwareCommand
*/
private $logger;

/**
* @var string
*/
private $siteaccess;

/**
* Initialize objects required by {@see execute()}.
*
Expand Down Expand Up @@ -143,6 +148,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
{
$commit = !$input->getOption('no-commit');
$iterationCount = $input->getOption('iteration-count');
$this->siteaccess = $input->getOption('siteaccess');
if (!is_numeric($iterationCount) || (int) $iterationCount < 1) {
throw new RuntimeException("'--iteration-count' option should be > 0, got '{$iterationCount}'");
}
Expand Down Expand Up @@ -371,6 +377,7 @@ private function getPhpProcess(array $contentIds, $commit)
{
$process = new ProcessBuilder([
file_exists('bin/console') ? 'bin/console' : 'app/console',
$this->siteaccess ? '--siteaccess=' . $this->siteaccess : null,
'ezplatform:reindex',
'--content-ids=' . implode(',', $contentIds),
]);
Expand Down
9 changes: 6 additions & 3 deletions eZ/Publish/API/Repository/PermissionResolver.php
Expand Up @@ -29,10 +29,13 @@ public function getCurrentUserReference();
public function setCurrentUserReference(UserReference $userReference);

/**
* Returns boolean value or an array of limitations describing user's permissions
* on the given module and function.
* Low level permission function: Returns boolean value, or an array of limitations that user permission depends on.
*
* Note: boolean value describes full access (true) or no access at all (false).
* Note: boolean value describes full access (true) or no access at all (false), array can be seen as a maybe..
*
* WARNING: This is a low level method, if possible strongly prefer to use canUser() as it is able to handle limitations.
* This includes Role Assignment limitations, but also future policy limitations added in kernel,
* or as plain user configuration and/or extending the system.
*
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException If module or function is invalid.
*
Expand Down
6 changes: 2 additions & 4 deletions eZ/Publish/API/Repository/Tests/SearchServiceTest.php
Expand Up @@ -1049,8 +1049,7 @@ public function testFindNoPerformCount()
$searchHit = $searchService->findContent($query);

if (ltrim(get_class($this->getSetupFactory()), '\\') === 'eZ\Publish\API\Repository\Tests\SetupFactory\Legacy') {
$this->assertEquals(
null,
$this->assertNull(
$searchHit->totalCount
);
} else {
Expand Down Expand Up @@ -1097,8 +1096,7 @@ public function testFindLocationsNoPerformCount()
$searchHit = $searchService->findLocations($query);

if (ltrim(get_class($this->getSetupFactory()), '\\') === 'eZ\Publish\API\Repository\Tests\SetupFactory\Legacy') {
$this->assertEquals(
null,
$this->assertNull(
$searchHit->totalCount
);
} else {
Expand Down
6 changes: 3 additions & 3 deletions eZ/Publish/API/Repository/Tests/SectionServiceTest.php
Expand Up @@ -525,8 +525,8 @@ public function testIsSectionUsed()
);
/* END: Use Case */

$this->assertEquals(
true, // Taken from the fixture
$this->assertTrue(
// Taken from the fixture
$isSectionUsed
);
}
Expand Down Expand Up @@ -637,7 +637,7 @@ public function testIsSectionUsedReturnsZeroByDefault()
$isSectionUsed = $sectionService->isSectionUsed($section);
/* END: Use Case */

$this->assertSame(false, $isSectionUsed);
$this->assertFalse($isSectionUsed);
}

/**
Expand Down
29 changes: 25 additions & 4 deletions eZ/Publish/API/Repository/Tests/TrashServiceTest.php
Expand Up @@ -11,6 +11,7 @@
use eZ\Publish\API\Repository\Repository;
use eZ\Publish\API\Repository\URLAliasService;
use eZ\Publish\API\Repository\Values\Content\Content;
use eZ\Publish\API\Repository\Values\Content\ContentInfo;
use eZ\Publish\API\Repository\Values\Content\Location as APILocation;
use eZ\Publish\API\Repository\Values\Content\LocationCreateStruct;
use eZ\Publish\API\Repository\Values\Content\Query;
Expand Down Expand Up @@ -339,8 +340,13 @@ public function testRecoverThrowsNotFoundExceptionForNonExistingTrashItem()
$repository = $this->getRepository();
$trashService = $repository->getTrashService();

$trashItem = new TrashItem(['id' => 12364, 'parentLocationId' => 12363]);
$trashService->recover($trashItem);
$trashService->recover(
$this->getTrashItemDouble(
12364,
12345,
12363
)
);
}

/**
Expand Down Expand Up @@ -797,8 +803,11 @@ public function testDeleteThrowsNotFoundExceptionForNonExistingTrashItem()
$repository = $this->getRepository();
$trashService = $repository->getTrashService();

$trashItem = new TrashItem(['id' => 123456]);
$trashService->deleteTrashItem($trashItem);
$trashService->deleteTrashItem($this->getTrashItemDouble(
12364,
12345,
12363
));
}

/**
Expand Down Expand Up @@ -883,4 +892,16 @@ private function assertAliasNotExists(URLAliasService $urlAliasService, $urlPath
$this->assertTrue(true);
}
}

/**
* Get Test Double for TrashItem for exception testing and similar.
*/
private function getTrashItemDouble(int $trashId, int $contentId = 44, int $parentLocationId = 2): TrashItem
{
return new TrashItem([
'id' => $trashId,
'parentLocationId' => $parentLocationId,
'contentInfo' => new ContentInfo(['id' => $contentId]),
]);
}
}
3 changes: 1 addition & 2 deletions eZ/Publish/Core/FieldType/Tests/FieldTypeMockTest.php
Expand Up @@ -202,8 +202,7 @@ public function testApplyDefaultValidatorConfigurationEmpty()

$validatorConfiguration = null;
$stub->applyDefaultValidatorConfiguration($validatorConfiguration);
$this->assertSame(
null,
$this->assertNull(
$validatorConfiguration
);
}
Expand Down
4 changes: 2 additions & 2 deletions eZ/Publish/Core/FieldType/Tests/Url/UrlStorageTest.php
Expand Up @@ -97,7 +97,7 @@ public function testStoreFieldDataWithEmptyUrl()
$result = $storage->storeFieldData($versionInfo, $field, $this->getContext());

$this->assertFalse($result);
$this->assertEquals(null, $field->value->data['urlId']);
$this->assertNull($field->value->data['urlId']);
}

public function testGetFieldData()
Expand Down Expand Up @@ -163,7 +163,7 @@ public function testGetFieldDataWithEmptyUrlId()
$storage = $this->getPartlyMockedStorage($gateway);
$storage->getFieldData($versionInfo, $field, $this->getContext());

$this->assertEquals(null, $field->value->externalData);
$this->assertNull($field->value->externalData);
}

public function testDeleteFieldData()
Expand Down
9 changes: 7 additions & 2 deletions eZ/Publish/Core/Limitation/SubtreeLimitationType.php
Expand Up @@ -137,10 +137,15 @@ public function evaluate(APILimitationValue $value, APIUserReference $currentUse

// Load locations if no specific placement was provided
if ($targets === null) {
if ($object->published) {
// Skip check if content is in trash and no location is provided to check against
if ($object->isTrashed()) {
return self::ACCESS_ABSTAIN;
}

if ($object->isPublished()) {
$targets = $this->persistence->locationHandler()->loadLocationsByContent($object->id);
} else {
// @todo Need support for draft locations to to work correctly
// @todo Need support for draft locations to work correctly
$targets = $this->persistence->locationHandler()->loadParentLocationsForDraftContent($object->id);
}
}
Expand Down
20 changes: 10 additions & 10 deletions eZ/Publish/Core/Limitation/Tests/SubtreeLimitationTypeTest.php
Expand Up @@ -268,68 +268,68 @@ public function providerForTestEvaluate()
$versionInfoMock
->expects($this->once())
->method('getContentInfo')
->will($this->returnValue(new ContentInfo(array('published' => true))));
->willReturn(new ContentInfo(['published' => true, 'status' => ContentInfo::STATUS_PUBLISHED]));

$versionInfoMock2 = $this->createMock(APIVersionInfo::class);

$versionInfoMock2
->expects($this->once())
->method('getContentInfo')
->will($this->returnValue(new ContentInfo(array('published' => true))));
->willReturn(new ContentInfo(['published' => true, 'status' => ContentInfo::STATUS_PUBLISHED]));

return array(
// ContentInfo, with targets, no access
array(
'limitation' => new SubtreeLimitation(),
'object' => new ContentInfo(array('published' => true)),
'object' => new ContentInfo(['published' => true, 'status' => ContentInfo::STATUS_PUBLISHED]),
'targets' => array(new Location()),
'persistence' => array(),
'expected' => LimitationType::ACCESS_DENIED,
),
// ContentInfo, with targets, no access
array(
'limitation' => new SubtreeLimitation(array('limitationValues' => array('/1/2/'))),
'object' => new ContentInfo(array('published' => true)),
'object' => new ContentInfo(['published' => true, 'status' => ContentInfo::STATUS_PUBLISHED]),
'targets' => array(new Location(array('pathString' => '/1/55/'))),
'persistence' => array(),
'expected' => LimitationType::ACCESS_DENIED,
),
// ContentInfo, with targets, with access
array(
'limitation' => new SubtreeLimitation(array('limitationValues' => array('/1/2/'))),
'object' => new ContentInfo(array('published' => true)),
'object' => new ContentInfo(['published' => true, 'status' => ContentInfo::STATUS_PUBLISHED]),
'targets' => array(new Location(array('pathString' => '/1/2/'))),
'persistence' => array(),
'expected' => LimitationType::ACCESS_GRANTED,
),
// ContentInfo, no targets, with access
array(
'limitation' => new SubtreeLimitation(array('limitationValues' => array('/1/2/'))),
'object' => new ContentInfo(array('published' => true)),
'object' => new ContentInfo(['published' => true, 'status' => ContentInfo::STATUS_PUBLISHED]),
'targets' => null,
'persistence' => array(new Location(array('pathString' => '/1/2/'))),
'expected' => LimitationType::ACCESS_GRANTED,
),
// ContentInfo, no targets, no access
array(
'limitation' => new SubtreeLimitation(array('limitationValues' => array('/1/2/', '/1/43/'))),
'object' => new ContentInfo(array('published' => true)),
'object' => new ContentInfo(['published' => true, 'status' => ContentInfo::STATUS_PUBLISHED]),
'targets' => null,
'persistence' => array(new Location(array('pathString' => '/1/55/'))),
'expected' => LimitationType::ACCESS_DENIED,
),
// ContentInfo, no targets, un-published, with access
array(
'limitation' => new SubtreeLimitation(array('limitationValues' => array('/1/2/'))),
'object' => new ContentInfo(array('published' => false)),
'object' => new ContentInfo(['published' => false, 'status' => ContentInfo::STATUS_DRAFT]),
'targets' => null,
'persistence' => array(new Location(array('pathString' => '/1/2/'))),
'expected' => LimitationType::ACCESS_GRANTED,
),
// ContentInfo, no targets, un-published, no access
array(
'limitation' => new SubtreeLimitation(array('limitationValues' => array('/1/2/', '/1/43/'))),
'object' => new ContentInfo(array('published' => false)),
'object' => new ContentInfo(['published' => false, 'status' => ContentInfo::STATUS_DRAFT]),
'targets' => null,
'persistence' => array(new Location(array('pathString' => '/1/55/'))),
'expected' => LimitationType::ACCESS_DENIED,
Expand Down Expand Up @@ -385,7 +385,7 @@ public function providerForTestEvaluate()
// invalid target
array(
'limitation' => new SubtreeLimitation(),
'object' => new ContentInfo(array('published' => true)),
'object' => new ContentInfo(['published' => true, 'status' => ContentInfo::STATUS_PUBLISHED]),
'targets' => array(new ObjectStateLimitation()),
'persistence' => array(),
'expected' => LimitationType::ACCESS_ABSTAIN,
Expand Down
Expand Up @@ -98,8 +98,7 @@ public function testRenderTagNoTemplateConfigured()
->method('error')
->with("Could not render template tag '{$name}': no template configured");

$this->assertEquals(
null,
$this->assertNull(
$renderer->renderTag($name, $parameters, $isInline)
);
}
Expand Down Expand Up @@ -133,8 +132,7 @@ public function testRenderTagNoTemplateFound()
->method('error')
->with("Could not render template tag '{$name}': template '{$templateName}' does not exists");

$this->assertEquals(
null,
$this->assertNull(
$renderer->renderTag($name, $parameters, $isInline)
);
}
Expand Down Expand Up @@ -408,8 +406,7 @@ public function testRenderContentEmbedNoTemplateConfigured()
->method('error')
->with('Could not render embedded resource: no template configured');

$this->assertEquals(
null,
$this->assertNull(
$renderer->renderContentEmbed($contentId, $viewType, $parameters, $isInline)
);
}
Expand Down Expand Up @@ -458,8 +455,7 @@ public function testRenderContentEmbedNoTemplateFound()
->method('error')
->with("Could not render embedded resource: template '{$templateName}' does not exists");

$this->assertEquals(
null,
$this->assertNull(
$renderer->renderContentEmbed($contentId, $viewType, $parameters, $isInline)
);
}
Expand Down Expand Up @@ -550,8 +546,7 @@ public function testRenderContentEmbedTrashed()
->method('error')
->with("Could not render embedded resource: Content #{$contentId} is trashed.");

$this->assertEquals(
null,
$this->assertNull(
$renderer->renderContentEmbed($contentId, $viewType, $parameters, $isInline)
);
}
Expand Down Expand Up @@ -958,8 +953,7 @@ public function testRenderLocationEmbedNoTemplateConfigured()
->method('error')
->with('Could not render embedded resource: no template configured');

$this->assertEquals(
null,
$this->assertNull(
$renderer->renderLocationEmbed($locationId, $viewType, $parameters, $isInline)
);
}
Expand Down Expand Up @@ -1008,8 +1002,7 @@ public function testRenderLocationEmbedNoTemplateFound()
->method('error')
->with("Could not render embedded resource: template '{$templateName}' does not exists");

$this->assertEquals(
null,
$this->assertNull(
$renderer->renderLocationEmbed($locationId, $viewType, $parameters, $isInline)
);
}
Expand Down Expand Up @@ -1098,8 +1091,7 @@ public function testRenderLocationEmbedInvisible()
->method('error')
->with("Could not render embedded resource: Location #{$locationId} is not visible");

$this->assertEquals(
null,
$this->assertNull(
$renderer->renderLocationEmbed($locationId, $viewType, $parameters, $isInline)
);
}
Expand Down
Expand Up @@ -99,8 +99,7 @@ public function testParse()
'sectionId not created correctly'
);

$this->assertEquals(
true,
$this->assertTrue(
$result->contentCreateStruct->alwaysAvailable,
'alwaysAvailable not created correctly'
);
Expand Down
Expand Up @@ -63,8 +63,7 @@ public function testParse()
'nameSchema not created correctly'
);

$this->assertEquals(
true,
$this->assertTrue(
$result->isContainer,
'isContainer not created correctly'
);
Expand All @@ -81,8 +80,7 @@ public function testParse()
'defaultSortOrder not created correctly'
);

$this->assertEquals(
true,
$this->assertTrue(
$result->defaultAlwaysAvailable,
'defaultAlwaysAvailable not created correctly'
);
Expand Down

0 comments on commit 367de37

Please sign in to comment.