Skip to content

Commit

Permalink
IHF: New tests for call_in_background helper.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry-ivanov committed Sep 17, 2016
1 parent b776772 commit 943d153
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 90 deletions.
95 changes: 44 additions & 51 deletions tests/artisan/CallInBackgroundTest.php
Original file line number Diff line number Diff line change
@@ -1,57 +1,50 @@
<?php

// use Mockery as m;
//
use Mockery as m;

// /**
// * @runTestsInSeparateProcesses
// * @preserveGlobalState disabled
// */
// class CallInBackgroundTest extends TestCase
// {
// protected function setUp()
// {
// $phpMock = m::mock('overload:Symfony\Component\Process\PhpExecutableFinder');
// $phpMock->shouldReceive('find')->with(false)->once()->andReturn('php');
//
// $utilsMock = m::mock('alias:Symfony\Component\Process\ProcessUtils');
// $utilsMock->shouldReceive('escapeArgument')->withAnyArgs()->atLeast()->once()->andReturnUsing(function ($v) {
// return $v;
// });
// }
//
// /** @test */
// public function it_works_without_before_and_after_parameters()
// {
// $mock = m::mock('alias:Illuminated\Helpers\System\Command');
// $mock->shouldReceive('exec')->with('(php artisan test command) > /dev/null 2>&1 &')->once();
//
// call_in_background('test command');
// }
//
// /** @test */
// public function it_works_with_only_before_parameter()
// {
// $mock = m::mock('alias:Illuminated\Helpers\System\Command');
// $mock->shouldReceive('exec')->with('(before command && php artisan test command) > /dev/null 2>&1 &')->once();
//
// call_in_background('test command', 'before command');
// }
//
// /** @test */
// public function it_works_with_only_after_parameter()
// {
// $mock = m::mock('alias:Illuminated\Helpers\System\Command');
// $mock->shouldReceive('exec')->with('(php artisan test command && after command) > /dev/null 2>&1 &')->once();
//
// call_in_background('test command', null, 'after command');
// }
//
// /** @test */
// public function it_works_with_before_and_after_parameters()
// {
// $mock = m::mock('alias:Illuminated\Helpers\System\Command');
// $mock->shouldReceive('exec')->with('(before && php artisan test command && after) > /dev/null 2>&1 &')->once();
//
// call_in_background('test command', 'before', 'after');
// }
// }
class CallInBackgroundTest extends TestCase
{
/** @test */
public function it_works_without_before_and_after_parameters()
{
$mock = m::mock('alias:Illuminated\Helpers\Artisan\Command');
$mock->shouldReceive('factory')->withArgs(['test command', null, null])->once()->andReturnSelf();
$mock->shouldReceive('runInBackground')->withNoArgs()->once();

call_in_background('test command');
}

/** @test */
public function it_works_with_only_before_parameter()
{
$mock = m::mock('alias:Illuminated\Helpers\Artisan\Command');
$mock->shouldReceive('factory')->withArgs(['test command', 'before command', null])->once()->andReturnSelf();
$mock->shouldReceive('runInBackground')->withNoArgs()->once();

call_in_background('test command', 'before command');
}

/** @test */
public function it_works_with_only_after_parameter()
{
$mock = m::mock('alias:Illuminated\Helpers\Artisan\Command');
$mock->shouldReceive('factory')->withArgs(['test command', null, 'after command'])->once()->andReturnSelf();
$mock->shouldReceive('runInBackground')->withNoArgs()->once();

call_in_background('test command', null, 'after command');
}

/** @test */
public function it_works_with_before_and_after_parameters()
{
$mock = m::mock('alias:Illuminated\Helpers\Artisan\Command');
$mock->shouldReceive('factory')->withArgs(['test command', 'before', 'after'])->once()->andReturnSelf();
$mock->shouldReceive('runInBackground')->withNoArgs()->once();

call_in_background('test command', 'before', 'after');
}
}
39 changes: 0 additions & 39 deletions tests/artisan/CallInBackgroundValidationsTest.php

This file was deleted.

0 comments on commit 943d153

Please sign in to comment.