forked from laravel/framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSessionTableCommandTest.php
More file actions
55 lines (47 loc) · 1.61 KB
/
SessionTableCommandTest.php
File metadata and controls
55 lines (47 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
namespace Illuminate\Tests\Session;
use Illuminate\Database\Migrations\MigrationCreator;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Foundation\Application;
use Illuminate\Session\Console\SessionTableCommand;
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 SessionTableCommandTest extends TestCase
{
protected function tearDown(): void
{
m::close();
}
public function testCreateMakesMigration()
{
$command = new SessionTableCommandTestStub(
$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_sessions_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 SessionTableCommandTestStub extends SessionTableCommand
{
public function call($command, array $arguments = [])
{
return 0;
}
}