Skip to content
This repository was archived by the owner on Oct 24, 2023. It is now read-only.

Commit 33bb512

Browse files
author
Jens Schulze
committed
fix(State): add roles to state draft model
1 parent dab2edf commit 33bb512

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

src/Model/State/StateDraft.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
* @method StateDraft setInitial(bool $initial = null)
2525
* @method StateReferenceCollection getTransitions()
2626
* @method StateDraft setTransitions(StateReferenceCollection $transitions = null)
27+
* @method array getRoles()
28+
* @method StateDraft setRoles(array $roles = null)
2729
*/
2830
class StateDraft extends JsonObject
2931
{
@@ -37,6 +39,7 @@ public function fieldDefinitions()
3739
'name' => [static::TYPE => '\Commercetools\Core\Model\Common\LocalizedString'],
3840
'description' => [static::TYPE => '\Commercetools\Core\Model\Common\LocalizedString'],
3941
'initial' => [static::TYPE => 'bool'],
42+
'roles' => [static::TYPE => 'array'],
4043
'transitions' => [static::TYPE => '\Commercetools\Core\Model\State\StateReferenceCollection']
4144
];
4245
}

tests/fixtures/models.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,7 @@ stateDraft:
810810
- description
811811
- initial
812812
- transitions
813+
- roles
813814

814815
location:
815816
domain: zone

tests/integration/State/StateUpdateRequestTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,16 @@ public function testSetRoles()
253253
$this->assertInstanceOf('\Commercetools\Core\Model\State\State', $result);
254254
}
255255

256+
public function testCreateWithRoles()
257+
{
258+
$draft = $this->getDraft('set-roles');
259+
$draft->setRoles(['ReviewIncludedInStatistics']);
260+
$state = $this->createState($draft);
261+
262+
$this->assertInstanceOf('\Commercetools\Core\Model\State\State', $state);
263+
$this->assertSame(['ReviewIncludedInStatistics'], $state->getRoles());
264+
}
265+
256266
public function testAddRemoveRoles()
257267
{
258268
$draft = $this->getDraft('add-roles');

0 commit comments

Comments
 (0)