New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[toggle-core#16] Create FeatureWasCreated event #24
Conversation
Codecov Report
@@ Coverage Diff @@
## 1.0.x #24 +/- ##
============================================
+ Coverage 93.22% 95.21% +1.99%
- Complexity 74 78 +4
============================================
Files 18 19 +1
Lines 177 188 +11
============================================
+ Hits 165 179 +14
+ Misses 12 9 -3
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, we have to extend a little the tests and it will be ready to rebase ;-D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As commented @kpicaza , we should check the type of the event recorded in order to ensure that it's the right event. Also we can discuss about passing the primitive or the VO object when creating the instance. What do you think?
private string $eventType; | ||
|
||
private string $featureId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can define properties in the same order as they're assigned in the constructor:
private string $eventType; | |
private string $featureId; | |
private string $featureId; | |
private string $eventType; |
public function __construct(string $featureId) | ||
{ | ||
$this->featureId = $featureId; | ||
$this->eventType = "FEATURE_WAS_CREATED"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could put the string in lowercase and extract it into a constant for future references. @kpicaza what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need event type the event class name is the type itself
|
||
private string $featureId; | ||
|
||
public function __construct(string $featureId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could pass the FeatureId
VO instead of the primitive to ensure that it's a right FeatureId
. Then, inside the constructor we can assign the string value to the property.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is better to work with generics at this level to easy serialization of the object, we create the value object in the getter as it is immutable
@@ -48,7 +48,7 @@ public function testItShouldBeEnabled(): void | |||
$feature->enable(); | |||
$this->assertTrue($feature->isEnabled()); | |||
$events = $feature->release(); | |||
$this->assertCount(0, $events); | |||
$this->assertCount(1, $events); // Released FeatureWasCreated event |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As @kpicaza commented, we could add an extra line here, checking the event type, for example:
$this->assertCount(1, $events); // Released FeatureWasCreated event | |
$this->assertCount(1, $events); | |
$this->assertInstanceOf(FeatureWasCreated::class, reset($events)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We added a specific test for FeatureWasCreated event
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏👏👏
Closes issue togge-core#16