Skip to content

Commit a8b1788

Browse files
Merge branch '4.3' into 4.4
* 4.3: [DI] fix locators with numeric keys Fix error when we use VO for the marking property
2 parents 5c94750 + de36321 commit a8b1788

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

MarkingStore/MethodMarkingStore.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function getMarking($subject): Marking
6161
}
6262

6363
if ($this->singleState) {
64-
$marking = [$marking => 1];
64+
$marking = [(string) $marking => 1];
6565
}
6666

6767
return new Marking($marking);

Tests/MarkingStore/MethodMarkingStoreTest.php

+31
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,35 @@ public function testGetSetMarkingWithSingleState()
5252

5353
$this->assertEquals($marking, $marking2);
5454
}
55+
56+
public function testGetMarkingWithValueObject()
57+
{
58+
$subject = new Subject($this->createValueObject('first_place'));
59+
60+
$markingStore = new MethodMarkingStore(true);
61+
62+
$marking = $markingStore->getMarking($subject);
63+
64+
$this->assertInstanceOf(Marking::class, $marking);
65+
$this->assertCount(1, $marking->getPlaces());
66+
$this->assertSame('first_place', (string) $subject->getMarking());
67+
}
68+
69+
private function createValueObject(string $markingValue)
70+
{
71+
return new class($markingValue) {
72+
/** @var string */
73+
private $markingValue;
74+
75+
public function __construct(string $markingValue)
76+
{
77+
$this->markingValue = $markingValue;
78+
}
79+
80+
public function __toString()
81+
{
82+
return $this->markingValue;
83+
}
84+
};
85+
}
5586
}

0 commit comments

Comments
 (0)