TestCase::createApplication()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
crap 1
1
<?php
2
3
class TestCase extends Illuminate\Foundation\Testing\TestCase {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
5
	public $dbSeeded = false;
6
	
7
	/**
8
	 * Creates the application.
9
	 *
10
	 * @return \Symfony\Component\HttpKernel\HttpKernelInterface
11
	 */
12 9
	public function createApplication() {
13 9
		$unitTesting = true;
14
15 9
		$testEnvironment = 'testing';
16
17 9
		return require __DIR__ . '/../../bootstrap/start.php';
18
	}
19
20 9
	public function seedDatabase() {
21 9
		$this->app['artisan']->call('migrate');
22 9
		$this->app['artisan']->call('db:seed');
23 9
		$this->dbSeeded = true;
24 9
	}
25
26
27
	/**
28
	 * Start database transaction to speed up the tests related to database
29
	 */
30 9
	public function setUp() {
31 9
		parent::setUp();
32
33 9
		if (! $this->dbSeeded) {
34 9
			$this->seedDatabase();
35 9
		}
36
37 9
		DB::beginTransaction();
38 9
	}
39
40
	/**
41
	 * After test roll back all done stuff
42
	 */
43 9
	public function tearDown() {
44 9
		parent::tearDown();
45
46 9
		DB::rollBack();
47 9
	}
48
}
49