<commit_before><?php

use Mockery as m;
use Jaybizzle\MigrationsOrganiser\MigrationCreator;

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('{{class}}');
		$creator->getFilesystem()->shouldReceive('exists')->once()->shouldReceive('makeDirectory')->once()->shouldReceive('put')->once()->with('foo/'.date('Y').'/'.date('m').'/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('{{class}} {{table}}');
		$creator->getFilesystem()->shouldReceive('exists')->once()->shouldReceive('makeDirectory')->shouldReceive('put')->once()->with('foo/'.date('Y').'/'.date('m').'/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('{{class}} {{table}}');
		$creator->getFilesystem()->shouldReceive('exists')->once()->shouldReceive('makeDirectory')->shouldReceive('put')->once()->with('foo/'.date('Y').'/'.date('m').'/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('Jaybizzle\MigrationsOrganiser\MigrationCreator', array('getDatePrefix'), array($files));
	}

}<commit_msg>Fixed tests for Illuminate 5.1<commit_after><?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('exists')->once()->shouldReceive('makeDirectory')->once()->shouldReceive('put')->once()->with('foo/'.date('Y').'/'.date('m').'/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('exists')->once()->shouldReceive('makeDirectory')->shouldReceive('put')->once()->with('foo/'.date('Y').'/'.date('m').'/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('exists')->once()->shouldReceive('makeDirectory')->shouldReceive('put')->once()->with('foo/'.date('Y').'/'.date('m').'/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('Jaybizzle\MigrationsOrganiser\MigrationCreator', array('getDatePrefix'), array($files));
	}

}
{'fraction_non_alphanumeric': 0.23583333333333334, 'fraction_numerical': 0.0004166666666666667, 'mean_word_length': 7.7290909090909095, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 131, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5192532', 'n_tokens_mistral': 1609, 'n_tokens_neox': 1511, 'n_words': 142}