Attendize/tests/TestCase.php

90 lines
1.9 KiB
PHP
Raw Normal View History

2016-02-29 15:59:36 +00:00
<?php
2016-04-26 23:08:27 +00:00
use App\Models\Timezone;
2016-04-27 23:06:17 +00:00
use App\Models\User;
2016-04-26 23:08:27 +00:00
2016-03-05 00:18:10 +00:00
class TestCase extends Illuminate\Foundation\Testing\TestCase
{
2016-04-26 21:33:16 +00:00
/**
* The base URL to use while testing the application.
*
* @var string
*/
2016-04-27 23:06:17 +00:00
protected $baseUrl = 'http://localhost/public';
/**
* Email for the test user
*
* @var string
*/
protected $test_user_email = 'test@test.test';
/**
* Password for the test user
*
* @var string
*/
protected $test_user_password = 'testtest';
/**
* Our test user
2016-06-16 01:36:09 +00:00
*
2016-04-27 23:06:17 +00:00
* @var
*/
protected $test_user;
/**
* Our faker instance
2016-06-16 01:36:09 +00:00
*
2016-04-27 23:06:17 +00:00
* @var
*/
protected $faker;
2016-03-05 00:18:10 +00:00
/**
* Creates the application.
*
* @return \Illuminate\Foundation\Application
*/
public function createApplication()
{
$app = require __DIR__.'/../bootstrap/app.php';
2016-04-26 23:08:27 +00:00
$app->loadEnvironmentFrom('.env.testing');
2016-04-26 21:33:16 +00:00
$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
2016-03-05 00:18:10 +00:00
return $app;
}
2016-04-26 23:08:27 +00:00
public function setUp(){
parent::setUp();
2016-04-27 23:06:17 +00:00
/*
* Set up faker
*/
$this->faker = Faker\Factory::create();
/*
* Migrate & Seed the DB
*/
Artisan::call('migrate');
2016-04-26 23:08:27 +00:00
if (Timezone::count() == 0) {
2016-04-27 23:06:17 +00:00
Artisan::call('db:seed', ['--force' => true]);
2016-04-26 23:08:27 +00:00
}
2016-04-27 23:06:17 +00:00
/*
* Set up our test user
*/
if(User::where('email','=','test@test.test')->count() === 0) {
$this->test_user = factory(App\Models\User::class)->create([
'email' => $this->test_user_email,
'password' => Hash::make($this->test_user_password),
]);
} else {
$this->test_user = User::where('email','=','test@test.test')->first();
}
2016-04-26 23:08:27 +00:00
}
public function tearDown(){
parent::tearDown();
}
2016-04-26 21:33:16 +00:00
}