Skip to content

Instantly share code, notes, and snippets.

Created June 24, 2013 12:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/5849706 to your computer and use it in GitHub Desktop.
Save anonymous/5849706 to your computer and use it in GitHub Desktop.
Non-working Laravel test
<?php
return array(
'default' => 'sqlite',
'connections' => array(
'sqlite' => array(
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
)
)
);
$ vendor/bin/phpunit
PHPUnit 3.8-dev by Sebastian Bergmann.
Configuration read from /Users/learning/PhpstormProjects/laravel_test/phpunit.xml
.PHP Fatal error: Call to undefined method User::save() in /Users/learning/PhpstormProjects/laravel_test/app/tests/UserTest.php on line 8
User is Eloquent: YES
Fatal error: Call to undefined method User::save() in /Users/learning/PhpstormProjects/laravel_test/app/tests/UserTest.php on line 8
<?php
class TestCase extends Illuminate\Foundation\Testing\TestCase {
public function setUp()
{
parent::setUp();
$this->prepareForTests();
}
/**
* Creates the application.
*
* @return Symfony\Component\HttpKernel\HttpKernelInterface
*/
public function createApplication()
{
$unitTesting = true;
$testEnvironment = 'testing';
return require __DIR__.'/../../bootstrap/start.php';
}
private function prepareForTests()
{
Artisan::call('migrate');
}
}
<?php
class UserTest extends TestCase {
public function testUserNameIsAlwaysUppercase()
{
$user = new User();
print "User is Eloquent: " . ($user instanceof Eloquent ? "YES" : "NO") . "\n";
$user->save();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment