forked from laravel/framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDatabaseMigrationCreatorTest.php
More file actions
executable file
·54 lines (42 loc) · 2.16 KB
/
DatabaseMigrationCreatorTest.php
File metadata and controls
executable file
·54 lines (42 loc) · 2.16 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
<?php
use Mockery as m;
class DatabaseMigrationCreatorTest extends PHPUnit_Framework_TestCase
{
public function tearDown()
{
m::close();
}
public function testBasicCreateMethodStoresMigrationFile()
{
$creator = $this->getCreator();
unset($_SERVER['__migration.creator']);
$creator->afterCreate(function () { $_SERVER['__migration.creator'] = true; });
$creator->expects($this->any())->method('getDatePrefix')->will($this->returnValue('foo'));
$creator->getFilesystem()->shouldReceive('get')->once()->with($creator->getStubPath().'/blank.stub')->andReturn('DummyClass');
$creator->getFilesystem()->shouldReceive('put')->once()->with('foo/foo_create_bar.php', 'CreateBar');
$creator->create('create_bar', 'foo');
$this->assertTrue($_SERVER['__migration.creator']);
unset($_SERVER['__migration.creator']);
}
public function testTableUpdateMigrationStoresMigrationFile()
{
$creator = $this->getCreator();
$creator->expects($this->any())->method('getDatePrefix')->will($this->returnValue('foo'));
$creator->getFilesystem()->shouldReceive('get')->once()->with($creator->getStubPath().'/update.stub')->andReturn('DummyClass DummyTable');
$creator->getFilesystem()->shouldReceive('put')->once()->with('foo/foo_create_bar.php', 'CreateBar baz');
$creator->create('create_bar', 'foo', 'baz');
}
public function testTableCreationMigrationStoresMigrationFile()
{
$creator = $this->getCreator();
$creator->expects($this->any())->method('getDatePrefix')->will($this->returnValue('foo'));
$creator->getFilesystem()->shouldReceive('get')->once()->with($creator->getStubPath().'/create.stub')->andReturn('DummyClass DummyTable');
$creator->getFilesystem()->shouldReceive('put')->once()->with('foo/foo_create_bar.php', 'CreateBar baz');
$creator->create('create_bar', 'foo', 'baz', true);
}
protected function getCreator()
{
$files = m::mock('Illuminate\Filesystem\Filesystem');
return $this->getMock('Illuminate\Database\Migrations\MigrationCreator', ['getDatePrefix'], [$files]);
}
}