Skip to content

Commit

Permalink
refactor functions
Browse files Browse the repository at this point in the history
  • Loading branch information
rodber committed May 22, 2022
1 parent cccefbf commit 99f7d32
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/Runner.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function withRun(): RunnerInterface
foreach ($jobs->getGraph() as $jobs) {
foreach ($jobs as $job) {
$promises[] = enqueueCallable(
'Chevere\\Workflow\\workflowRunnerForJob',
'Chevere\\Workflow\\runnerForJob',
$new,
$job,
);
Expand Down
4 changes: 2 additions & 2 deletions src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function job(
return new Job($action, ...$namedArguments);
}

function workflowRunnerForJob(
function runnerForJob(
RunnerInterface $workflowRunner,
string $job,
): RunnerInterface {
Expand All @@ -49,7 +49,7 @@ function workflowRunnerForJob(
/**
* @param Array<string, mixed> $vars
*/
function workflowRun(
function run(
WorkflowInterface $workflow,
array $vars = [],
?ContainerInterface $container = null
Expand Down
4 changes: 2 additions & 2 deletions tests/RunnerParallelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
use function Chevere\Filesystem\fileForPath;
use Chevere\Tests\_resources\src\TestActionFileWrite;
use function Chevere\Workflow\job;
use function Chevere\Workflow\run;
use function Chevere\Workflow\workflow;
use function Chevere\Workflow\workflowRun;
use PHPUnit\Framework\TestCase;

final class RunnerParallelTest extends TestCase
Expand All @@ -39,7 +39,7 @@ public function testParallelRunner(): void
),
);
$arguments = [];
workflowRun($workflow, ...$arguments);
run($workflow, ...$arguments);
$this->assertStringEqualsFile(
$file->path()->__toString(),
'^^$$'
Expand Down
4 changes: 2 additions & 2 deletions tests/RunnerSequentialTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
use function Chevere\Filesystem\fileForPath;
use Chevere\Tests\_resources\src\TestActionFileWrite;
use function Chevere\Workflow\job;
use function Chevere\Workflow\run;
use function Chevere\Workflow\workflow;
use function Chevere\Workflow\workflowRun;
use PHPUnit\Framework\TestCase;

final class RunnerSequentialTest extends TestCase
Expand All @@ -40,7 +40,7 @@ public function testSequentialRunner(): void
)->withDepends('j1'),
);
$arguments = [];
$run = workflowRun($workflow, ...$arguments);
$run = run($workflow, ...$arguments);
$this->assertStringEqualsFile(
$file->path()->__toString(),
str_repeat('^$', 2)
Expand Down
12 changes: 6 additions & 6 deletions tests/RunnerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
use Chevere\Tests\_resources\src\TestActionParamsFooResponse1;
use function Chevere\Workflow\job;
use Chevere\Workflow\Run;
use function Chevere\Workflow\run;
use Chevere\Workflow\Runner;
use function Chevere\Workflow\runnerForJob;
use function Chevere\Workflow\workflow;
use function Chevere\Workflow\workflowRun;
use function Chevere\Workflow\workflowRunnerForJob;
use PHPUnit\Framework\TestCase;

final class RunnerTest extends TestCase
Expand All @@ -47,14 +47,14 @@ public function testWorkflowRunner(): void
];
$workflowRun = new Run($workflow, ...$arguments);
$workflowRunner = new Runner($workflowRun, new Container());
$workflowRunnerForStep1 = workflowRunnerForJob(
$workflowRunnerForStep1 = runnerForJob(
$workflowRunner,
'step1'
);
$workflowRunner = (new Runner($workflowRun, new Container()))
->withRun();
workflowRunnerForJob($workflowRunner, 'step1');
$workflowRunnerForStep2 = workflowRunnerForJob(
runnerForJob($workflowRunner, 'step1');
$workflowRunnerForStep2 = runnerForJob(
$workflowRunner,
'step2'
);
Expand All @@ -68,7 +68,7 @@ public function testWorkflowRunner(): void
$workflowRun->get('step2')->data()
);
$this->assertSame($workflowRun, $workflowRunner->run());
$workflowRunFunction = workflowRun($workflow, $arguments);
$workflowRunFunction = run($workflow, $arguments);
$this->assertEquals(
$workflowRunFunction->workflow(),
$workflowRunner->run()->workflow()
Expand Down

0 comments on commit 99f7d32

Please sign in to comment.