Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?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';
- }
- /**
- * Migrate the database
- */
- private function prepareForTests()
- {
- Artisan::call('migrate');
- }
- /**
- * Username is required
- */
- public function testUsernameIsRequired()
- {
- // Create a new User
- $user = new User;
- $user->user_email = 'test@test.se';
- $user->password = 'password';
- $user->password_confirmation = 'password';
- // User should not save
- $this->assertFalse($user->save());
- // Save the errors
- $errors = $user->errors()->all();
- // There should be 1 error
- $this->assertCount(1, $errors);
- // The username error should be set
- $this->assertEquals($errors[0], 'The username field is required');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement