Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
assertModerationState example
$english_node
= Node::
create
(
[
'type' => 'example',
'title' => 'Test title',
]
)
;
// Revision 1 (en).
$english_node
->
setUnpublished
(
)
->
save
(
)
;
$this
->
assertEquals
(
'draft',
$english_node
->moderation_state->value
)
;
$this
->
assertFalse
(
$english_node
->
isPublished
(
)
)
;
$this
->
assertTrue
(
$english_node
->
isDefaultRevision
(
)
)
;
$this
->
assertModerationState
(
$english_node
->
getRevisionId
(
)
,
$english_node
->
language
(
)
->
getId
(
)
, 'draft'
)
;
// Revision 2 (fr)
$french_node
=
$english_node
->
addTranslation
(
'fr',
[
'title' => 'French title'
]
)
;
$french_node
->moderation_state->value = 'published';
$french_node
->
save
(
)
;
$this
->
assertTrue
(
$french_node
->
isPublished
(
)
)
;
$this
->
assertTrue
(
$french_node
->
isDefaultRevision
(
)
)
;
$this
->
assertModerationState
(
$french_node
->
getRevisionId
(
)
,
$french_node
->
language
(
)
->
getId
(
)
, 'published'
)
;
// Revision 3 (fr)
$node
= Node::
load
(
$english_node
->
id
(
)
)
->
getTranslation
(
'fr'
)
;