<?php

$I = new FunctionalTester($scenario);
$I->wantTo('delete a workflow keeping its files');
$I->runArtisan('workflow:create publishPost -a Notifier');
$I->runArtisan('workflow:create banUser -a Logger');
$I->runArtisan('workflow:delete banUser');
$I->seeJob('BanUserJob');
$I->seeRequest('BanUserRequest');
$I->seePipe('BanUser/Logger');
$I->seeJob('PublishPostJob');
$I->seeRequest('PublishPostRequest');
$I->seePipe('PublishPost/Notifier');
$I->seeInWorkflows('Delete/workflows.stub');
$I->seeInShellOutput('Workflow deleted successfully.');
$I->clearWorkflow('BanUser');
<?php

$I = new FunctionalTester($scenario);
$I->wantTo('append the newly created workflow if another one exists');
$I->runArtisan('workflow:create updateUser -a Notifier');
$I->runArtisan('workflow:create deleteUser -a Logger');
$I->seeInJob('UpdateUserJob', 'Append/UpdateUserJob.stub');
$I->seeInRequest('UpdateUserRequest', 'Append/UpdateUserRequest.stub');
$I->seeInPipe('UpdateUser/Notifier', 'Append/Notifier.stub');
$I->seeInJob('DeleteUserJob', 'Append/DeleteUserJob.stub');
$I->seeInRequest('DeleteUserRequest', 'Append/DeleteUserRequest.stub');
$I->seeInPipe('DeleteUser/Logger', 'Append/Logger.stub');
$I->seeInWorkflows('Append/workflows.stub');
$I->clearWorkflow('UpdateUser');
$I->clearWorkflow('DeleteUser');
<?php

$I = new FunctionalTester($scenario);
$I->wantTo('see an error if the workflow to create already exists');
$I->runArtisan('workflow:create registerUser');
$I->seeInShellOutput('Workflow created successfully.');
$I->runArtisan('workflow:create registerUser');
$I->seeInShellOutput('The workflow [RegisterUser] already exists.');
$I->clearWorkflow('RegisterUser');
<?php

$I = new FunctionalTester($scenario);
$I->wantTo('update an existing workflow');
$I->runArtisan('workflow:create loginUser -a Notifier');
$I->runArtisan('workflow:create registerUser -a "Notifier Logger"');
$I->runArtisan('workflow:update registerUser -a Buzzer -d Notifier');
$I->seePipe('LoginUser/Notifier');
$I->seePipe('RegisterUser/Notifier');
// because --force is not set
$I->seeInPipe('RegisterUser/Buzzer', 'Update/Buzzer.stub');
$I->seePipe('RegisterUser/Logger');
$I->seeInWorkflows('Update/workflows.stub');
$I->seeInShellOutput('Workflow updated successfully.');
$I->clearWorkflow('LoginUser');
$I->clearWorkflow('RegisterUser');
<?php

$I = new FunctionalTester($scenario);
$I->wantTo('create an unguarded workflow');
$I->runArtisan('workflow:create IndexPosts -u');
$I->dontSeeRequest('IndexPostsRequest');
$I->seeInJob('IndexPostsJob', 'Unguarded/IndexPostsJob.stub');
$I->seeInShellOutput('Job created successfully.');
$I->dontSeeInShellOutput('Request created successfully.');
$I->seeInWorkflows('Unguarded/workflows.stub');
$I->seeInShellOutput('Workflow created successfully.');
$I->clearWorkflow('IndexPosts');
<?php

$I = new FunctionalTester($scenario);
$I->wantTo('see a workflow with many pipes');
$I->runArtisan('workflow:create UpdatePost -a "Logger Buzzer Uploader Composer PipeWithVeryLongName"');
$I->runArtisan('workflow:read UpdatePost');
$I->seeDrawingIs('many.stub');
$I->clearWorkflow('UpdatePost');
<?php

$I = new FunctionalTester($scenario);
$I->wantTo('create a workflow with no pipes');
$I->runArtisan('workflow:create LoginUser');
$I->seeInJob('LoginUserJob', 'NoPipes/LoginUserJob.stub');
$I->seeInRequest('LoginUserRequest', 'NoPipes/LoginUserRequest.stub');
$I->seeInWorkflows('NoPipes/workflows.stub');
$I->seeInShellOutput('Job created successfully.');
$I->seeInShellOutput('Request created successfully.');
$I->dontSeeInShellOutput('Pipe created successfully.');
$I->seeInShellOutput('Workflow created successfully.');
$I->clearWorkflow('LoginUser');
<?php

$I = new FunctionalTester($scenario);
$I->wantTo('delete a workflow and its files');
$I->runArtisan('workflow:create publishPost -a Notifier');
$I->runArtisan('workflow:create banUser -a Logger');
$I->runArtisan('workflow:delete banUser -f');
$I->dontSeeJob('BanUserJob');
$I->dontSeeRequest('BanUserRequest');
$I->dontSeePipe('BanUser/Logger');
$I->seeJob('PublishPostJob');
$I->seeRequest('PublishPostRequest');
$I->seePipe('PublishPost/Notifier');
$I->seeInWorkflows('Delete/workflows.stub');
$I->seeInShellOutput('Workflow deleted successfully.');
$I->clearWorkflow('PublishPost');