12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- namespace Illuminate\Tests\Cache;
- use Illuminate\Cache\Console\CacheTableCommand;
- use Illuminate\Database\Migrations\MigrationCreator;
- use Illuminate\Filesystem\Filesystem;
- use Illuminate\Foundation\Application;
- use Illuminate\Support\Composer;
- use Mockery as m;
- use PHPUnit\Framework\TestCase;
- use Symfony\Component\Console\Input\ArrayInput;
- use Symfony\Component\Console\Output\NullOutput;
- class CacheTableCommandTest extends TestCase
- {
- protected function tearDown(): void
- {
- m::close();
- }
- public function testCreateMakesMigration()
- {
- $command = new CacheTableCommandTestStub(
- $files = m::mock(Filesystem::class),
- $composer = m::mock(Composer::class)
- );
- $creator = m::mock(MigrationCreator::class)->shouldIgnoreMissing();
- $app = new Application;
- $app->useDatabasePath(__DIR__);
- $app['migration.creator'] = $creator;
- $command->setLaravel($app);
- $path = __DIR__.'/migrations';
- $creator->shouldReceive('create')->once()->with('create_cache_table', $path)->andReturn($path);
- $files->shouldReceive('get')->once()->andReturn('foo');
- $files->shouldReceive('put')->once()->with($path, 'foo');
- $composer->shouldReceive('dumpAutoloads')->once();
- $this->runCommand($command);
- }
- protected function runCommand($command, $input = [])
- {
- return $command->run(new ArrayInput($input), new NullOutput);
- }
- }
- class CacheTableCommandTestStub extends CacheTableCommand
- {
- public function call($command, array $arguments = [])
- {
- return 0;
- }
- }
|