-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
132 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
namespace Ycs77\LaravelWizard; | ||
|
||
use Illuminate\Foundation\Application; | ||
|
||
class WizardFactory | ||
{ | ||
/** | ||
* The application instance. | ||
* | ||
* @var \Illuminate\Foundation\Application | ||
*/ | ||
protected $app; | ||
|
||
/** | ||
* Create a new Wizard instance. | ||
* | ||
* @param \Illuminate\Foundation\Application $app | ||
* @return void | ||
*/ | ||
public function __construct(Application $app) | ||
{ | ||
$this->app = $app; | ||
} | ||
|
||
/** | ||
* Make the new wizard. | ||
* | ||
* @param string $name | ||
* @param array|string $steps | ||
* @param array $options | ||
* @return \Ycs77\LaravelWizard\Wizard | ||
*/ | ||
public function make(string $name, $steps, $options = []) | ||
{ | ||
$wizard = new Wizard($this->app, $name, $options); | ||
|
||
$wizard->setCache(); | ||
$wizard->setStepRepo(); | ||
|
||
$wizard->stepRepo()->make($steps); | ||
|
||
return $wizard; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace Ycs77\LaravelWizard\Test\Unit; | ||
|
||
use Ycs77\LaravelWizard\Contracts\CacheStore; | ||
use Ycs77\LaravelWizard\StepRepository; | ||
use Ycs77\LaravelWizard\Test\Stubs\UserStepStub; | ||
use Ycs77\LaravelWizard\Test\TestCase; | ||
use Ycs77\LaravelWizard\WizardFactory; | ||
|
||
class WizardFactoryTest extends TestCase | ||
{ | ||
public function testMakeWizard() | ||
{ | ||
$factory = new WizardFactory($this->app); | ||
|
||
$wizard = $factory->make('test-wizard', [UserStepStub::class]); | ||
|
||
$this->assertEquals('test-wizard', $wizard->getName()); | ||
$this->assertInstanceOf(CacheStore::class, $wizard->cache()); | ||
$this->assertInstanceOf(StepRepository::class, $wizard->stepRepo()); | ||
$this->assertCount(1, $wizard->stepRepo()->original()); | ||
$this->assertInstanceOf(UserStepStub::class, $wizard->stepRepo()->original()->first()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters