|
6 | 6 | use Opensoft\Rollout\Rollout; |
7 | 7 | use Illuminate\Cache\ArrayStore; |
8 | 8 | use Illuminate\Cache\Repository; |
| 9 | +use Illuminate\Support\Facades\Artisan; |
| 10 | +use Illuminate\Contracts\Console\Kernel; |
9 | 11 | use Jaspaul\LaravelRollout\Drivers\Cache; |
| 12 | +use Jaspaul\LaravelRollout\FeaturePresenter; |
10 | 13 | use Jaspaul\LaravelRollout\Console\ListCommand; |
11 | 14 |
|
12 | 15 | class ListCommandTest extends TestCase |
13 | 16 | { |
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 | | - |
26 | 17 | /** |
27 | 18 | * @test |
28 | 19 | */ |
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() |
30 | 21 | { |
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); |
33 | 29 | } |
34 | 30 |
|
35 | 31 | /** |
36 | 32 | * @test |
37 | 33 | */ |
38 | | - function get_rows_returns_the_features_that_were_set() |
| 34 | + function it_returns_the_stored_features_in_the_table() |
39 | 35 | { |
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', []); |
41 | 42 |
|
42 | | - $result = $this->command->getRows(); |
| 43 | + $output = $this->app[Kernel::class]->output(); |
43 | 44 |
|
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); |
48 | 47 | } |
49 | 48 | } |
0 commit comments