-
-
Notifications
You must be signed in to change notification settings - Fork 30
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
1 parent
8af12eb
commit 548a2a9
Showing
5 changed files
with
149 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright (c) 2021 Kai Sassnowski | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
* | ||
* @see https://github.com/ksassnowski/venture | ||
*/ | ||
|
||
namespace Stubs; | ||
|
||
use Sassnowski\Venture\Models\WorkflowJob; | ||
|
||
class CustomWorkflowJobModel extends WorkflowJob | ||
{ | ||
} |
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,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright (c) 2021 Kai Sassnowski | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
* | ||
* @see https://github.com/ksassnowski/venture | ||
*/ | ||
|
||
namespace Stubs; | ||
|
||
use Sassnowski\Venture\Models\Workflow; | ||
|
||
class CustomWorkflowModel extends Workflow | ||
{ | ||
} |
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,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright (c) 2021 Kai Sassnowski | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
* | ||
* @see https://github.com/ksassnowski/venture | ||
*/ | ||
|
||
namespace Stubs; | ||
|
||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
use Sassnowski\Venture\WorkflowStep; | ||
|
||
class TestJobWithHandle implements ShouldQueue | ||
{ | ||
use WorkflowStep; | ||
|
||
public function handle() | ||
{ | ||
return true; | ||
} | ||
} |
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,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright (c) 2021 Kai Sassnowski | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
* | ||
* @see https://github.com/ksassnowski/venture | ||
*/ | ||
|
||
namespace Stubs; | ||
|
||
use Sassnowski\Venture\AbstractWorkflow; | ||
use Sassnowski\Venture\WorkflowDefinition; | ||
|
||
class WorkflowWithJob extends AbstractWorkflow | ||
{ | ||
public function definition(): WorkflowDefinition | ||
{ | ||
return (new WorkflowDefinition)->addJob( | ||
new TestJobWithHandle | ||
); | ||
} | ||
} |
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,55 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright (c) 2021 Kai Sassnowski | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
* | ||
* @see https://github.com/ksassnowski/venture | ||
*/ | ||
|
||
use Sassnowski\Venture\Models\Workflow; | ||
use Sassnowski\Venture\Models\WorkflowJob; | ||
use Sassnowski\Venture\Venture; | ||
use Stubs\CustomWorkflowJobModel; | ||
use Stubs\CustomWorkflowModel; | ||
use Stubs\WorkflowWithJob; | ||
use function PHPUnit\Framework\assertCount; | ||
use function PHPUnit\Framework\assertInstanceOf; | ||
use function PHPUnit\Framework\assertNotInstanceOf; | ||
|
||
uses(TestCase::class); | ||
|
||
afterEach(function () { | ||
Venture::useWorkflowModel(Workflow::class); | ||
Venture::useWorkflowJobModel(WorkflowJob::class); | ||
}); | ||
|
||
it('can override workflow model', function () { | ||
Venture::useWorkflowModel(CustomWorkflowModel::class); | ||
|
||
assertInstanceOf(CustomWorkflowModel::class, WorkflowWithJob::start()); | ||
}); | ||
|
||
it('can override workflow job model', function () { | ||
Venture::useWorkflowJobModel(CustomWorkflowJobModel::class); | ||
|
||
assertInstanceOf(Workflow::class, $workflow = WorkflowWithJob::start()); | ||
assertCount(1, $jobs = $workflow->jobs()->get()); | ||
assertInstanceOf(CustomWorkflowJobModel::class, $job = $jobs->first()); | ||
assertInstanceOf(Workflow::class, $job->workflow); | ||
assertNotInstanceOf(CustomWorkflowModel::class, $job->workflow); | ||
}); | ||
|
||
it('can override workflow and job model', function () { | ||
Venture::useWorkflowModel(CustomWorkflowModel::class); | ||
Venture::useWorkflowJobModel(CustomWorkflowJobModel::class); | ||
|
||
assertInstanceOf(CustomWorkflowModel::class, $workflow = WorkflowWithJob::start()); | ||
assertCount(1, $jobs = $workflow->jobs()->get()); | ||
assertInstanceOf(CustomWorkflowJobModel::class, $job = $jobs->first()); | ||
assertInstanceOf(CustomWorkflowModel::class, $job->workflow); | ||
}); |