Skip to content

Commit

Permalink
Merge pull request #36 from dmitryuk/Laravel-8
Browse files Browse the repository at this point in the history
6.x branch laravel 8 support
  • Loading branch information
JayBizzle committed Oct 17, 2020
2 parents 339a954 + db460a4 commit 8b2b037
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 27 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ language: php

matrix:
include:
- php: 7.2.5
- php: 7.3
- php: 7.4
- php: nightly
allow_failures:
- php: nightly
fast_finish: true
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Versions
========
- Laravel 5.3-6.* use `v4.*`
- Laravel 7.* use `v5.*`
- Laravel 8.* use `v6.*`

Installation
============
Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
}
],
"require": {
"php": "^7.2.5",
"illuminate/support": "^7.0"
"php": "^7.3",
"illuminate/support": "^8.0"
},
"autoload": {
"psr-4": {
Expand All @@ -24,9 +24,9 @@
},
"require-dev": {
"mockery/mockery": "^1.3.1",
"phpunit/phpunit": "^8.4|^9.0",
"illuminate/database": "^7.0",
"illuminate/filesystem": "^7.0"
"phpunit/phpunit": "^9.3",
"illuminate/database": "^8.0",
"illuminate/filesystem": "^8.0"
},
"extra": {
"laravel": {
Expand Down
47 changes: 27 additions & 20 deletions tests/MigrationCreatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ public function testBasicCreateMethodStoresMigrationFile()
{
$creator = $this->getCreator();

$date = date('Y').'/'.date('m');
$creator->expects($this->any())->method('getDatePrefix')->willReturn('foo');
$creator->getFilesystem()->shouldReceive('exists')->once()->with('stubs/migration.stub')->andReturn(false);
$creator->getFilesystem()->shouldReceive('get')->once()->with($creator->stubPath().'/migration.stub')->andReturn('DummyClass');
$creator->getFilesystem()->shouldReceive('exists')->once()->with('foo/2020/03')->andReturn(false);
$creator->getFilesystem()->shouldReceive('exists')->once()->with('foo/'.$date)->andReturn(false);
$creator->getFilesystem()->shouldReceive('makeDirectory')->once();
$creator->getFilesystem()->shouldReceive('put')->once()->with('foo/2020/03/foo_create_bar.php', 'CreateBar');
$creator->getFilesystem()->shouldReceive('glob')->once()->with('foo/2020/03/*.php')->andReturn(['foo/2020/03/foo_create_bar.php']);
$creator->getFilesystem()->shouldReceive('requireOnce')->once()->with('foo/2020/03/foo_create_bar.php');
$creator->getFilesystem()->shouldReceive('ensureDirectoryExists')->andReturn(true);
$creator->getFilesystem()->shouldReceive('put')->once()->with('foo/'.$date.'/foo_create_bar.php', 'CreateBar');
$creator->getFilesystem()->shouldReceive('glob')->once()->with('foo/'.$date.'/*.php')->andReturn(['foo/'.$date.'/foo_create_bar.php']);
$creator->getFilesystem()->shouldReceive('requireOnce')->once()->with('foo/'.$date.'/foo_create_bar.php');

$creator->create('create_bar', 'foo');
}
Expand All @@ -40,15 +42,16 @@ public function testBasicCreateMethodCallsPostCreateHooks()
$creator->afterCreate(function ($table) {
$_SERVER['__migration.creator'] = $table;
});

$date = date('Y').'/'.date('m');
$creator->expects($this->any())->method('getDatePrefix')->willReturn('foo');
$creator->getFilesystem()->shouldReceive('exists')->once()->with('stubs/migration.update.stub')->andReturn(false);
$creator->getFilesystem()->shouldReceive('get')->once()->with($creator->stubPath().'/migration.update.stub')->andReturn('DummyClass DummyTable');
$creator->getFilesystem()->shouldReceive('exists')->once()->with('foo/2020/03')->andReturn(false);
$creator->getFilesystem()->shouldReceive('exists')->once()->with('foo/'.$date)->andReturn(false);
$creator->getFilesystem()->shouldReceive('makeDirectory')->once();
$creator->getFilesystem()->shouldReceive('put')->once()->with('foo/2020/03/foo_create_bar.php', 'CreateBar baz');
$creator->getFilesystem()->shouldReceive('glob')->once()->with('foo/2020/03/*.php')->andReturn(['foo/2020/03/foo_create_bar.php']);
$creator->getFilesystem()->shouldReceive('requireOnce')->once()->with('foo/2020/03/foo_create_bar.php');
$creator->getFilesystem()->shouldReceive('ensureDirectoryExists')->andReturn(true);
$creator->getFilesystem()->shouldReceive('put')->once()->with('foo/'.$date.'/foo_create_bar.php', 'CreateBar baz');
$creator->getFilesystem()->shouldReceive('glob')->once()->with('foo/'.$date.'/*.php')->andReturn(['foo/'.$date.'/foo_create_bar.php']);
$creator->getFilesystem()->shouldReceive('requireOnce')->once()->with('foo/'.$date.'/foo_create_bar.php');

$creator->create('create_bar', 'foo', $table);

Expand All @@ -60,29 +63,33 @@ public function testBasicCreateMethodCallsPostCreateHooks()
public function testTableUpdateMigrationStoresMigrationFile()
{
$creator = $this->getCreator();
$date = date('Y').'/'.date('m');
$creator->expects($this->any())->method('getDatePrefix')->willReturn('foo');
$creator->getFilesystem()->shouldReceive('exists')->once()->with('stubs/migration.update.stub')->andReturn(false);
$creator->getFilesystem()->shouldReceive('get')->once()->with($creator->stubPath().'/migration.update.stub')->andReturn('DummyClass DummyTable');
$creator->getFilesystem()->shouldReceive('exists')->once()->with('foo/2020/03')->andReturn(false);
$creator->getFilesystem()->shouldReceive('exists')->once()->with('foo/'.$date)->andReturn(false);
$creator->getFilesystem()->shouldReceive('makeDirectory')->once();
$creator->getFilesystem()->shouldReceive('put')->once()->with('foo/2020/03/foo_create_bar.php', 'CreateBar baz');
$creator->getFilesystem()->shouldReceive('glob')->once()->with('foo/2020/03/*.php')->andReturn(['foo/2020/03/foo_create_bar.php']);
$creator->getFilesystem()->shouldReceive('requireOnce')->once()->with('foo/2020/03/foo_create_bar.php');
$creator->getFilesystem()->shouldReceive('ensureDirectoryExists')->andReturn(true);
$creator->getFilesystem()->shouldReceive('put')->once()->with('foo/'.$date.'/foo_create_bar.php', 'CreateBar baz');
$creator->getFilesystem()->shouldReceive('glob')->once()->with('foo/'.$date.'/*.php')->andReturn(['foo/'.$date.'/foo_create_bar.php']);
$creator->getFilesystem()->shouldReceive('requireOnce')->once()->with('foo/'.$date.'/foo_create_bar.php');

$creator->create('create_bar', 'foo', 'baz');
}

public function testTableCreationMigrationStoresMigrationFile()
{
$creator = $this->getCreator();
$date = date('Y').'/'.date('m');
$creator->expects($this->any())->method('getDatePrefix')->willReturn('foo');
$creator->getFilesystem()->shouldReceive('exists')->once()->with('stubs/migration.create.stub')->andReturn(false);
$creator->getFilesystem()->shouldReceive('get')->once()->with($creator->stubPath().'/migration.create.stub')->andReturn('DummyClass DummyTable');
$creator->getFilesystem()->shouldReceive('exists')->once()->with('foo/2020/03')->andReturn(false);
$creator->getFilesystem()->shouldReceive('exists')->once()->with('foo/'.$date)->andReturn(false);
$creator->getFilesystem()->shouldReceive('makeDirectory')->once();
$creator->getFilesystem()->shouldReceive('put')->once()->with('foo/2020/03/foo_create_bar.php', 'CreateBar baz');
$creator->getFilesystem()->shouldReceive('glob')->once()->with('foo/2020/03/*.php')->andReturn(['foo/2020/03/foo_create_bar.php']);
$creator->getFilesystem()->shouldReceive('requireOnce')->once()->with('foo/2020/03/foo_create_bar.php');
$creator->getFilesystem()->shouldReceive('ensureDirectoryExists')->andReturn(true);
$creator->getFilesystem()->shouldReceive('put')->once()->with('foo/'.$date.'/foo_create_bar.php', 'CreateBar baz');
$creator->getFilesystem()->shouldReceive('glob')->once()->with('foo/'.$date.'/*.php')->andReturn(['foo/'.$date.'/foo_create_bar.php']);
$creator->getFilesystem()->shouldReceive('requireOnce')->once()->with('foo/'.$date.'/foo_create_bar.php');

$creator->create('create_bar', 'foo', 'baz', true);
}
Expand All @@ -93,9 +100,9 @@ public function testTableUpdateMigrationWontCreateDuplicateClass()
$this->expectExceptionMessage('A MigrationCreatorFakeMigration class already exists.');

$creator = $this->getCreator();

$creator->getFilesystem()->shouldReceive('glob')->once()->with('foo/2020/03/*.php')->andReturn(['foo/2020/03/foo_create_bar.php']);
$creator->getFilesystem()->shouldReceive('requireOnce')->once()->with('foo/2020/03/foo_create_bar.php');
$date = date('Y').'/'.date('m');
$creator->getFilesystem()->shouldReceive('glob')->once()->with('foo/'.$date.'/*.php')->andReturn(['foo/'.$date.'/foo_create_bar.php']);
$creator->getFilesystem()->shouldReceive('requireOnce')->once()->with('foo/'.$date.'/foo_create_bar.php');

$creator->create('migration_creator_fake_migration', 'foo');
}
Expand Down

0 comments on commit 8b2b037

Please sign in to comment.