Better mocking of objects.

This commit is contained in:
James Cole
2016-01-23 06:59:22 +01:00
parent bf9c1c1875
commit 0d5efb8d27
3 changed files with 31 additions and 33 deletions

View File

@@ -28,14 +28,6 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase
return $app;
}
/**
* @return User
*/
public function user()
{
return User::find(1);
}
/**
* @return User
*/
@@ -44,7 +36,6 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase
return User::find(2);
}
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
@@ -65,7 +56,7 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase
touch($original);
Artisan::call('migrate', ['--seed' => true]);
}
copy($original, $copy);
} else {
if (file_exists($copy)) {
@@ -99,5 +90,28 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase
}
/**
* @return User
*/
public function user()
{
return User::find(1);
}
/**
* @param string $class
*
* @return \Mockery\MockInterface
*/
protected function mock($class)
{
$object = Mockery::mock($class);
$this->app->instance($class, $object);
return $object;
}
}