Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
EntityResourceValidationTraitTestClass example
/** * @group rest * @coversDefaultClass \Drupal\rest\Plugin\rest\resource\EntityResourceValidationTrait */
class
EntityResourceValidationTraitTest
extends
UnitTestCase
{
/** * @covers ::validate */
public
function
testValidate
(
)
{
$trait
=
new
EntityResourceValidationTraitTestClass
(
)
;
$method
=
new
\
ReflectionMethod
(
$trait
, 'validate'
)
;
$violations
=
$this
->
prophesize
(
EntityConstraintViolationList::
class
)
;
$violations
->
filterByFieldAccess
(
)
->
shouldBeCalled
(
)
->
willReturn
(
[
]
)
;
$violations
->
count
(
)
->
shouldBeCalled
(
)
->
willReturn
(
0
)
;
$entity
=
$this
->
prophesize
(
Node::
class
)
;
$entity
->
validate
(
)
->
shouldBeCalled
(
)
->
willReturn
(
$violations
->
reveal
(
)
)
;
$method
->
invoke
(
$trait
,
$entity
->
reveal
(
)
)
;
}