diff --git a/.gitignore b/.gitignore index 5baea3c..106ff4c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /vendor composer.lock -/.idea \ No newline at end of file +/.idea +.phpunit.result.cache \ No newline at end of file diff --git a/README.md b/README.md index 6ca22fa..2b0bf64 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,10 @@ simple laravel step-by-step wizard -## Required - - php ^7.0 - laravel ^5.5 +| Version | Laravel Version | Php Version | +|---- |----|----| +| 1.1 | 5.* | ^7.0 | +| 1.2 | 6.* | ^7.2 | ## Install diff --git a/composer.json b/composer.json index 1f56fe8..d087cb3 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "smajti1/laravel-wizard", "description": "Wizard component for laravel5.", - "keywords": ["laravel", "wizard"], + "keywords": ["laravel", "wizard", "step", "steps"], "license": "MIT", "authors": [ { @@ -9,12 +9,13 @@ "email": "smajti1@gmail.com" } ], + "homepage": "https://github.com/smajti1/laravel-wizard", "require": { - "php": ">=7.0", - "illuminate/http": "~5.5" + "php": "^7.2", + "illuminate/http": "^6.0" }, "require-dev": { - "phpunit/phpunit": "~6.0" + "phpunit/phpunit": "^8.0" }, "autoload": { "psr-4": { diff --git a/src/Wizard.php b/src/Wizard.php index 12ef7c3..d04171d 100644 --- a/src/Wizard.php +++ b/src/Wizard.php @@ -42,10 +42,7 @@ protected function createStepClass($stepClassName, int $naturalNumber, $key, int return $step; } - /** - * @return Step|null - */ - public function prevStep() + public function prevStep(): ?Step { if ($this->hasPrev()) { return $this->get($this->currentIndex - 1); @@ -59,7 +56,6 @@ public function hasPrev(): bool } /** - * @return Step * @throws StepNotFoundException */ protected function get(int $index, bool $moveCurrentIndex = true): Step @@ -73,10 +69,7 @@ protected function get(int $index, bool $moveCurrentIndex = true): Step return $this->steps[$index]; } - /** - * @return null|string - */ - public function prevSlug() + public function prevSlug(): ?string { if ($this->hasPrev()) { $prevSlug = $this->get($this->currentIndex - 1, false); @@ -85,10 +78,7 @@ public function prevSlug() return null; } - /** - * @return Step|null - */ - public function nextStep() + public function nextStep(): ?Step { if ($this->hasNext()) { return $this->get($this->currentIndex + 1); @@ -106,10 +96,7 @@ public function limit(): int return count($this->steps); } - /** - * @return null|string - */ - public function nextSlug() + public function nextSlug(): ?string { if ($this->hasNext()) { $nextStep = $this->get($this->currentIndex + 1, false); @@ -149,17 +136,13 @@ public function firstOrLastProcessed(int $moveSteps = 0): Step /** * @deprecated - * @return bool|null */ - public function lastProcessed() + public function lastProcessed(): ?bool { return $this->lastProcessedIndex(); } - /** - * @return int|null - */ - public function lastProcessedIndex() + public function lastProcessedIndex(): ?int { $data = $this->data(); if ($data) { diff --git a/tests/WizardTest.php b/tests/WizardTest.php index 8e0bff1..bbbee14 100644 --- a/tests/WizardTest.php +++ b/tests/WizardTest.php @@ -19,32 +19,17 @@ class WizardTest extends PHPUnit\Framework\TestCase public function __construct() { parent::__construct(); - $this->firstTestStepClass = $this->getMockBuilder(Step::class) - ->disableOriginalConstructor() - ->setMethods([ - 'process', - ]) - ->getMock(); + $this->firstTestStepClass = $this->createPartialMock(Step::class, ['process',]); $this->firstTestStepClass::$label = 'First step label'; $this->firstTestStepClass::$slug = 'first-step'; $this->firstTestStepClass::$view = ''; - $this->secondTestStepClass = $this->getMockBuilder(Step::class) - ->disableOriginalConstructor() - ->setMethods([ - 'process', - ]) - ->getMock(); + $this->secondTestStepClass = $this->createPartialMock(Step::class, ['process',]); $this->secondTestStepClass::$label = 'Second step label'; $this->secondTestStepClass::$slug = 'second-step'; $this->secondTestStepClass::$view = ''; - $this->thirdTestStepClass = $this->getMockBuilder(Step::class) - ->disableOriginalConstructor() - ->setMethods([ - 'process', - ]) - ->getMock(); + $this->thirdTestStepClass = $this->createPartialMock(Step::class, ['process',]); $this->secondTestStepClass::$label = 'Third step label'; $this->secondTestStepClass::$slug = 'third-step'; $this->secondTestStepClass::$view = ''; @@ -57,10 +42,10 @@ public function __construct() $this->wizardThirdStepKey => get_class($this->thirdTestStepClass), ]; $this->sessionKeyName = 'test'; - $this->wizard = $this->getMockBuilder(Wizard::class) - ->disableOriginalConstructor() - ->setMethods(['createStepClass', 'lastProcessedIndex']) - ->getMock(); + $this->wizard = $this->createPartialMock(Wizard::class, [ + 'createStepClass', + 'lastProcessedIndex', + ]); $this->wizard_reflection = new \ReflectionClass(Wizard::class); } @@ -168,10 +153,7 @@ public function testFirstOrLastProcessed() public function testLastProcessedIndex() { - $wizard = $this->getMockBuilder(Wizard::class) - ->disableOriginalConstructor() - ->setMethods(['data']) - ->getMock(); + $wizard = $this->createPartialMock(Wizard::class, ['data',]); $wizard->expects($this->once()) ->method('data') ->willReturn(['lastProcessed' => 1]); @@ -180,10 +162,7 @@ public function testLastProcessedIndex() public function testLastProcessedIndexWithoutData() { - $wizard = $this->getMockBuilder(Wizard::class) - ->disableOriginalConstructor() - ->setMethods(['data']) - ->getMock(); + $wizard = $this->createPartialMock(Wizard::class, ['data',]); $wizard->expects($this->once()) ->method('data') ->willReturn([]);