Skip to content
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

Closed
wants to merge 2 commits into from

Conversation

jamesRUS52
Copy link

append, insert, replace, destroy

It may be very helpfully when next step depends on data from prev step

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) {
Copy link
Owner

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++) {
Copy link
Owner

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;
Copy link
Owner

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.

Copy link
Owner

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);
Copy link
Owner

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

@smajti1
Copy link
Owner

smajti1 commented May 22, 2021

Added at version v.1.6.0 see changelog

@smajti1 smajti1 closed this May 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants