Skip to content

Commit

Permalink
Add isMerged property to DimensionContentInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasnatter committed May 18, 2020
1 parent 38da24e commit 8a88c1b
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Content/Application/ContentMerger/ContentMerger.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public function mergeCollection(DimensionContentCollectionInterface $dimensionCo
$mostSpecificDimension = $mostSpecificDimensionContent->getDimension();
$contentRichEntity = $mostSpecificDimensionContent->getContentRichEntity();

// TODO: set isResolved flag of dimension content
$mergedDimensionContent = $contentRichEntity->createDimensionContent($mostSpecificDimension);
$mergedDimensionContent->markAsMerged();

foreach ($dimensionContentCollection as $dimensionContent) {
$this->merge($mergedDimensionContent, $dimensionContent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function getIgnoredAttributes(object $object): array

return [
'id',
'merged',
'dimension',
'contentRichEntity',
];
Expand Down
4 changes: 4 additions & 0 deletions Content/Domain/Model/DimensionContentInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ interface DimensionContentInterface
public function getDimension(): DimensionInterface;

public function getContentRichEntity(): ContentRichEntityInterface;

public function isMerged(): bool;

public function markAsMerged(): void;
}
15 changes: 15 additions & 0 deletions Content/Domain/Model/DimensionContentTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,23 @@ trait DimensionContentTrait
*/
protected $dimension;

/**
* @var bool
*/
private $isMerged = false;

public function getDimension(): DimensionInterface
{
return $this->dimension;
}

public function isMerged(): bool
{
return $this->isMerged;
}

public function markAsMerged(): void
{
$this->isMerged = true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ public function testMergeCollection(): void
$merger1->merge($mergedDimensionContent->reveal(), $dimensionContent3->reveal())->shouldBeCalled();
$merger2->merge($mergedDimensionContent->reveal(), $dimensionContent3->reveal())->shouldBeCalled();

$mergedDimensionContent->markAsMerged()->shouldBeCalled();

$dimensionContentCollection = new DimensionContentCollection([
$dimensionContent1->reveal(),
$dimensionContent2->reveal(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function testIgnoredAttributes(): void
$object = $this->prophesize(DimensionContentInterface::class);

$this->assertSame(
['id', 'dimension', 'contentRichEntity'],
['id', 'merged', 'dimension', 'contentRichEntity'],
$normalizer->getIgnoredAttributes($object->reveal())
);
}
Expand Down
11 changes: 11 additions & 0 deletions Tests/Unit/Content/Domain/Model/DimensionContentTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,15 @@ public function testGetDimension(): void
$model = $this->getDimensionContentInstance($dimension->reveal());
$this->assertSame($dimension->reveal(), $model->getDimension());
}

public function testGetSetIsMerged(): void
{
$dimension = $this->prophesize(DimensionInterface::class);

$model = $this->getDimensionContentInstance($dimension->reveal());
$this->assertFalse($model->isMerged());

$model->markAsMerged();
$this->assertTrue($model->isMerged());
}
}
2 changes: 1 addition & 1 deletion Tests/Unit/Content/Domain/Model/RoutableTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function testGetLocale(): void
$this->assertSame('en', $model->getLocale());
}

public function getContentId(): void
public function testGetContentId(): void
{
$model = $this->getRoutableInstance();
$this->assertSame('content-id-123', $model->getContentId());
Expand Down
10 changes: 10 additions & 0 deletions Tests/Unit/Mocks/DimensionContentMockWrapperTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,14 @@ public function getContentRichEntity(): ContentRichEntityInterface
{
return $this->instance->getContentRichEntity();
}

public function isMerged(): bool
{
return $this->instance->isMerged();
}

public function markAsMerged(): void
{
$this->instance->markAsMerged();
}
}
4 changes: 2 additions & 2 deletions Tests/Unit/SuluContentBundleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@

class SuluContentBundleTest extends TestCase
{
protected function getBundle(): SuluContentBundle
protected function getContentBundle(): SuluContentBundle
{
return new SuluContentBundle();
}

public function testPersistenceCompilerPass(): void
{
$bundle = $this->getBundle();
$bundle = $this->getContentBundle();
$containerBuilder = new ContainerBuilder();

$bundle->build($containerBuilder);
Expand Down

0 comments on commit 8a88c1b

Please sign in to comment.