Skip to content
Projects
Groups
Snippets
Help
Sign in / Register
Toggle navigation
Minds Backend - Engine
Project overview
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
263
Merge Requests
33
CI / CD
Security & Compliance
Packages
Analytics
Wiki
Snippets
Members
Collapse sidebar
Close sidebar
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Minds
Minds Backend - Engine
Commits
334430f8
Commit
334430f8
authored
23 minutes ago
by
Marcelo Rivera
Browse files
Options
Download
(fix): updated spec tests for Votes\Manager
parent
d5789e17
feat/unverified-users-permissions
1 merge request
!459
Deny write permissions for new unverified users
Pipeline
#115990636
failed with stages
in 12 minutes and 12 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
8 deletions
+47
-8
Spec/Core/Votes/ManagerSpec.php
View file @
334430f8
...
...
@@ -3,7 +3,7 @@
namespace
Spec\Minds\Core\Votes
;
use
Minds\Core\Events\EventsDispatcher
;
use
Minds\Core\
Di\Di
;
use
Minds\Core\
Router\Exceptions\UnverifiedEmailException
;
use
Minds\Core\Security\ACL
;
use
Minds\Core\Votes\Counters
;
use
Minds\Core\Votes\Indexes
;
...
...
@@ -52,6 +52,10 @@ class ManagerSpec extends ObjectBehavior
$vote
->
getActor
()
->
willReturn
(
$user
);
$vote
->
getDirection
()
->
willReturn
(
'up'
);
$this
->
acl
->
write
(
$vote
)
->
shouldBeCalled
()
->
willReturn
(
true
);
$this
->
acl
->
interact
(
$entity
,
$user
,
'voteup'
)
->
shouldBeCalled
()
->
willReturn
(
true
);
...
...
@@ -64,7 +68,7 @@ class ManagerSpec extends ObjectBehavior
->
shouldBeCalled
()
->
willReturn
(
true
);
$this
->
cast
(
$vote
,
[
'events'
=>
false
])
$this
->
cast
(
$vote
,
[
'events'
=>
false
])
->
shouldReturn
(
true
);
}
...
...
@@ -77,6 +81,10 @@ class ManagerSpec extends ObjectBehavior
$vote
->
getActor
()
->
willReturn
(
$user
);
$vote
->
getDirection
()
->
willReturn
(
'up'
);
$this
->
acl
->
write
(
$vote
)
->
shouldBeCalled
()
->
willReturn
(
true
);
$this
->
acl
->
interact
(
$entity
,
$user
,
'voteup'
)
->
shouldBeCalled
()
->
willReturn
(
true
);
...
...
@@ -89,10 +97,22 @@ class ManagerSpec extends ObjectBehavior
->
shouldBeCalled
()
->
willReturn
(
true
);
$this
->
cast
(
$vote
,
[
'events'
=>
true
])
$this
->
cast
(
$vote
,
[
'events'
=>
true
])
->
shouldReturn
(
true
);
}
public
function
it_should_fail_to_cast_a_vote_if_the_user_hasnt_verified_its_email_address
(
Vote
$vote
,
Activity
$entity
,
User
$user
)
{
$this
->
acl
->
write
(
$vote
)
->
shouldBeCalled
()
->
willThrow
(
UnverifiedEmailException
::
class
);
$this
->
shouldThrow
(
UnverifiedEmailException
::
class
)
->
during
(
'cast'
,
[
$vote
,
[
'events'
=>
true
]]);
}
public
function
it_should_throw_during_insert_if_cannot_interact
(
Vote
$vote
,
Activity
$entity
,
...
...
@@ -102,6 +122,10 @@ class ManagerSpec extends ObjectBehavior
$vote
->
getActor
()
->
willReturn
(
$user
);
$vote
->
getDirection
()
->
willReturn
(
'up'
);
$this
->
acl
->
write
(
$vote
)
->
shouldBeCalled
()
->
willReturn
(
true
);
$this
->
acl
->
interact
(
$entity
,
$user
,
'voteup'
)
->
shouldBeCalled
()
->
willReturn
(
false
);
...
...
@@ -113,7 +137,7 @@ class ManagerSpec extends ObjectBehavior
->
shouldNotBeCalled
();
$this
->
shouldThrow
(
new
\Exception
(
'Actor cannot interact with entity'
))
->
duringCast
(
$vote
,
[
'events'
=>
false
]);
->
duringCast
(
$vote
,
[
'events'
=>
false
]);
}
public
function
it_should_cancel
(
...
...
@@ -124,6 +148,10 @@ class ManagerSpec extends ObjectBehavior
$vote
->
getEntity
()
->
willReturn
(
$entity
);
$vote
->
getActor
()
->
willReturn
(
$user
);
$this
->
acl
->
write
(
$vote
)
->
shouldBeCalled
()
->
willReturn
(
true
);
$this
->
counters
->
update
(
$vote
,
-
1
)
->
shouldBeCalled
()
->
willReturn
(
true
);
...
...
@@ -132,7 +160,7 @@ class ManagerSpec extends ObjectBehavior
->
shouldBeCalled
()
->
willReturn
(
true
);
$this
->
cancel
(
$vote
,
[
'events'
=>
false
])
$this
->
cancel
(
$vote
,
[
'events'
=>
false
])
->
shouldReturn
(
true
);
}
...
...
@@ -145,6 +173,9 @@ class ManagerSpec extends ObjectBehavior
$vote
->
getActor
()
->
willReturn
(
$user
);
$vote
->
getDirection
()
->
willReturn
(
'up'
);
$this
->
acl
->
write
(
$vote
)
->
shouldBeCalled
()
->
willReturn
(
true
);
$this
->
dispatcher
->
trigger
(
'vote:action:cancel'
,
Argument
::
any
(),
[
'vote'
=>
$vote
],
null
)
->
shouldBeCalled
()
...
...
@@ -154,7 +185,7 @@ class ManagerSpec extends ObjectBehavior
->
shouldBeCalled
()
->
willReturn
(
true
);
$this
->
cancel
(
$vote
,
[
'events'
=>
true
])
$this
->
cancel
(
$vote
,
[
'events'
=>
true
])
->
shouldReturn
(
true
);
}
...
...
@@ -199,6 +230,10 @@ class ManagerSpec extends ObjectBehavior
$vote
->
getActor
()
->
willReturn
(
$user
);
$vote
->
getDirection
()
->
willReturn
(
'up'
);
$this
->
acl
->
write
(
$vote
)
->
shouldBeCalled
()
->
willReturn
(
true
);
$this
->
acl
->
interact
(
$entity
,
$user
,
'voteup'
)
->
shouldBeCalled
()
->
willReturn
(
true
);
...
...
@@ -215,7 +250,7 @@ class ManagerSpec extends ObjectBehavior
->
shouldBeCalled
()
->
willReturn
(
true
);
$this
->
toggle
(
$vote
,
[
'events'
=>
false
])
$this
->
toggle
(
$vote
,
[
'events'
=>
false
])
->
shouldReturn
(
true
);
}
...
...
@@ -227,6 +262,10 @@ class ManagerSpec extends ObjectBehavior
$vote
->
getEntity
()
->
willReturn
(
$entity
);
$vote
->
getActor
()
->
willReturn
(
$user
);
$this
->
acl
->
write
(
$vote
)
->
shouldBeCalled
()
->
willReturn
(
true
);
$this
->
indexes
->
exists
(
$vote
)
->
shouldBeCalled
()
->
willReturn
(
true
);
...
...
@@ -243,7 +282,7 @@ class ManagerSpec extends ObjectBehavior
->
shouldBeCalled
()
->
willReturn
(
true
);
$this
->
toggle
(
$vote
,
[
'events'
=>
false
])
$this
->
toggle
(
$vote
,
[
'events'
=>
false
])
->
shouldReturn
(
true
);
}
}
This diff is collapsed.
Please
register
or
sign in
to comment