Skip to content
Next
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
295
Merge Requests
40
CI / CD
Security & Compliance
Packages
Wiki
Snippets
Members
Collapse sidebar
Close sidebar
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Minds
Minds Backend - Engine
Commits
4a0642ef
Commit
4a0642ef
authored
44 minutes ago
by
Ben Hayward
Browse files
Options
Download
Adding tests
parent
4251ac5a
fix/spam-detection-return-1104
1 merge request
!391
[Sprint/RollingRabbit](fix): Updated returned exception of offending spam link. #1104
Pipeline
#94695687
failed with stages
in 2 minutes and 32 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
150 additions
and
0 deletions
+150
-0
Spec/Core/Security/SpamSpec.php
0 → 100644
View file @
4a0642ef
<?php
namespace
Spec\Minds\Core\Security
;
use
PhpSpec\ObjectBehavior
;
use
Prophecy\Argument
;
use
Minds\Core\Blogs\Blog
;
use
Minds\Core\Config
;
use
Minds\Core\Comments\Comment
;
use
Minds\Entities\User
;
use
Minds\Entities\Group
;
use
Minds\Entities\Entity
;
class
SpamSpec
extends
ObjectBehavior
{
public
function
it_is_initializable
()
{
$this
->
shouldHaveType
(
'Minds\Core\Security\Spam'
);
}
public
function
it_should_detect_spam_in_a_blog
(
Blog
$blog
,
Config
$config
)
{
$config
->
get
(
'prohibited_domains'
)
->
shouldBeCalled
()
->
willReturn
([
'bit.ly'
]);
$this
->
beConstructedWith
(
$config
);
$blog
->
getBody
()
->
shouldBeCalled
()
->
willReturn
(
'test bit.ly test'
);
$blog
->
getType
()
->
shouldBeCalled
()
->
willReturn
(
'object'
);
$blog
->
getSubtype
()
->
shouldBeCalled
()
->
willReturn
(
'blog'
);
$this
->
shouldThrow
(
new
\Exception
(
"Sorry, you included a reference to a domain name linked to spam (bit.ly)"
))
->
duringCheck
(
$blog
);
}
public
function
it_should_detect_spam_in_a_comment
(
Comment
$comment
,
Config
$config
)
{
$config
->
get
(
'prohibited_domains'
)
->
shouldBeCalled
()
->
willReturn
([
'bit.ly'
]);
$this
->
beConstructedWith
(
$config
);
$comment
=
new
Comment
();
$comment
->
setBody
(
'test bit.ly test'
);
$comment
->
setType
(
'comment'
);
$this
->
shouldThrow
(
new
\Exception
(
"Sorry, you included a reference to a domain name linked to spam (bit.ly)"
))
->
duringCheck
(
$comment
);
}
public
function
it_should_detect_spam_in_a_user
(
User
$user
,
Config
$config
)
{
$config
->
get
(
'prohibited_domains'
)
->
shouldBeCalled
()
->
willReturn
([
'bit.ly'
]);
$this
->
beConstructedWith
(
$config
);
$user
=
new
User
(
'123'
);
$user
[
'briefdescription'
]
=
'test bit.ly test'
;
$user
[
'type'
]
=
'user'
;
$this
->
shouldThrow
(
new
\Exception
(
"Sorry, you included a reference to a domain name linked to spam (bit.ly)"
))
->
duringCheck
(
$user
);
}
public
function
it_should_detect_spam_in_a_group
(
Group
$group
,
Config
$config
)
{
$config
->
get
(
'prohibited_domains'
)
->
shouldBeCalled
()
->
willReturn
([
'bit.ly'
]);
$this
->
beConstructedWith
(
$config
);
$group
=
new
Group
();
$group
->
setBriefdescription
(
'test bit.ly test'
);
$group
->
setType
(
'group'
);
$this
->
shouldThrow
(
new
\Exception
(
"Sorry, you included a reference to a domain name linked to spam (bit.ly)"
))
->
duringCheck
(
$group
);
}
public
function
it_should_detect_NO_spam_in_a_blog
(
Blog
$blog
,
Config
$config
)
{
$config
->
get
(
'prohibited_domains'
)
->
shouldBeCalled
()
->
willReturn
([
'bit.ly'
]);
$this
->
beConstructedWith
(
$config
);
$blog
->
getBody
()
->
shouldBeCalled
()
->
willReturn
(
'test bit.nospam test'
);
$blog
->
getType
()
->
shouldBeCalled
()
->
willReturn
(
'object'
);
$blog
->
getSubtype
()
->
shouldBeCalled
()
->
willReturn
(
'blog'
);
$this
->
check
(
$blog
)
->
shouldReturn
(
false
);
}
public
function
it_should_detect_NO_spam_in_a_comment
(
Comment
$comment
,
Config
$config
)
{
$config
->
get
(
'prohibited_domains'
)
->
shouldBeCalled
()
->
willReturn
([
'bit.ly'
]);
$this
->
beConstructedWith
(
$config
);
$comment
=
new
Comment
();
$comment
->
setBody
(
'test bit.nospam test'
);
$comment
->
setType
(
'comment'
);
$this
->
check
(
$comment
)
->
shouldReturn
(
false
);
}
public
function
it_should_detect_NO_spam_in_a_user
(
User
$user
,
Config
$config
)
{
$config
->
get
(
'prohibited_domains'
)
->
shouldBeCalled
()
->
willReturn
([
'bit.ly'
]);
$this
->
beConstructedWith
(
$config
);
$user
=
new
User
(
'123'
);
$user
[
'briefdescription'
]
=
'test bit.nospam test'
;
$user
[
'type'
]
=
'user'
;
$this
->
check
(
$user
)
->
shouldReturn
(
false
);
}
public
function
it_should_detect_NO_spam_in_a_group
(
Group
$group
,
Config
$config
)
{
$config
->
get
(
'prohibited_domains'
)
->
shouldBeCalled
()
->
willReturn
([
'bit.ly'
]);
$this
->
beConstructedWith
(
$config
);
$group
=
new
Group
();
$group
->
setBriefdescription
(
'test bit.nospam test'
);
$group
->
setType
(
'group'
);
$this
->
check
(
$group
)
->
shouldReturn
(
false
);
}
}
This diff is collapsed.
Please
register
or
sign in
to comment