-
Notifications
You must be signed in to change notification settings - Fork 16
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
Manage steps: append, insert, replace, destroy #8
Conversation
append, insert, replace, destroy It may be very helpfully when next step depends on data from prev step
|
||
public function insertStep(int $index, string $step_class, string $key): Step | ||
{ | ||
if ($index >= count($this->steps) || count($this->steps) === 0) { |
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.
Hey, it looks good :)
I see here way to make a little tweak/upgrade here. On most pessimistic path we count property $this->steps
3 times lets move this to new property $steps_count
$step = $this->get($index); | ||
$step->clearData(); | ||
|
||
for ($i=$index+1; $i < count($this->steps); $i++) { |
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.
Lest move count($this->steps)
before for
now it call count on every step and add some spaces betwean $i=$index+1
@@ -16,7 +16,9 @@ class WizardTest extends PHPUnit\Framework\TestCase | |||
protected $secondTestStepClass; | |||
protected $wizard_reflection; | |||
protected $thirdTestStepClass; | |||
protected $fourthTestStepClass; |
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.
I don't like how this test look (all file). I think i will rewrite this test and instead of create mock steps I add some dump step classes.
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.
ok i made a small refactor here you can check what i change -> a3d2367
$this->wizard = $this->createPartialMock(Wizard::class, []); | ||
$this->wizard->__construct($this->steps); | ||
|
||
$result = $this->wizard->appendStep($this->fourthTestStepClass::class, $this->wizardFourthStepKey); |
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.
Here i don't know we should use php 8.0 feature like '::class' on object. But if i rewrite this test it shoud not be needed
Added at version v.1.6.0 see changelog |
append, insert, replace, destroy
It may be very helpfully when next step depends on data from prev step