Skip to content

Commit

Permalink
add support for laravel 8.* and php 8.*
Browse files Browse the repository at this point in the history
  • Loading branch information
smajti1 authored Nov 14, 2020
1 parent e6e9d7f commit 1aca218
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 62 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [1.5.0] - 2020-11-13
### Added
- support `laravel` version `^8.0` and php `^8.0`
- update README.md see [automatic-controller-namespace-prefixing](https://laravel.com/docs/8.x/upgrade#automatic-controller-namespace-prefixing)

## [1.4.0] - 2020-04-25
### Added
- support `laravel` version `^7.0`
Expand Down Expand Up @@ -51,3 +56,4 @@ And will be changed to non-static
[1.2.0]: https://github.com/smajti1/laravel-wizard/compare/v1.1.0...v1.2.0
[1.3.0]: https://github.com/smajti1/laravel-wizard/compare/v1.2.0...v1.3.0
[1.4.0]: https://github.com/smajti1/laravel-wizard/compare/v1.3.0...v1.4.0
[1.5.0]: https://github.com/smajti1/laravel-wizard/compare/v1.4.0...v1.5.0
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:7.2-fpm-alpine
FROM php:8.0-rc-fpm-alpine

RUN apk update && apk add --no-cache \
bash \
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ simple laravel step-by-step wizard
| Version | Laravel Version | Php Version |
|---- |----|----|
| 1.1 | 5.* | ^7.0 |
| ^1.4 | 6.* || 7.* | ^7.2 |
| ^1.4 | 6.* || 7.* || 8.* | ^7.2 |

## Install

Expand All @@ -16,8 +16,10 @@ simple laravel step-by-step wizard
1. add routes

```php
Route::get('wizard/user/{step?}', 'UserWizardController@wizard')->name('wizard.user');
Route::post('wizard/user/{step}', 'UserWizardController@wizardPost')->name('wizard.user.post');
use App\Http\Controllers\UserWizardController;

Route::get('wizard/user/{step?}', [UserWizardController::class, 'wizard'])->name('wizard.user');
Route::post('wizard/user/{step}', [UserWizardController::class, 'wizardPost'])->name('wizard.user.post');
```

2. create steps
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "smajti1/laravel-wizard",
"description": "Wizard component for laravel5.",
"description": "Wizard component for laravel.",
"keywords": ["laravel", "wizard", "step", "steps"],
"license": "MIT",
"authors": [
Expand All @@ -11,11 +11,11 @@
],
"homepage": "https://github.com/smajti1/laravel-wizard",
"require": {
"php": "^7.2",
"illuminate/http": "^6.0 || ^7.0"
"php": "^7.2 || ^8.0",
"illuminate/http": "^6.0 || ^7.0 || ^8.0"
},
"require-dev": {
"phpunit/phpunit": "^8.0"
"phpunit/phpunit": "^8.0 || ^9.0"
},
"autoload": {
"psr-4": {
Expand Down
110 changes: 56 additions & 54 deletions tests/WizardTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

use Smajti1\Laravel\Exceptions\StepNotFoundException;
use Smajti1\Laravel\Step;
use Smajti1\Laravel\Wizard;
Expand Down Expand Up @@ -47,53 +49,53 @@ public function __construct()
'lastProcessedIndex',
]);

$this->wizard_reflection = new \ReflectionClass(Wizard::class);
$this->wizard_reflection = new ReflectionClass(Wizard::class);
}

public function testConstructor()
{
$this->wizard->expects($this->exactly(3))
public function testConstructor(): void
{
$this->wizard->expects(self::exactly(3))
->method('createStepClass');
$this->wizard->__construct($this->steps);
}

public function testConstructorEmptySteps()
{
public function testConstructorEmptySteps(): void
{
$this->expectException(StepNotFoundException::class);
$this->wizard->__construct([]);
}

public function testCreateStepClass()
{
public function testCreateStepClass(): void
{
$testStepClassName = 'TestStepClassName';
$this->getMockForAbstractClass(Step::class, [], $testStepClassName, false);

$method = $this->wizard_reflection->getMethod('createStepClass');
$method->setAccessible(true);

$result = $method->invoke($this->wizard, $testStepClassName, 1, 'test_key', 2);
$this->assertInstanceOf($testStepClassName, $result);
$this->assertInstanceOf(Step::class, $result);
self::assertInstanceOf($testStepClassName, $result);
self::assertInstanceOf(Step::class, $result);
}

public function testPrevStep()
{
public function testPrevStep(): void
{
$this->wizard->__construct($this->steps);
$this->assertNull($this->wizard->prevStep());
self::assertNull($this->wizard->prevStep());
$this->wizard->nextStep();
$this->assertInstanceOf(Step::class, $this->wizard->prevStep());
self::assertInstanceOf(Step::class, $this->wizard->prevStep());
}

public function testHasStep()
{
public function testHasStep(): void
{
$this->wizard->__construct($this->steps);
$this->assertFalse($this->wizard->hasPrev());
self::assertFalse($this->wizard->hasPrev());
$this->wizard->nextStep();
$this->assertTrue($this->wizard->hasPrev());
self::assertTrue($this->wizard->hasPrev());
}

public function testGetNotExistingStep()
{
public function testGetNotExistingStep(): void
{
$this->expectException(StepNotFoundException::class);

$method = $this->wizard_reflection->getMethod('get');
Expand All @@ -102,84 +104,84 @@ public function testGetNotExistingStep()
$method->invoke($this->wizard, -1);
}

public function testPrevSlug()
{
public function testPrevSlug(): void
{
$this->wizard->__construct($this->steps);
$this->assertNull($this->wizard->prevSlug());
self::assertNull($this->wizard->prevSlug());
$this->wizard->nextStep();
$this->assertEquals($this->firstTestStepClass::$slug, $this->wizard->prevSlug());
self::assertEquals($this->firstTestStepClass::$slug, $this->wizard->prevSlug());
}

public function testNextStep()
{
public function testNextStep(): void
{
$this->wizard->__construct($this->steps);
$this->assertInstanceOf(Step::class, $this->wizard->nextStep());
self::assertInstanceOf(Step::class, $this->wizard->nextStep());
$this->wizard->nextStep();
$this->assertNull($this->wizard->nextStep());
self::assertNull($this->wizard->nextStep());
}

public function testNextSlug()
{
public function testNextSlug(): void
{
$this->wizard->__construct($this->steps);
$this->assertEquals($this->secondTestStepClass::$slug, $this->wizard->nextSlug());
self::assertEquals($this->secondTestStepClass::$slug, $this->wizard->nextSlug());
$this->wizard->nextStep();
$this->wizard->nextStep();
$this->assertNull($this->wizard->nextSlug());
self::assertNull($this->wizard->nextSlug());
}

public function testGetBySlugNotExistingStep()
{
public function testGetBySlugNotExistingStep(): void
{
$this->expectException(StepNotFoundException::class);
$this->wizard->getBySlug('wrong_slug');
}

public function testFirst()
{
public function testFirst(): void
{
$this->wizard->__construct($this->steps);
$result = $this->wizard->first();
$this->assertEquals($this->firstTestStepClass::$slug, $result::$slug);
self::assertEquals($this->firstTestStepClass::$slug, $result::$slug);
}

public function testFirstOrLastProcessed()
{
public function testFirstOrLastProcessed(): void
{
$this->wizard->__construct($this->steps);
$this->wizard->expects($this->once())
$this->wizard->expects(self::once())
->method('lastProcessedIndex')
->willReturn(1);
$allSteps = $this->wizard->all();
$result = $this->wizard->firstOrLastProcessed();
$this->assertEquals($allSteps[1], $result);
self::assertEquals($allSteps[1], $result);
}

public function testLastProcessedIndex()
{
public function testLastProcessedIndex(): void
{
$wizard = $this->createPartialMock(Wizard::class, ['data',]);
$wizard->expects($this->once())
$wizard->expects(self::once())
->method('data')
->willReturn(['lastProcessed' => 1]);
$this->assertEquals($wizard->lastProcessedIndex(), 1);
self::assertEquals(1, $wizard->lastProcessedIndex());
}

public function testLastProcessedIndexWithoutData()
{
public function testLastProcessedIndexWithoutData(): void
{
$wizard = $this->createPartialMock(Wizard::class, ['data',]);
$wizard->expects($this->once())
$wizard->expects(self::once())
->method('data')
->willReturn([]);
$this->assertNull($wizard->lastProcessedIndex());
self::assertNull($wizard->lastProcessedIndex());
}

public function testWizardTestSteps()
{
public function testWizardTestSteps(): void
{
$this->wizard->__construct($this->steps);
$nextStep = $this->wizard->nextStep();
$this->assertTrue($nextStep::$slug == $this->secondTestStepClass::$slug);
self::assertEquals($nextStep::$slug, $this->secondTestStepClass::$slug);

$goBackToPrevStep = $this->wizard->prevStep();
$this->assertTrue($goBackToPrevStep::$slug == $this->firstTestStepClass::$slug);
self::assertEquals($goBackToPrevStep::$slug, $this->firstTestStepClass::$slug);

$stepBySlug = $this->wizard->getBySlug($this->secondTestStepClass::$slug);
$this->assertTrue($stepBySlug::$slug == $this->secondTestStepClass::$slug);
self::assertEquals($stepBySlug::$slug, $this->secondTestStepClass::$slug);
}

}

0 comments on commit 1aca218

Please sign in to comment.