Skip to content

Commit 2f4355e

Browse files
committed
Refactor list command to be full integration tests
1 parent 1e0e9d1 commit 2f4355e

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed

tests/Console/ListCommandTest.php

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,44 +6,43 @@
66
use Opensoft\Rollout\Rollout;
77
use Illuminate\Cache\ArrayStore;
88
use Illuminate\Cache\Repository;
9+
use Illuminate\Support\Facades\Artisan;
10+
use Illuminate\Contracts\Console\Kernel;
911
use Jaspaul\LaravelRollout\Drivers\Cache;
12+
use Jaspaul\LaravelRollout\FeaturePresenter;
1013
use Jaspaul\LaravelRollout\Console\ListCommand;
1114

1215
class ListCommandTest extends TestCase
1316
{
14-
private $command;
15-
private $rollout;
16-
17-
/**
18-
* @before
19-
*/
20-
function setup_command()
21-
{
22-
$this->rollout = new Rollout(new Cache(new Repository(new ArrayStore())));
23-
$this->command = new ListCommand($this->rollout);
24-
}
25-
2617
/**
2718
* @test
2819
*/
29-
function get_rows_returns_an_empty_set_when_no_features_exist()
20+
function it_returns_an_empty_table_if_there_are_no_stored_features()
3021
{
31-
$result = $this->command->getRows();
32-
$this->assertEmpty($result);
22+
$expected = "+------+--------+\n| name | status |\n+------+--------+\n";
23+
24+
Artisan::call('rollout:list', []);
25+
26+
$output = $this->app[Kernel::class]->output();
27+
28+
$this->assertSame($expected, $output);
3329
}
3430

3531
/**
3632
* @test
3733
*/
38-
function get_rows_returns_the_features_that_were_set()
34+
function it_returns_the_stored_features_in_the_table()
3935
{
40-
$this->rollout->get('test');
36+
$rollout = $this->app[Rollout::class];
37+
38+
// Create our feature flag if it doesn't exist
39+
$rollout->get('derp');
40+
41+
Artisan::call('rollout:list', []);
4142

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

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

0 commit comments

Comments
 (0)