Skip to content

Commit 8e2573e

Browse files
committed
Update flush test to check exit code of artisan command
1 parent c38d5f6 commit 8e2573e

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/Console/Commands/Flush.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ public function handle()
1212
$option = $this->option('model');
1313
$model = new $option;
1414
$model->flushCache();
15+
$this->info("Cache for model '{$option}' flushed.");
1516
}
1617
}

tests/Unit/Console/Commands/FlushTest.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php namespace GeneaLabs\LaravelModelCaching\Tests\Unit;
1+
<?php namespace GeneaLabs\LaravelModelCaching\Tests\Unit\Console\Commands;
22

33
use GeneaLabs\LaravelModelCaching\Tests\Fixtures\Author;
44
use GeneaLabs\LaravelModelCaching\Tests\Fixtures\Book;
@@ -48,13 +48,14 @@ public function testGivenModelIsFlushed()
4848
$cachedResults = cache()
4949
->tags($tags)
5050
->get($key);
51-
$this->artisan('modelCache:flush', ['--model' => Author::class]);
51+
$result = $this->artisan('modelCache:flush', ['--model' => Author::class]);
5252
$flushedResults = cache()
5353
->tags($tags)
5454
->get($key);
5555

5656
$this->assertEquals($authors, $cachedResults);
5757
$this->assertEmpty($flushedResults);
58+
$this->assertEquals($result, 0);
5859
}
5960

6061
public function testGivenModelWithRelationshipIsFlushed()
@@ -69,12 +70,16 @@ public function testGivenModelWithRelationshipIsFlushed()
6970
$cachedResults = cache()
7071
->tags($tags)
7172
->get($key);
72-
$this->artisan('modelCache:flush', ['--model' => Author::class]);
73+
$result = $this->artisan(
74+
'modelCache:flush',
75+
['--model' => Author::class]
76+
);
7377
$flushedResults = cache()
7478
->tags($tags)
7579
->get($key);
7680

7781
$this->assertEquals($authors, $cachedResults);
7882
$this->assertEmpty($flushedResults);
83+
$this->assertEquals($result, 0);
7984
}
8085
}

0 commit comments

Comments
 (0)