Task_DB_Test_Load   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 31
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B _execute() 0 28 3
1
<?php defined('SYSPATH') OR die('No direct script access.');
2
3
/**
4
 * Load the latest structure to the test database.
5
 * Will also load all the sql files from test/test_data/structure/test-schema-<type>.sql
6
 * where <type> is based on the test database type.
7
 */
8
class Task_DB_Test_Load extends Minion_Database {
9
10
	protected function _execute(array $options)
11
	{
12
		$db = $this->db_params(Kohana::TESTING);
13
14
		Minion_Task::factory(array(
15
				'task' => 'db:structure:load',
16
				'database' => Kohana::TESTING,
17
				'force' => NULL,
18
				'file' => NULL,
19
			))
20
			->execute();
21
22
		$structure_files = array_filter(array_map(function($dir) use ($db) {
23
			$file = $dir.'tests'.DIRECTORY_SEPARATOR.'database'.DIRECTORY_SEPARATOR.'structure'.DIRECTORY_SEPARATOR.strtolower($db['type']).'.sql';
24
			return is_file($file) ? $file : NULL;
25
		}, Kohana::modules()));
26
27
		foreach ($structure_files as $schema)
28
		{
29
			Minion_Task::factory(array(
30
				'task' => 'db:structure:load',
31
				'database' => Kohana::TESTING,
32
				'force' => NULL,
33
				'file' => $schema,
34
			))
35
			->execute();
36
		}
37
	}
38
}
39