Passed
Push — master ( d7fd6a...9124ff )
by Robbie
11:58
created

testCreateDefaultWorkflowTest()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 11
nc 1
nop 0
1
<?php
2
/**
3
 * Tests the data extension {@link: CWPWorkflowDefinitionExtension}
4
 *
5
 * @package framework
6
 * @subpackage tests
7
 */
8
class WorkflowDefinitionExtensionTest extends FunctionalTest {
9
10
	/**
11
	 * @var Boolean If set to TRUE, this will force a test database to be generated
12
	 * in {@link setUp()}. Note that this flag is overruled by the presence of a
13
	 * {@link $fixture_file}, which always forces a database build.
14
	 */
15
	protected $usesDatabase = true;
16
	
17
	/**
18
	 * Tests the config option that controls the creation of a default workflow definition
19
	 *
20
	 * @return void
21
	 */
22
	public function testCreateDefaultWorkflowTest() {
23
		DB::quiet();
24
		
25
		// test disabling the default workflow definition
26
		Config::inst()->update('CwpWorkflowDefinitionExtension', 'create_default_workflow', false);
27
		$workflowExtn = Injector::inst()->create('CwpWorkflowDefinitionExtension');
28
		$workflowExtn->requireDefaultRecords();
29
		$definition = WorkflowDefinition::get()->first();
30
		$this->assertNull($definition);
31
32
		// test enabling the default workflow definition
33
		Config::inst()->update('CwpWorkflowDefinitionExtension', 'create_default_workflow', true);
34
		$workflowExtn = Injector::inst()->create('CwpWorkflowDefinitionExtension');
35
		$workflowExtn->requireDefaultRecords();
36
		$definition = WorkflowDefinition::get()->first();
37
		$this->assertNotNull($definition);
38
	}
39
}
40