-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestCase.php
More file actions
executable file
·88 lines (72 loc) · 2.16 KB
/
TestCase.php
File metadata and controls
executable file
·88 lines (72 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
namespace Tests;
use Medlib\Models\User;
use Medlib\Models\Profile;
use Medlib\Models\Timeline;
use Tests\Traits\TestHelpers;
use Laracasts\TestDummy\Factory;
use Illuminate\Support\Facades\DB;
use Tests\Traits\DatabaseMigrations;
use Tests\Traits\CreatesApplication;
use Illuminate\Support\Facades\Session;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase
{
use TestHelpers, CreatesApplication, WithoutMiddleware, DatabaseMigrations;
/**
* @var \Illuminate\Session\SessionManager
*/
protected $manager;
/**
* Settings the environment test
* @return void
*/
public function setUp()
{
parent::setUp();
/**
* Avoid "Session store not set on request." - Exception!
* @see http://laravel-tricks.com/tricks/unit-test-session-store-not-set-on-request
* Session::setDefaultDriver('array');
* Session::start();
*/
$this->manager = app('session');
}
/**
* Resetting all information this environment test
* @return void
*/
public function tearDown()
{
parent::tearDown();
$this->artisanMigrateReset();
}
/**
* @return User
*/
public function getUser()
{
$timeline = Factory::create(Timeline::class);
list($first_name, $last_name) = explode(' ', $timeline->name);
$user = Factory::create(User::class, [
'timeline_id' => $timeline->id,
'username' => $timeline->id,
'first_name' => $first_name,
'last_name' => $last_name
]);
$user->profile()->save(
factory(Profile::class)->make()
);
$user_settings = [
'user_id' => $user->id,
'confirm_follow' => 'no',
'follow_privacy' => 'everyone',
'comment_privacy' => 'everyone',
'timeline_post_privacy' => 'only_follow',
'post_privacy' => 'everyone',];
DB::table('user_settings')->insert($user_settings);
$user->roles()->attach(1);
return $user;
}
}