2019-08-21 23:46:38 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests;
|
|
|
|
|
|
|
|
use Illuminate\Filesystem\Filesystem;
|
2019-12-14 11:10:37 +08:00
|
|
|
use Illuminate\Support\Str;
|
2019-08-21 23:46:38 +08:00
|
|
|
|
|
|
|
class OptionsCacheCommandTest extends TestCase
|
|
|
|
{
|
|
|
|
public function testRun()
|
|
|
|
{
|
2019-08-22 08:50:59 +08:00
|
|
|
$this->mock(Filesystem::class, function ($mock) {
|
2019-08-22 10:06:13 +08:00
|
|
|
$mock->shouldReceive('exists')->andReturn(false);
|
2019-12-23 23:28:46 +08:00
|
|
|
$mock->shouldReceive('delete')->with(storage_path('options.php'))->once();
|
2019-08-21 23:46:38 +08:00
|
|
|
$mock->shouldReceive('put')
|
2019-08-22 08:50:59 +08:00
|
|
|
->withArgs(function ($path, $content) {
|
2019-12-23 23:28:46 +08:00
|
|
|
$this->assertEquals(storage_path('options.php'), $path);
|
|
|
|
$this->assertTrue(Str::startsWith($content, '<?php'.PHP_EOL));
|
2019-08-22 08:50:59 +08:00
|
|
|
$this->assertTrue(Str::endsWith($content, ';'));
|
2019-08-21 23:46:38 +08:00
|
|
|
|
|
|
|
return true;
|
|
|
|
})
|
|
|
|
->once();
|
2019-08-22 08:50:59 +08:00
|
|
|
});
|
2019-08-21 23:46:38 +08:00
|
|
|
|
|
|
|
$this->artisan('options:cache')->expectsOutput('Options cached successfully.');
|
|
|
|
}
|
|
|
|
}
|