Skip to content

Commit

Permalink
Refactor list command to be full integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaspaul committed Mar 29, 2017
1 parent 1e0e9d1 commit 2f4355e
Showing 1 changed file with 21 additions and 22 deletions.
43 changes: 21 additions & 22 deletions tests/Console/ListCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,43 @@
use Opensoft\Rollout\Rollout;
use Illuminate\Cache\ArrayStore;
use Illuminate\Cache\Repository;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Contracts\Console\Kernel;
use Jaspaul\LaravelRollout\Drivers\Cache;
use Jaspaul\LaravelRollout\FeaturePresenter;
use Jaspaul\LaravelRollout\Console\ListCommand;

class ListCommandTest extends TestCase
{
private $command;
private $rollout;

/**
* @before
*/
function setup_command()
{
$this->rollout = new Rollout(new Cache(new Repository(new ArrayStore())));
$this->command = new ListCommand($this->rollout);
}

/**
* @test
*/
function get_rows_returns_an_empty_set_when_no_features_exist()
function it_returns_an_empty_table_if_there_are_no_stored_features()
{
$result = $this->command->getRows();
$this->assertEmpty($result);
$expected = "+------+--------+\n| name | status |\n+------+--------+\n";

Artisan::call('rollout:list', []);

$output = $this->app[Kernel::class]->output();

$this->assertSame($expected, $output);
}

/**
* @test
*/
function get_rows_returns_the_features_that_were_set()
function it_returns_the_stored_features_in_the_table()
{
$this->rollout->get('test');
$rollout = $this->app[Rollout::class];

// Create our feature flag if it doesn't exist
$rollout->get('derp');

Artisan::call('rollout:list', []);

$result = $this->command->getRows();
$output = $this->app[Kernel::class]->output();

$this->assertEquals(1, count($result));
$this->assertEquals(
[['name' => 'test', 'status' => 'Deactivated globally.']], $result
);
$this->assertContains('derp', $output);
$this->assertContains(FeaturePresenter::$statuses['disabled'], $output);
}
}

0 comments on commit 2f4355e

Please sign in to comment.