Newer
Older
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
<?php
namespace Breyta\Test\Migration;
use Breyta\Adapter\BasicAdapter;
use Breyta\Migration\CreateMigrationTable;
use Breyta\Test\TestCase;
use Mockery as m;
class CreateMigrationTableTest extends TestCase
{
/** @test */
public function createsATable()
{
$adapter = m::mock(BasicAdapter::class)->shouldIgnoreMissing();
$migration = new CreateMigrationTable($adapter);
$migration->up();
$adapter->shouldHaveReceived('exec')->with(m::pattern('/create table migrations/i'))->once();
}
/** @test */
public function createIndexesOnMigrationTable()
{
$adapter = m::mock(BasicAdapter::class)->shouldIgnoreMissing();
$migration = new CreateMigrationTable($adapter);
$migration->up();
$adapter->shouldHaveReceived('exec')
->with(m::pattern('/create index.* on migrations\s*\(\s*executed\s*\)/i'))
->once();
$adapter->shouldHaveReceived('exec')
->with(m::pattern('/create index.* on migrations\s*\(\s*status\s*\)/i'))
->once();
$adapter->shouldHaveReceived('exec')
->with(m::pattern('/create index.* on migrations\s*\(\s*executionTime\s*\)/i'))
->once();
}
/** @test */
public function dropsTheMigrationTable()
{
$adapter = m::mock(BasicAdapter::class)->shouldIgnoreMissing();
$migration = new CreateMigrationTable($adapter);
$migration->down();
$adapter->shouldHaveReceived('exec')->with(m::pattern('/drop table migrations/i'));
}
}