Skip to content
Next
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Minds Backend - Engine
Project
Project
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
241
Issues
241
List
Boards
Labels
Service Desk
Milestones
Merge Requests
31
Merge Requests
31
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
List
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Minds
Minds Backend - Engine
Compare Revisions
d720d192a39f20648b46d75c7c71a8fcb895875f...12402bb2d85fe3b4e0e3968de669ec96bbc05e7d
Source
12402bb2d85fe3b4e0e3968de669ec96bbc05e7d
Select Git revision
...
Target
d720d192a39f20648b46d75c7c71a8fcb895875f
Select Git revision
Compare
Commits (3)
(chore) Linting new PropogateProperties classes -
#616
· 4ad8b92c
Guy Thouret
authored
1 hour ago
4ad8b92c
(fix) Typo changing all instances propogate -> propagate -
#616
· 980d6ed4
Guy Thouret
authored
2 minutes ago
980d6ed4
(fix) Regeressions in existing spec tests -
#616
· 12402bb2
Guy Thouret
authored
1 minute ago
12402bb2
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
126 additions
and
218 deletions
+126
-218
PropagateProperties.php
Core/Blogs/Delegates/PropagateProperties.php
+2
-2
Manager.php
Core/Blogs/Manager.php
+7
-7
PropagateProperties.php
Core/Entities/Delegates/PropagateProperties.php
+10
-6
PropagateProperties.php
Core/Entities/PropagateProperties.php
+31
-26
Properties.php
Core/Entities/Propagator/Properties.php
+1
-1
PropagateProperties.php
Core/Feeds/Delegates/PropagateProperties.php
+10
-6
Manager.php
Core/Feeds/Firehose/Manager.php
+7
-11
PropagateProperties.php
Core/Media/Delegates/PropagateProperties.php
+6
-4
Feeds.php
Core/Media/Feeds.php
+4
-4
PropagateProperties.php
Core/Permissions/Delegates/PropagateProperties.php
+7
-5
Manager.php
Core/Permissions/Manager.php
+6
-5
EntitiesProvider.php
Entities/EntitiesProvider.php
+2
-2
ManagerSpec.php
Spec/Core/Blogs/ManagerSpec.php
+9
-2
ManagerSpec.php
Spec/Core/Feeds/Firehose/ManagerSpec.php
+16
-87
ManagerSpec.php
Spec/Core/Permissions/ManagerSpec.php
+8
-50
No files found.
Core/Blogs/Delegates/Prop
o
gateProperties.php
→
Core/Blogs/Delegates/Prop
a
gateProperties.php
View file @
12402bb2
...
...
@@ -2,10 +2,10 @@
namespace
Minds\Core\Blogs\Delegates
;
use
Minds\Core\Entities\Prop
o
gator\Properties
;
use
Minds\Core\Entities\Prop
a
gator\Properties
;
use
Minds\Entities\Activity
;
class
Prop
o
gateProperties
extends
Properties
class
Prop
a
gateProperties
extends
Properties
{
protected
$actsOnSubtype
=
'blog'
;
...
...
This diff is collapsed.
Click to expand it.
Core/Blogs/Manager.php
View file @
12402bb2
...
...
@@ -9,7 +9,7 @@
namespace
Minds\Core\Blogs
;
use
Minds\Core\Di\Di
;
use
Minds\Core\Entities\Prop
o
gateProperties
;
use
Minds\Core\Entities\Prop
a
gateProperties
;
use
Minds\Core\Security\Spam
;
class
Manager
...
...
@@ -32,8 +32,8 @@ class Manager
/** @var Delegates\Search */
protected
$search
;
/** @var Prop
o
gateProperties */
protected
$prop
o
gateProperties
;
/** @var Prop
a
gateProperties */
protected
$prop
a
gateProperties
;
/**
* Manager constructor.
...
...
@@ -43,7 +43,7 @@ class Manager
* @param null $feeds
* @param null $spam
* @param null $search
* @param Prop
ogateProperties $propo
gateProperties
* @param Prop
agateProperties $propa
gateProperties
* @throws \Exception
*/
public
function
__construct
(
...
...
@@ -53,7 +53,7 @@ class Manager
$feeds
=
null
,
$spam
=
null
,
$search
=
null
,
Prop
ogateProperties
$propo
gateProperties
=
null
Prop
agateProperties
$propa
gateProperties
=
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
->
prop
ogateProperties
=
$propogateProperties
??
Di
::
_
()
->
get
(
'Propo
gateProperties'
);
$this
->
prop
agateProperties
=
$propagateProperties
??
Di
::
_
()
->
get
(
'Propa
gateProperties'
);
}
/**
...
...
@@ -177,7 +177,7 @@ class Manager
}
$this
->
paywallReview
->
queue
(
$blog
);
$this
->
prop
o
gateProperties
->
from
(
$blog
);
$this
->
prop
a
gateProperties
->
from
(
$blog
);
}
return
$saved
;
...
...
This diff is collapsed.
Click to expand it.
Core/Entities/Delegates/Prop
o
gateProperties.php
→
Core/Entities/Delegates/Prop
a
gateProperties.php
View file @
12402bb2
...
...
@@ -2,26 +2,30 @@
namespace
Minds\Core\Entities\Delegates
;
use
Minds\Core\Entities\Prop
o
gator\Properties
;
use
Minds\Core\Entities\Prop
a
gator\Properties
;
use
Minds\Entities\Activity
;
class
Prop
o
gateProperties
extends
Properties
class
Prop
a
gateProperties
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
());
}
}
}
This diff is collapsed.
Click to expand it.
Core/Entities/Prop
o
gateProperties.php
→
Core/Entities/Prop
a
gateProperties.php
View file @
12402bb2
...
...
@@ -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\Prop
o
gator\Properties
;
use
Minds\Core\Entities\Prop
a
gator\Properties
;
use
Minds\Core\EntitiesBuilder
;
use
Minds\Entities\Activity
;
use
Minds\Core
;
class
Prop
o
gateProperties
class
Prop
a
gateProperties
{
/** @var Properties[] */
protected
$prop
o
gators
;
protected
$prop
a
gators
;
/** @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
->
registerProp
o
gators
();
$this
->
registerProp
a
gators
();
}
protected
function
registerProp
o
gators
()
:
void
protected
function
registerProp
a
gators
()
:
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
addProp
o
gator
(
string
$class
)
:
void
protected
function
addProp
a
gator
(
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
->
prop
o
gators
[]
=
$obj
;
$this
->
prop
a
gators
[]
=
$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
->
prop
ogators
as
$propo
gator
)
{
if
(
$prop
o
gator
->
willActOnEntity
(
$attachment
))
{
$prop
o
gator
->
fromActivity
(
$activity
,
$attachment
);
$this
->
changed
|=
$prop
o
gator
->
changed
();
foreach
(
$this
->
prop
agators
as
$propa
gator
)
{
if
(
$prop
a
gator
->
willActOnEntity
(
$attachment
))
{
$prop
a
gator
->
fromActivity
(
$activity
,
$attachment
);
$this
->
changed
|=
$prop
a
gator
->
changed
();
}
}
...
...
@@ -79,7 +84,7 @@ class PropogateProperties
{
$activities
=
$this
->
getActivitiesForEntity
(
$entity
->
getGuid
());
foreach
(
$activities
as
$activity
)
{
$this
->
prop
o
gateToActivity
(
$entity
,
$activity
);
$this
->
prop
a
gateToActivity
(
$entity
,
$activity
);
if
(
$this
->
changed
)
{
$this
->
save
->
setEntity
(
$activity
)
->
save
();
}
...
...
@@ -101,13 +106,13 @@ class PropogateProperties
return
$activities
;
}
public
function
prop
o
gateToActivity
(
$entity
,
Activity
&
$activity
)
:
void
public
function
prop
a
gateToActivity
(
$entity
,
Activity
&
$activity
)
:
void
{
$this
->
changed
=
false
;
foreach
(
$this
->
prop
ogators
as
$propo
gator
)
{
if
(
$prop
o
gator
->
willActOnEntity
(
$entity
))
{
$prop
o
gator
->
toActivity
(
$entity
,
$activity
);
$this
->
changed
|=
$prop
o
gator
->
changed
();
foreach
(
$this
->
prop
agators
as
$propa
gator
)
{
if
(
$prop
a
gator
->
willActOnEntity
(
$entity
))
{
$prop
a
gator
->
toActivity
(
$entity
,
$activity
);
$this
->
changed
|=
$prop
a
gator
->
changed
();
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Core/Entities/Prop
o
gator/Properties.php
→
Core/Entities/Prop
a
gator/Properties.php
View file @
12402bb2
<?php
namespace
Minds\Core\Entities\Prop
o
gator
;
namespace
Minds\Core\Entities\Prop
a
gator
;
use
Minds\Entities\Activity
;
...
...
This diff is collapsed.
Click to expand it.
Core/Feeds/Delegates/Prop
o
gateProperties.php
→
Core/Feeds/Delegates/Prop
a
gateProperties.php
View file @
12402bb2
...
...
@@ -2,26 +2,30 @@
namespace
Minds\Core\Feeds\Delegates
;
use
Minds\Core\Entities\Prop
o
gator\Properties
;
use
Minds\Core\Entities\Prop
a
gator\Properties
;
use
Minds\Entities\Activity
;
class
Prop
o
gateProperties
extends
Properties
class
Prop
a
gateProperties
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
());
}
}
}
This diff is collapsed.
Click to expand it.
Core/Feeds/Firehose/Manager.php
View file @
12402bb2
...
...
@@ -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\Prop
o
gateProperties
;
use
Minds\Core\Entities\Prop
a
gateProperties
;
class
Manager
{
...
...
@@ -20,19 +16,19 @@ class Manager
protected
$moderationCache
;
/** @var Save */
protected
$save
;
/** @var Prop
o
gateProperties */
protected
$prop
o
gateProperties
;
/** @var Prop
a
gateProperties */
protected
$prop
a
gateProperties
;
public
function
__construct
(
TopFeedsManager
$topFeedsManager
=
null
,
ModerationCache
$moderationCache
=
null
,
Save
$save
=
null
,
Prop
ogateProperties
$propo
gateProperties
=
null
Prop
agateProperties
$propa
gateProperties
=
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
->
prop
ogateProperties
=
$propogateProperties
??
Di
::
_
()
->
get
(
'Propo
gateProperties'
);
$this
->
save
=
$save
?:
new
Save
();
$this
->
prop
agateProperties
=
$propagateProperties
??
Di
::
_
()
->
get
(
'Propa
gateProperties'
);
}
/**
...
...
@@ -90,7 +86,7 @@ class Manager
}
$this
->
saveEntity
(
$entity
,
$moderator
,
$time
);
$this
->
prop
o
gateProperties
->
from
(
$entity
);
$this
->
prop
a
gateProperties
->
from
(
$entity
);
}
private
function
saveEntity
(
...
...
This diff is collapsed.
Click to expand it.
Core/Media/Delegates/Prop
o
gateProperties.php
→
Core/Media/Delegates/Prop
a
gateProperties.php
View file @
12402bb2
...
...
@@ -2,23 +2,25 @@
namespace
Minds\Core\Media\Delegates
;
use
Minds\Core\Entities\Prop
o
gator\Properties
;
use
Minds\Core\Entities\Prop
a
gator\Properties
;
use
Minds\Entities\Activity
;
class
Prop
o
gateProperties
extends
Properties
class
Prop
a
gateProperties
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
...
...
This diff is collapsed.
Click to expand it.
Core/Media/Feeds.php
View file @
12402bb2
...
...
@@ -9,11 +9,11 @@ use Minds\Helpers;
class
Feeds
{
protected
$entity
;
protected
$prop
o
gateProperties
;
protected
$prop
a
gateProperties
;
public
function
__construct
(
Core\Entities\Prop
ogateProperties
$propo
gateProperties
=
null
)
public
function
__construct
(
Core\Entities\Prop
agateProperties
$propa
gateProperties
=
null
)
{
$this
->
prop
ogateProperties
=
$propogateProperties
??
Core\Di\Di
::
_
()
->
get
(
'Propo
gateProperties'
);
$this
->
prop
agateProperties
=
$propagateProperties
??
Core\Di\Di
::
_
()
->
get
(
'Propa
gateProperties'
);
}
public
function
setEntity
(
$entity
)
...
...
@@ -52,7 +52,7 @@ class Feeds
throw
new
\Exception
(
'Entity not set'
);
}
$this
->
prop
o
gateProperties
->
from
(
$this
->
entity
);
$this
->
prop
a
gateProperties
->
from
(
$this
->
entity
);
}
public
function
dispatch
(
array
$targets
=
[])
...
...
This diff is collapsed.
Click to expand it.
Core/Permissions/Delegates/Prop
o
gateProperties.php
→
Core/Permissions/Delegates/Prop
a
gateProperties.php
View file @
12402bb2
<?php
namespace
Minds\Core\Permissions
;
namespace
Minds\Core\Permissions
\Delegates
;
use
Minds\Core\Entities\Prop
o
gator\Properties
;
use
Minds\Core\Entities\Prop
a
gator\Properties
;
use
Minds\Entities\Activity
;
class
Prop
o
gateProperties
extends
Properties
class
Prop
a
gateProperties
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
());
}
}
}
This diff is collapsed.
Click to expand it.
Core/Permissions/Manager.php
View file @
12402bb2
...
...
@@ -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\Propo
gateProperties */
protected
$prop
o
gateProperties
;
/** @var
Propa
gateProperties */
protected
$prop
a
gateProperties
;
public
function
__construct
(
Save
$save
=
null
,
\Minds\Core\Entities\PropogateProperties
$propo
gateProperties
=
null
PropagateProperties
$propa
gateProperties
=
null
)
{
$this
->
save
=
$save
?:
new
Save
();
$this
->
prop
ogateProperties
=
$propogateProperties
??
Di
::
_
()
->
get
(
'Propo
gateProperties'
);
$this
->
prop
agateProperties
=
$propagateProperties
??
Di
::
_
()
->
get
(
'Propa
gateProperties'
);
}
...
...
@@ -37,6 +38,6 @@ class Manager
->
setEntity
(
$entity
)
->
save
();
$this
->
prop
o
gateProperties
->
from
(
$entity
);
$this
->
prop
a
gateProperties
->
from
(
$entity
);
}
}
This diff is collapsed.
Click to expand it.
Entities/EntitiesProvider.php
View file @
12402bb2
...
...
@@ -23,8 +23,8 @@ class EntitiesProvider extends Provider
$this
->
di
->
bind
(
'Entities\Factory'
,
function
(
$di
)
{
return
new
EntitiesFactory
();
},
[
'useFactory'
=>
true
]);
$this
->
di
->
bind
(
'Prop
o
gateProperties'
,
function
(
$di
)
{
return
new
Entities\Prop
o
gateProperties
();
$this
->
di
->
bind
(
'Prop
a
gateProperties'
,
function
(
$di
)
{
return
new
Entities\Prop
a
gateProperties
();
},
[
'useFactory'
=>
true
]);
}
}
This diff is collapsed.
Click to expand it.
Spec/Core/Blogs/ManagerSpec.php
View file @
12402bb2
...
...
@@ -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
);
...
...
This diff is collapsed.
Click to expand it.
Spec/Core/Feeds/Firehose/ManagerSpec.php
View file @
12402bb2
...
...
@@ -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
);
}
...
...
This diff is collapsed.
Click to expand it.
Spec/Core/Permissions/ManagerSpec.php
View file @
12402bb2
...
...
@@ -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
);
}
}
This diff is collapsed.
Click to expand it.