From b46e9aea78ef632712d1eb184491452865b2c2c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Tue, 7 Apr 2020 11:39:41 +0200 Subject: [PATCH 1/2] [Workflow] Use a strict comparison when retrieving raw markin in MarkingStore --- MarkingStore/SingleStateMarkingStore.php | 2 +- Tests/MarkingStore/SingleStateMarkingStoreTest.php | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/MarkingStore/SingleStateMarkingStore.php b/MarkingStore/SingleStateMarkingStore.php index daccc65..cd102f4 100644 --- a/MarkingStore/SingleStateMarkingStore.php +++ b/MarkingStore/SingleStateMarkingStore.php @@ -44,7 +44,7 @@ public function getMarking($subject) { $placeName = $this->propertyAccessor->getValue($subject, $this->property); - if (!$placeName) { + if (null === $placeName) { return new Marking(); } diff --git a/Tests/MarkingStore/SingleStateMarkingStoreTest.php b/Tests/MarkingStore/SingleStateMarkingStoreTest.php index 2e00714..0db3798 100644 --- a/Tests/MarkingStore/SingleStateMarkingStoreTest.php +++ b/Tests/MarkingStore/SingleStateMarkingStoreTest.php @@ -30,4 +30,17 @@ public function testGetSetMarking() $this->assertEquals($marking, $marking2); } + + public function testAlmostEmptyPlaceName() + { + $subject = new \stdClass(); + $subject->myMarks = 0; + + $markingStore = new SingleStateMarkingStore('myMarks'); + + $marking = $markingStore->getMarking($subject); + + $this->assertInstanceOf(Marking::class, $marking); + $this->assertCount(1, $marking->getPlaces()); + } } From 57cc0b5baa9caa0a0f368d9461194cb161203c4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Tue, 7 Apr 2020 11:51:42 +0200 Subject: [PATCH 2/2] [Workflow] Use a strict comparison when retrieving raw marking in MarkingStore --- MarkingStore/MethodMarkingStore.php | 2 +- Tests/MarkingStore/MethodMarkingStoreTest.php | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/MarkingStore/MethodMarkingStore.php b/MarkingStore/MethodMarkingStore.php index 8c219f5..feb0129 100644 --- a/MarkingStore/MethodMarkingStore.php +++ b/MarkingStore/MethodMarkingStore.php @@ -56,7 +56,7 @@ public function getMarking($subject): Marking $marking = $subject->{$method}(); - if (!$marking) { + if (null === $marking) { return new Marking(); } diff --git a/Tests/MarkingStore/MethodMarkingStoreTest.php b/Tests/MarkingStore/MethodMarkingStoreTest.php index 7393faa..155f285 100644 --- a/Tests/MarkingStore/MethodMarkingStoreTest.php +++ b/Tests/MarkingStore/MethodMarkingStoreTest.php @@ -53,6 +53,18 @@ public function testGetSetMarkingWithSingleState() $this->assertEquals($marking, $marking2); } + public function testGetSetMarkingWithSingleStateAndAlmostEmptyPlaceName() + { + $subject = new Subject(0); + + $markingStore = new MethodMarkingStore(true); + + $marking = $markingStore->getMarking($subject); + + $this->assertInstanceOf(Marking::class, $marking); + $this->assertCount(1, $marking->getPlaces()); + } + public function testGetMarkingWithValueObject() { $subject = new Subject($this->createValueObject('first_place'));