Fix error when we use VO for the marking property
Fix Illegal offset type when we use ValueObject instead of string for the marking property #28203 #22031
This commit is contained in:
parent
a1fc280bf2
commit
6570d5cbe2
@ -61,7 +61,7 @@ final class MethodMarkingStore implements MarkingStoreInterface
|
||||
}
|
||||
|
||||
if ($this->singleState) {
|
||||
$marking = [$marking => 1];
|
||||
$marking = [(string) $marking => 1];
|
||||
}
|
||||
|
||||
return new Marking($marking);
|
||||
|
@ -52,4 +52,35 @@ class MethodMarkingStoreTest extends TestCase
|
||||
|
||||
$this->assertEquals($marking, $marking2);
|
||||
}
|
||||
|
||||
public function testGetMarkingWithValueObject()
|
||||
{
|
||||
$subject = new Subject($this->createValueObject('first_place'));
|
||||
|
||||
$markingStore = new MethodMarkingStore(true);
|
||||
|
||||
$marking = $markingStore->getMarking($subject);
|
||||
|
||||
$this->assertInstanceOf(Marking::class, $marking);
|
||||
$this->assertCount(1, $marking->getPlaces());
|
||||
$this->assertSame('first_place', (string) $subject->getMarking());
|
||||
}
|
||||
|
||||
private function createValueObject(string $markingValue)
|
||||
{
|
||||
return new class($markingValue) {
|
||||
/** @var string */
|
||||
private $markingValue;
|
||||
|
||||
public function __construct(string $markingValue)
|
||||
{
|
||||
$this->markingValue = $markingValue;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->markingValue;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user