Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Applied fixes from StyleCI #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 28 additions & 25 deletions spec/Cerbero/Workflow/Console/Drawing/DrawerSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,20 @@

namespace spec\Cerbero\Workflow\Console\Drawing;

use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Cerbero\Workflow\Repositories\PipelineRepositoryInterface;
use Cerbero\Workflow\Console\Drawing\Geometry;
use Cerbero\Workflow\Repositories\PipelineRepositoryInterface;
use PhpSpec\ObjectBehavior;

class DrawerSpec extends ObjectBehavior
{
function let(PipelineRepositoryInterface $pipelines)
{
$geometry = new Geometry;
public function let(PipelineRepositoryInterface $pipelines)
{
$geometry = new Geometry();

$this->beConstructedWith($pipelines, $geometry);
}
$this->beConstructedWith($pipelines, $geometry);
}

function it_is_initializable()
public function it_is_initializable()
{
$this->shouldHaveType('Cerbero\Workflow\Console\Drawing\Drawer');
}
Expand All @@ -25,59 +24,63 @@ function it_is_initializable()
* @testdox It draws a workflow with zero pipes.
*
* @author Andrea Marco Sartori
* @return void
*
* @return void
*/
public function it_draws_a_workflow_with_zero_pipes($pipelines)
{
$pipelines->getPipesByPipeline('RegisterUser')->willReturn([]);
$pipelines->getPipesByPipeline('RegisterUser')->willReturn([]);

$drawing = file_get_contents(__DIR__ . '/stubs/zero.stub');
$drawing = file_get_contents(__DIR__.'/stubs/zero.stub');

$this->draw('RegisterUser')->shouldReturn($drawing);
$this->draw('RegisterUser')->shouldReturn($drawing);
}

/**
* @testdox It draws a workflow with one pipe.
*
* @author Andrea Marco Sartori
* @return void
*
* @return void
*/
public function it_draws_a_workflow_with_one_pipe($pipelines)
{
$pipelines->getPipesByPipeline('RegisterUser')->willReturn(['App\Workflows\RegisterUser\Notifier']);
$pipelines->getPipesByPipeline('RegisterUser')->willReturn(['App\Workflows\RegisterUser\Notifier']);

$drawing = file_get_contents(__DIR__ . '/stubs/one.stub');
$drawing = file_get_contents(__DIR__.'/stubs/one.stub');

$this->draw('RegisterUser')->shouldReturn($drawing);
$this->draw('RegisterUser')->shouldReturn($drawing);
}

/**
* @testdox It draws a workflow with two pipe.
*
* @author Andrea Marco Sartori
* @return void
*
* @return void
*/
public function it_draws_a_workflow_with_two_pipe($pipelines)
{
$pipelines->getPipesByPipeline('RegisterUser')->willReturn(['App\Workflows\RegisterUser\Logger', 'App\Workflows\RegisterUser\Notifier']);
$pipelines->getPipesByPipeline('RegisterUser')->willReturn(['App\Workflows\RegisterUser\Logger', 'App\Workflows\RegisterUser\Notifier']);

$drawing = file_get_contents(__DIR__ . '/stubs/two.stub');
$drawing = file_get_contents(__DIR__.'/stubs/two.stub');

$this->draw('RegisterUser')->shouldReturn($drawing);
$this->draw('RegisterUser')->shouldReturn($drawing);
}

/**
* @testdox It draws a workflow with many pipes.
*
* @author Andrea Marco Sartori
* @return void
*
* @return void
*/
public function it_draws_a_workflow_with_many_pipes($pipelines)
{
$pipelines->getPipesByPipeline('LoginUser')->willReturn(['LongName', 'TheLongestNameEver', 'LongerName', 'Name', 'VeryLongName']);
$pipelines->getPipesByPipeline('LoginUser')->willReturn(['LongName', 'TheLongestNameEver', 'LongerName', 'Name', 'VeryLongName']);

$drawing = file_get_contents(__DIR__ . '/stubs/many.stub');
$drawing = file_get_contents(__DIR__.'/stubs/many.stub');

$this->draw('LoginUser')->shouldReturn($drawing);
$this->draw('LoginUser')->shouldReturn($drawing);
}
}
34 changes: 18 additions & 16 deletions spec/Cerbero/Workflow/Inflectors/InflectorSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@

namespace spec\Cerbero\Workflow\Inflectors;

use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Cerbero\Workflow\Wrappers\NamespaceDetectorInterface;
use PhpSpec\ObjectBehavior;

class InflectorSpec extends ObjectBehavior
{
function let(NamespaceDetectorInterface $detector)
{
$this->beConstructedWith($detector);
public function let(NamespaceDetectorInterface $detector)
{
$this->beConstructedWith($detector);

$detector->detect()->willReturn('App');
}
$detector->detect()->willReturn('App');
}

function it_is_initializable()
public function it_is_initializable()
{
$this->shouldHaveType('Cerbero\Workflow\Inflectors\Inflector');
$this->shouldHaveType('Cerbero\Workflow\Inflectors\InflectorInterface');
Expand All @@ -25,36 +24,39 @@ function it_is_initializable()
* @testdox It returns itself after setting the word to inflect.
*
* @author Andrea Marco Sartori
* @return void
*
* @return void
*/
public function it_returns_itself_after_setting_the_word_to_inflect()
{
$this->of('foo')->shouldReturn($this);
$this->of('foo')->shouldReturn($this);
}

/**
* @testdox It inflects the request.
*
* @author Andrea Marco Sartori
* @return void
*
* @return void
*/
public function it_inflects_the_request()
{
$expected = 'App\Http\Requests\RegisterUserRequest';
$expected = 'App\Http\Requests\RegisterUserRequest';

$this->of('registerUser')->getRequest()->shouldReturn($expected);
$this->of('registerUser')->getRequest()->shouldReturn($expected);
}

/**
* @testdox It inflects the job.
*
* @author Andrea Marco Sartori
* @return void
*
* @return void
*/
public function it_inflects_the_job()
{
$expected = 'App\Jobs\RegisterUserJob';
$expected = 'App\Jobs\RegisterUserJob';

$this->of('registerUser')->getJob()->shouldReturn($expected);
$this->of('registerUser')->getJob()->shouldReturn($expected);
}
}
59 changes: 34 additions & 25 deletions spec/Cerbero/Workflow/Repositories/YamlPipelineRepositorySpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,27 @@

namespace spec\Cerbero\Workflow\Repositories;

use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Cerbero\Workflow\Wrappers\YamlParserInterface;
use Illuminate\Filesystem\Filesystem;
use PhpSpec\ObjectBehavior;

class YamlPipelineRepositorySpec extends ObjectBehavior
{

/**
* @author Andrea Marco Sartori
* @var array $pipeline Example of pipeline.
*
* @var array Example of pipeline.
*/
private $pipeline = array('RegisterUser' => ['Notifier', 'Logger']);
private $pipeline = ['RegisterUser' => ['Notifier', 'Logger']];

function let(YamlParserInterface $parser, Filesystem $files)
{
$this->beConstructedWith($parser, $files, 'path/to/workflows');
public function let(YamlParserInterface $parser, Filesystem $files)
{
$this->beConstructedWith($parser, $files, 'path/to/workflows');

$parser->parse('path/to/workflows/workflows.yml')->shouldBeCalled()->willReturn($this->pipeline);
}
$parser->parse('path/to/workflows/workflows.yml')->shouldBeCalled()->willReturn($this->pipeline);
}

function it_is_initializable()
public function it_is_initializable()
{
$this->shouldHaveType('Cerbero\Workflow\Repositories\YamlPipelineRepository');
$this->shouldHaveType('Cerbero\Workflow\Repositories\PipelineRepositoryInterface');
Expand All @@ -33,42 +32,46 @@ function it_is_initializable()
* @testdox It returns false when a pipeline does not exist.
*
* @author Andrea Marco Sartori
* @return void
*
* @return void
*/
public function it_returns_false_when_a_pipeline_does_not_exist()
{
$this->exists('unknownPipeline')->shouldReturn(false);
$this->exists('unknownPipeline')->shouldReturn(false);
}

/**
* @testdox It returns true when a pipeline exists.
*
* @author Andrea Marco Sartori
* @return void
*
* @return void
*/
public function it_returns_true_when_a_pipeline_exists()
{
$this->exists('RegisterUser')->shouldReturn(true);
$this->exists('RegisterUser')->shouldReturn(true);
}

/**
* @testdox It returns the pipeline of a fiven workflow.
*
* @author Andrea Marco Sartori
* @return void
*
* @return void
*/
public function it_returns_the_pipeline_of_a_fiven_workflow()
{
$expected = ['Notifier', 'Logger'];
$expected = ['Notifier', 'Logger'];

$this->getPipesByPipeline('registerUser')->shouldReturn($expected);
$this->getPipesByPipeline('registerUser')->shouldReturn($expected);
}

/**
* @testdox It retrieves the source of the pipelines.
*
* @author Andrea Marco Sartori
* @return void
*
* @return void
*/
public function it_retrieves_the_source_of_the_pipelines()
{
Expand All @@ -79,7 +82,8 @@ public function it_retrieves_the_source_of_the_pipelines()
* @testdox It creates the YAML file.
*
* @author Andrea Marco Sartori
* @return void
*
* @return void
*/
public function it_creates_the_YAML_file($files)
{
Expand All @@ -94,7 +98,8 @@ public function it_creates_the_YAML_file($files)
* @testdox It stores the given pipeline and its pipes.
*
* @author Andrea Marco Sartori
* @return void
*
* @return void
*/
public function it_stores_the_given_pipeline_and_its_pipes($parser, $files)
{
Expand All @@ -109,7 +114,8 @@ public function it_stores_the_given_pipeline_and_its_pipes($parser, $files)
* @testdox It updates an existing pipeline by attaching and detaching pipes.
*
* @author Andrea Marco Sartori
* @return void
*
* @return void
*/
public function it_updates_an_existing_pipeline_by_attaching_and_detaching_pipes($parser, $files)
{
Expand All @@ -126,7 +132,8 @@ public function it_updates_an_existing_pipeline_by_attaching_and_detaching_pipes
* @testdox It does not attach if no attachments are specified.
*
* @author Andrea Marco Sartori
* @return void
*
* @return void
*/
public function it_does_not_attach_if_no_attachments_are_specified($parser, $files)
{
Expand All @@ -143,7 +150,8 @@ public function it_does_not_attach_if_no_attachments_are_specified($parser, $fil
* @testdox It does not detach if no detachments are specified.
*
* @author Andrea Marco Sartori
* @return void
*
* @return void
*/
public function it_does_not_detach_if_no_detachments_are_specified($parser, $files)
{
Expand All @@ -160,7 +168,8 @@ public function it_does_not_detach_if_no_detachments_are_specified($parser, $fil
* @testdox It destroys a pipeline.
*
* @author Andrea Marco Sartori
* @return void
*
* @return void
*/
public function it_destroys_a_pipeline($parser, $files)
{
Expand Down
Loading