...
 
Commits (3)
......@@ -2,10 +2,10 @@
namespace Minds\Core\Blogs\Delegates;
use Minds\Core\Entities\Propogator\Properties;
use Minds\Core\Entities\Propagator\Properties;
use Minds\Entities\Activity;
class PropogateProperties extends Properties
class PropagateProperties extends Properties
{
protected $actsOnSubtype = 'blog';
......
......@@ -9,7 +9,7 @@
namespace Minds\Core\Blogs;
use Minds\Core\Di\Di;
use Minds\Core\Entities\PropogateProperties;
use Minds\Core\Entities\PropagateProperties;
use Minds\Core\Security\Spam;
class Manager
......@@ -32,8 +32,8 @@ class Manager
/** @var Delegates\Search */
protected $search;
/** @var PropogateProperties */
protected $propogateProperties;
/** @var PropagateProperties */
protected $propagateProperties;
/**
* Manager constructor.
......@@ -43,7 +43,7 @@ class Manager
* @param null $feeds
* @param null $spam
* @param null $search
* @param PropogateProperties $propogateProperties
* @param PropagateProperties $propagateProperties
* @throws \Exception
*/
public function __construct(
......@@ -53,7 +53,7 @@ class Manager
$feeds = null,
$spam = null,
$search = null,
PropogateProperties $propogateProperties = null
PropagateProperties $propagateProperties = null
) {
$this->repository = $repository ?: new Repository();
$this->paywallReview = $paywallReview ?: new Delegates\PaywallReview();
......@@ -61,7 +61,7 @@ class Manager
$this->feeds = $feeds ?: new Delegates\Feeds();
$this->spam = $spam ?: Di::_()->get('Security\Spam');
$this->search = $search ?: new Delegates\Search();
$this->propogateProperties = $propogateProperties ?? Di::_()->get('PropogateProperties');
$this->propagateProperties = $propagateProperties ?? Di::_()->get('PropagateProperties');
}
/**
......@@ -177,7 +177,7 @@ class Manager
}
$this->paywallReview->queue($blog);
$this->propogateProperties->from($blog);
$this->propagateProperties->from($blog);
}
return $saved;
......
......@@ -2,26 +2,30 @@
namespace Minds\Core\Entities\Delegates;
use Minds\Core\Entities\Propogator\Properties;
use Minds\Core\Entities\Propagator\Properties;
use Minds\Entities\Activity;
class PropogateProperties extends Properties
class PropagateProperties extends Properties
{
public function toActivity($from, Activity &$to): void
{
if ($this->valueHasChanged($from->getNsfw(), $to->getNsfw()))
if ($this->valueHasChanged($from->getNsfw(), $to->getNsfw())) {
$to->setNsfw($from->getNsfw());
}
if ($this->valueHasChanged($from->getNsfwLock(), $to->getNsfwLock()))
if ($this->valueHasChanged($from->getNsfwLock(), $to->getNsfwLock())) {
$to->setNsfwLock($from->getNsfwLock());
}
}
public function fromActivity(Activity $from, &$to): void
{
if ($this->valueHasChanged($from->getNsfw(), $to->getNsfw()))
if ($this->valueHasChanged($from->getNsfw(), $to->getNsfw())) {
$to->setNsfw($from->getNsfw());
}
if ($this->valueHasChanged($from->getNsfwLock(), $to->getNsfwLock()))
if ($this->valueHasChanged($from->getNsfwLock(), $to->getNsfwLock())) {
$to->setNsfwLock($from->getNsfwLock());
}
}
}
......@@ -5,15 +5,15 @@ namespace Minds\Core\Entities;
use Minds\Core\Data\Call;
use Minds\Core\Di\Di;
use Minds\Core\Entities\Actions\Save;
use Minds\Core\Entities\Propogator\Properties;
use Minds\Core\Entities\Propagator\Properties;
use Minds\Core\EntitiesBuilder;
use Minds\Entities\Activity;
use Minds\Core;
class PropogateProperties
class PropagateProperties
{
/** @var Properties[] */
protected $propogators;
protected $propagators;
/** @var Call */
private $db;
/** @var Save */
......@@ -28,45 +28,50 @@ class PropogateProperties
$this->db = $db ?? new Call('entities_by_time');
$this->save = $save ?? new Save();
$this->entitiesBuilder = $entitiesBuilder ?? Di::_()->get('EntitiesBuilder');
$this->registerPropogators();
$this->registerPropagators();
}
protected function registerPropogators(): void
protected function registerPropagators(): void
{
/* Register PropertyPropogator classes here */
$this->addPropogator(Core\Blogs\Delegates\PropogateProperties::class);
$this->addPropogator(Core\Feeds\Delegates\PropogateProperties::class);
$this->addPropogator(Core\Media\Delegates\PropogateProperties::class);
/* Register PropertyPropagator classes here */
$this->addPropagator(Core\Blogs\Delegates\PropagateProperties::class);
$this->addPropagator(Core\Feeds\Delegates\PropagateProperties::class);
$this->addPropagator(Core\Media\Delegates\PropagateProperties::class);
$this->addPropagator(Core\Entities\Delegates\PropagateProperties::class);
$this->addPropagator(Core\Permissions\Delegates\PropagateProperties::class);
}
protected function addPropogator(string $class): void
protected function addPropagator(string $class): void
{
$obj = new $class();
if (!$obj instanceof Properties)
throw new \Exception('Propogator class is not a Property Propogator');
if (!$obj instanceof Properties) {
throw new \Exception('Propagator class is not a Property Propagator');
}
$this->propogators[] = $obj;
$this->propagators[] = $obj;
}
public function from($entity): void
{
if ($entity instanceof Activity)
if ($entity instanceof Activity) {
$this->fromActivity($entity);
else
} else {
$this->toActivities($entity);
}
}
protected function fromActivity(Activity $activity): void
{
$this->changed = false;
$attachment = $this->entitiesBuilder->single($activity->get('entity_guid'));
if ($attachment === false)
if ($attachment === false) {
return;
}
foreach ($this->propogators as $propogator) {
if ($propogator->willActOnEntity($attachment)) {
$propogator->fromActivity($activity, $attachment);
$this->changed |= $propogator->changed();
foreach ($this->propagators as $propagator) {
if ($propagator->willActOnEntity($attachment)) {
$propagator->fromActivity($activity, $attachment);
$this->changed |= $propagator->changed();
}
}
......@@ -79,7 +84,7 @@ class PropogateProperties
{
$activities = $this->getActivitiesForEntity($entity->getGuid());
foreach ($activities as $activity) {
$this->propogateToActivity($entity, $activity);
$this->propagateToActivity($entity, $activity);
if ($this->changed) {
$this->save->setEntity($activity)->save();
}
......@@ -101,13 +106,13 @@ class PropogateProperties
return $activities;
}
public function propogateToActivity($entity, Activity &$activity): void
public function propagateToActivity($entity, Activity &$activity): void
{
$this->changed = false;
foreach ($this->propogators as $propogator) {
if ($propogator->willActOnEntity($entity)) {
$propogator->toActivity($entity, $activity);
$this->changed |= $propogator->changed();
foreach ($this->propagators as $propagator) {
if ($propagator->willActOnEntity($entity)) {
$propagator->toActivity($entity, $activity);
$this->changed |= $propagator->changed();
}
}
}
......
<?php
namespace Minds\Core\Entities\Propogator;
namespace Minds\Core\Entities\Propagator;
use Minds\Entities\Activity;
......
......@@ -2,26 +2,30 @@
namespace Minds\Core\Feeds\Delegates;
use Minds\Core\Entities\Propogator\Properties;
use Minds\Core\Entities\Propagator\Properties;
use Minds\Entities\Activity;
class PropogateProperties extends Properties
class PropagateProperties extends Properties
{
public function toActivity($from, Activity &$to): void
{
if ($this->valueHasChanged($from->getModeratorGuid(), $to->getModeratorGuid()))
if ($this->valueHasChanged($from->getModeratorGuid(), $to->getModeratorGuid())) {
$to->setModeratorGuid($from->getModeratorGuid());
}
if ($this->valueHasChanged($from->getTimeModerated(), $to->getModeratorGuid()))
if ($this->valueHasChanged($from->getTimeModerated(), $to->getModeratorGuid())) {
$to->setTimeModerated($from->getTimeModerated());
}
}
public function fromActivity(Activity $from, &$to): void
{
if ($this->valueHasChanged($from->getModeratorGuid(), $to->getModeratorGuid()))
if ($this->valueHasChanged($from->getModeratorGuid(), $to->getModeratorGuid())) {
$to->setModeratorGuid($from->getModeratorGuid());
}
if ($this->valueHasChanged($from->getTimeModerated(), $to->getModeratorGuid()))
if ($this->valueHasChanged($from->getTimeModerated(), $to->getModeratorGuid())) {
$to->setTimeModerated($from->getTimeModerated());
}
}
}
......@@ -2,15 +2,11 @@
namespace Minds\Core\Feeds\Firehose;
use Minds\Entities\Activity;
use Minds\Entities\User;
use Minds\Entities\Entity;
use Minds\Core\EntitiesBuilder;
use Minds\Core\Data\Call;
use Minds\Core\Entities\Actions\Save;
use Minds\Core\Di\Di;
use Minds\Core\Feeds\Top\Manager as TopFeedsManager;
use Minds\Core\Entities\PropogateProperties;
use Minds\Core\Entities\PropagateProperties;
class Manager
{
......@@ -20,19 +16,19 @@ class Manager
protected $moderationCache;
/** @var Save */
protected $save;
/** @var PropogateProperties */
protected $propogateProperties;
/** @var PropagateProperties */
protected $propagateProperties;
public function __construct(
TopFeedsManager $topFeedsManager = null,
ModerationCache $moderationCache = null,
Save $save = null,
PropogateProperties $propogateProperties = null
PropagateProperties $propagateProperties = null
) {
$this->topFeedsManager = $topFeedsManager ?: Di::_()->get('Feeds\Top\Manager');
$this->moderationCache = $moderationCache ?: new ModerationCache();
$this->save = $save ?: new Save(); //Mockable, else instantiate a new one on save.
$this->propogateProperties = $propogateProperties ?? Di::_()->get('PropogateProperties');
$this->save = $save ?: new Save();
$this->propagateProperties = $propagateProperties ?? Di::_()->get('PropagateProperties');
}
/**
......@@ -90,7 +86,7 @@ class Manager
}
$this->saveEntity($entity, $moderator, $time);
$this->propogateProperties->from($entity);
$this->propagateProperties->from($entity);
}
private function saveEntity(
......
......@@ -2,23 +2,25 @@
namespace Minds\Core\Media\Delegates;
use Minds\Core\Entities\Propogator\Properties;
use Minds\Core\Entities\Propagator\Properties;
use Minds\Entities\Activity;
class PropogateProperties extends Properties
class PropagateProperties extends Properties
{
protected $actsOnType = 'object';
protected $actsOnSubtype = ['image', 'video'];
public function toActivity($from, Activity &$to): void
{
if ($this->valueHasChanged($from->title, $to->getMessage()))
if ($this->valueHasChanged($from->title, $to->getMessage())) {
$to->setMessage($from->title);
}
$fromData = $from->getActivityParameters();
$toData = $to->getCustom();
if ($this->valueHasChanged($fromData[1], $toData[1]))
if ($this->valueHasChanged($fromData[1], $toData[1])) {
$to->setCustom($fromData[0], $fromData[1]);
}
}
public function fromActivity(Activity $from, &$to): void
......
......@@ -9,11 +9,11 @@ use Minds\Helpers;
class Feeds
{
protected $entity;
protected $propogateProperties;
protected $propagateProperties;
public function __construct(Core\Entities\PropogateProperties $propogateProperties = null)
public function __construct(Core\Entities\PropagateProperties $propagateProperties = null)
{
$this->propogateProperties = $propogateProperties ?? Core\Di\Di::_()->get('PropogateProperties');
$this->propagateProperties = $propagateProperties ?? Core\Di\Di::_()->get('PropagateProperties');
}
public function setEntity($entity)
......@@ -52,7 +52,7 @@ class Feeds
throw new \Exception('Entity not set');
}
$this->propogateProperties->from($this->entity);
$this->propagateProperties->from($this->entity);
}
public function dispatch(array $targets = [])
......
<?php
namespace Minds\Core\Permissions;
namespace Minds\Core\Permissions\Delegates;
use Minds\Core\Entities\Propogator\Properties;
use Minds\Core\Entities\Propagator\Properties;
use Minds\Entities\Activity;
class PropogateProperties extends Properties
class PropagateProperties extends Properties
{
public function toActivity($from, Activity &$to): void
{
if ($this->valueHasChanged($from->getAllowComments(), $to->getAllowComments()))
if ($this->valueHasChanged($from->getAllowComments(), $to->getAllowComments())) {
$to->setAllowComments($from->getAllowComments());
}
}
public function fromActivity(Activity $from, &$to): void
{
if ($this->valueHasChanged($from->getAllowComments(), $to->getAllowComments()))
if ($this->valueHasChanged($from->getAllowComments(), $to->getAllowComments())) {
$to->setAllowComments($from->getAllowComments());
}
}
}
......@@ -4,22 +4,23 @@ namespace Minds\Core\Permissions;
use Minds\Core\Di\Di;
use Minds\Core\Entities\Actions\Save;
use Minds\Core\Entities\PropagateProperties;
use Minds\Exceptions\StopEventException;
class Manager
{
/** @var Save */
protected $save;
/** @var \Minds\Core\Entities\PropogateProperties */
protected $propogateProperties;
/** @var PropagateProperties */
protected $propagateProperties;
public function __construct(
Save $save = null,
\Minds\Core\Entities\PropogateProperties $propogateProperties = null
PropagateProperties $propagateProperties = null
)
{
$this->save = $save ?: new Save();
$this->propogateProperties = $propogateProperties ?? Di::_()->get('PropogateProperties');
$this->propagateProperties = $propagateProperties ?? Di::_()->get('PropagateProperties');
}
......@@ -37,6 +38,6 @@ class Manager
->setEntity($entity)
->save();
$this->propogateProperties->from($entity);
$this->propagateProperties->from($entity);
}
}
......@@ -23,8 +23,8 @@ class EntitiesProvider extends Provider
$this->di->bind('Entities\Factory', function ($di) {
return new EntitiesFactory();
}, ['useFactory' => true]);
$this->di->bind('PropogateProperties', function ($di) {
return new Entities\PropogateProperties();
$this->di->bind('PropagateProperties', function ($di) {
return new Entities\PropagateProperties();
}, ['useFactory' => true]);
}
}
......@@ -5,6 +5,7 @@ namespace Spec\Minds\Core\Blogs;
use Minds\Core\Blogs\Blog;
use Minds\Core\Blogs\Delegates;
use Minds\Core\Blogs\Repository;
use Minds\Core\Entities\PropagateProperties;
use Minds\Core\Security\Spam;
use PhpSpec\ObjectBehavior;
......@@ -30,13 +31,16 @@ class ManagerSpec extends ObjectBehavior
/** @var Delegates\Search */
protected $search;
protected $propagateProperties;
public function let(
Repository $repository,
Delegates\PaywallReview $paywallReview,
Delegates\Slug $slug,
Delegates\Feeds $feeds,
Spam $spam,
Delegates\Search $search
Delegates\Search $search,
PropagateProperties $propagateProperties
) {
$this->beConstructedWith(
$repository,
......@@ -44,7 +48,8 @@ class ManagerSpec extends ObjectBehavior
$slug,
$feeds,
$spam,
$search
$search,
$propagateProperties
);
$this->repository = $repository;
......@@ -53,6 +58,7 @@ class ManagerSpec extends ObjectBehavior
$this->feeds = $feeds;
$this->spam = $spam;
$this->search = $search;
$this->propagateProperties = $propagateProperties;
}
public function it_is_initializable()
......@@ -240,6 +246,7 @@ class ManagerSpec extends ObjectBehavior
->shouldBeCalled()
->willReturn(true);
$this->propagateProperties->from($blog)->shouldBeCalled();
$this
->update($blog)
->shouldReturn(true);
......
......@@ -2,6 +2,7 @@
namespace Spec\Minds\Core\Feeds\Firehose;
use Minds\Core\Entities\PropagateProperties;
use PhpSpec\ObjectBehavior;
use Minds\Entities\User;
use Minds\Core\Feeds\Firehose\Manager;
......@@ -25,12 +26,10 @@ class ManagerSpec extends ObjectBehavior
protected $topFeedsManager;
/** @var ModerationCache */
protected $moderationCache;
/** @var EntitiesBuilder */
protected $entitiesBuilder;
/** @var Call */
protected $db;
/** @var Save */
protected $save;
/** @var PropagateProperties */
protected $propagateProperties;
protected $guids = [
'968599624820461570', '966142563226488850', '966145446911152135',
......@@ -43,25 +42,22 @@ class ManagerSpec extends ObjectBehavior
User $user,
TopFeedsManager $topFeedsManager,
ModerationCache $moderationCache,
EntitiesBuilder $entitiesBuilder,
Call $db,
Save $save
Save $save,
PropagateProperties $propagateProperties
) {
$this->user = $user;
$this->topFeedsManager = $topFeedsManager;
$this->moderationCache = $moderationCache;
$this->entitiesBuilder = $entitiesBuilder;
$this->db = $db;
$this->save = $save;
$this->propagateProperties = $propagateProperties;
$this->user->getGUID()->willReturn(123);
$this->beConstructedWith(
$this->topFeedsManager,
$this->moderationCache,
$this->entitiesBuilder,
$this->db,
$this->save
$this->save,
$this->propagateProperties
);
}
......@@ -77,10 +73,10 @@ class ManagerSpec extends ObjectBehavior
$response = new Response($activities);
$this->topFeedsManager->getList([
'moderation_user' => $this->user,
'exclude_moderated' => true,
'moderation_reservations' => null,
])
'moderation_user' => $this->user,
'exclude_moderated' => true,
'moderation_reservations' => null,
])
->shouldBeCalled()
->willReturn($response);
......@@ -112,89 +108,22 @@ class ManagerSpec extends ObjectBehavior
'exclude_moderated' => true,
'moderation_reservations' => null,
])
->shouldBeCalled()
->willReturn($response);
->shouldBeCalled()
->willReturn($response);
$this->getList()->shouldBeLike($response->map(function ($entity) {
return $entity->getEntity();
}));
}
public function it_should_save_moderated_activites(Entity $activity)
{
$time = time();
$this->db->getRow('activity:entitylink:1')->shouldBeCalled()->willReturn([]);
$activity->getType()->shouldBeCalled()->willReturn('activity');
$activity->get('entity_guid')->shouldBeCalled()->willReturn(false);
$activity->getGUID()->shouldBeCalled()->willReturn(1);
$activity->setModeratorGuid('123')->shouldBeCalled();
$activity->setTimeModerated($time)->shouldBeCalled();
$this->save->setEntity($activity)->shouldBeCalled()->willReturn($this->save);
$this->save->save()->shouldBeCalled();
$this->save($activity, $this->user, $time);
}
public function it_should_save_reported_activites(Entity $activity)
public function it_should_save_and_propogate(Entity $activity)
{
$time = time();
$this->db->getRow('activity:entitylink:1')->shouldBeCalled()->willReturn([]);
$activity->getType()->shouldBeCalled()->willReturn('activity');
$activity->get('entity_guid')->shouldBeCalled()->willReturn(false);
$activity->getGUID()->shouldBeCalled()->willReturn(1);
$activity->setTimeModerated($time)->shouldBeCalled();
$activity->setModeratorGuid('123')->shouldBeCalled();
$this->save->setEntity($activity)->shouldBeCalled()->willReturn($this->save);
$this->save->save()->shouldBeCalled();
$this->save($activity, $this->user, $time);
}
public function it_should_save_an_attachment(Entity $activity, Image $image)
{
$time = time();
$image->setModeratorGuid(123)->shouldBeCalled();
$image->setTimeModerated($time)->shouldBeCalled();
$this->db->getRow('activity:entitylink:1')->shouldBeCalled()->willReturn([]);
$this->entitiesBuilder->single(1)->shouldBeCalled()->willReturn($image);
$activity->getType()->shouldBeCalled()->willReturn('activity');
$activity->get('entity_guid')->shouldBeCalled()->willReturn(1);
$activity->getGUID()->shouldBeCalled()->willReturn(1);
$activity->setTimeModerated($time)->shouldBeCalled();
$activity->setModeratorGuid(123)->shouldBeCalled();
$this->save->setEntity($activity)->shouldBeCalled()->willReturn($this->save);
$this->save->setEntity($image)->shouldBeCalled()->willReturn($this->save);
$this->save->save()->shouldBeCalled();
$this->save($activity, $this->user, $time);
}
public function it_should_save_a_blog(Blog $blog)
{
$time = time();
$this->db->getRow('activity:entitylink:1')->shouldBeCalled()->willReturn([]);
$blog->getType()->shouldBeCalled()->willReturn('object');
$blog->getGuid()->shouldBeCalled()->willReturn(1);
$blog->setTimeModerated($time)->shouldBeCalled();
$blog->setModeratorGuid('123')->shouldBeCalled();
$this->save->save()->shouldBeCalled();
$this->save->setEntity($blog)->shouldBeCalled()->willReturn($this->save);
$this->save($blog, $this->user, $time);
}
public function it_should_save_a_linked_entity(Entity $activity, Entity $parent)
{
$time = time();
$parent->setTimeModerated($time)->shouldBeCalled();
$parent->setModeratorGuid('123')->shouldBeCalled();
$this->db->getRow('activity:entitylink:1')->shouldBeCalled()
->willReturn([2 => $parent]);
$this->entitiesBuilder->single(2)->shouldBeCalled()->willReturn($parent);
$activity->getType()->shouldBeCalled()->willReturn('activity');
$activity->get('entity_guid')->shouldBeCalled()->willReturn(false);
$activity->getGUID()->shouldBeCalled()->willReturn(1);
$activity->setTimeModerated($time)->shouldBeCalled();
$activity->setModeratorGuid('123')->shouldBeCalled();
$this->save->setEntity($activity)->shouldBeCalled()->willReturn($this->save);
$this->save->setEntity($parent)->shouldBeCalled()->willReturn($this->save);
$this->save->save()->shouldBeCalled();
$this->propagateProperties->from($activity)->shouldBeCalled();
$this->save($activity, $this->user, $time);
}
......
......@@ -2,12 +2,11 @@
namespace Spec\Minds\Core\Permissions;
use Minds\Core\Entities\PropagateProperties;
use Minds\Core\Permissions\Manager;
use Minds\Core\Permissions\Permissions;
use Minds\Entities\User;
use PhpSpec\ObjectBehavior;
use Minds\Core\EntitiesBuilder;
use Minds\Core\Data\Call;
use Minds\Core\Entities\Actions\Save;
use Minds\Entities\Entity;
use Minds\Entities\Image;
......@@ -16,22 +15,18 @@ class ManagerSpec extends ObjectBehavior
{
/** @var User */
protected $user;
/** @var EntitiesBuilder */
protected $entitiesBuilder;
/** @var Call */
protected $db;
/** @var Save */
protected $save;
/** @var PropagateProperties */
protected $propagateProperties;
public function let(
EntitiesBuilder $entitiesBuilder,
Call $db,
Save $save
Save $save,
PropagateProperties $propagateProperties
) {
$this->entitiesBuilder = $entitiesBuilder;
$this->db = $db;
$this->save = $save;
$this->beConstructedWith($this->entitiesBuilder, $this->db, $this->save);
$this->propagateProperties = $propagateProperties;
$this->beConstructedWith($this->save, $this->propagateProperties);
}
public function it_is_initializable()
......@@ -43,46 +38,9 @@ class ManagerSpec extends ObjectBehavior
{
$permissions = new Permissions();
$entity->setAllowComments(true)->shouldBeCalled();
$entity->get('entity_guid')->shouldBeCalled()->willReturn(false);
$entity->getGUID()->shouldBeCalled()->willReturn(1);
$entity->getType()->shouldBeCalled()->willReturn('activity');
$this->db->getRow('activity:entitylink:1')->shouldBeCalled()->willReturn([]);
$this->save->setEntity($entity)->shouldBeCalled()->willReturn($this->save);
$this->save->save()->shouldBeCalled();
$this->save($entity, $permissions);
}
public function it_should_save_attachment_permissions(Entity $entity, Image $image)
{
$permissions = new Permissions();
$image->setAllowComments(true)->shouldBeCalled();
$this->entitiesBuilder->single(1)->shouldBeCalled()->willReturn($image);
$entity->setAllowComments(true)->shouldBeCalled();
$entity->getGUID()->shouldBeCalled()->willReturn(1);
$entity->getType()->shouldBeCalled()->willReturn('activity');
$entity->get('entity_guid')->shouldBeCalled()->willReturn(1);
$this->db->getRow('activity:entitylink:1')->shouldBeCalled()->willReturn([]);
$this->save->setEntity($entity)->shouldBeCalled()->willReturn($this->save);
$this->save->setEntity($image)->shouldBeCalled()->willReturn($this->save);
$this->save->save()->shouldBeCalled();
$this->save($entity, $permissions);
}
public function it_should_save_linked_entity_permissions(Entity $entity, Entity $parent)
{
$permissions = new Permissions();
$parent->setAllowComments(true)->shouldBeCalled();
$this->db->getRow('activity:entitylink:1')->shouldBeCalled()
->willReturn([2 => $parent]);
$this->entitiesBuilder->single(1)->shouldBeCalled()->willReturn($parent);
$entity->setAllowComments(true)->shouldBeCalled();
$entity->getGUID()->shouldBeCalled()->willReturn(1);
$entity->getType()->shouldBeCalled()->willReturn('activity');
$entity->get('entity_guid')->shouldBeCalled()->willReturn(1);
$this->db->getRow('activity:entitylink:1')->shouldBeCalled()->willReturn([]);
$this->save->setEntity($entity)->shouldBeCalled()->willReturn($this->save);
$this->save->setEntity($parent)->shouldBeCalled()->willReturn($this->save);
$this->save->save()->shouldBeCalled();
$this->propagateProperties->from($entity)->shouldBeCalled();
$this->save($entity, $permissions);
}
}