Passed
Pull Request — master (#12)
by Robbie
04:58 queued 01:01
created

WorkflowDefinitionExtensionTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testCreateDefaultWorkflowTest() 0 16 1
1
<?php
2
3
namespace CWP\CWP\Tests\Extensions;
4
5
6
7
8
9
use WorkflowDefinition;
0 ignored issues
show
Bug introduced by
The type WorkflowDefinition was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use SilverStripe\ORM\DB;
11
use SilverStripe\Core\Config\Config;
12
use CWP\CWP\Extensions\CwpWorkflowDefinitionExtension;
13
use SilverStripe\Core\Injector\Injector;
14
use SilverStripe\Dev\FunctionalTest;
15
16
17
/**
18
 * Tests the data extension {@link: CWPWorkflowDefinitionExtension}
19
 *
20
 * @package framework
21
 * @subpackage tests
22
 */
23
class WorkflowDefinitionExtensionTest extends FunctionalTest {
24
25
	/**
26
	 * @var Boolean If set to TRUE, this will force a test database to be generated
27
	 * in {@link setUp()}. Note that this flag is overruled by the presence of a
28
	 * {@link $fixture_file}, which always forces a database build.
29
	 */
30
	protected $usesDatabase = true;
31
	
32
	/**
33
	 * Tests the config option that controls the creation of a default workflow definition
34
	 *
35
	 * @return void
36
	 */
37
	public function testCreateDefaultWorkflowTest() {
38
		DB::quiet();
39
		
40
		// test disabling the default workflow definition
41
		Config::inst()->update(CwpWorkflowDefinitionExtension::class, 'create_default_workflow', false);
0 ignored issues
show
Bug introduced by
The method update() does not exist on SilverStripe\Config\Coll...nfigCollectionInterface. It seems like you code against a sub-type of SilverStripe\Config\Coll...nfigCollectionInterface such as SilverStripe\Config\Coll...\MemoryConfigCollection. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

41
		Config::inst()->/** @scrutinizer ignore-call */ update(CwpWorkflowDefinitionExtension::class, 'create_default_workflow', false);
Loading history...
42
		$workflowExtn = Injector::inst()->create(CwpWorkflowDefinitionExtension::class);
43
		$workflowExtn->requireDefaultRecords();
44
		$definition = WorkflowDefinition::get()->first();
45
		$this->assertNull($definition);
46
47
		// test enabling the default workflow definition
48
		Config::inst()->update(CwpWorkflowDefinitionExtension::class, 'create_default_workflow', true);
49
		$workflowExtn = Injector::inst()->create(CwpWorkflowDefinitionExtension::class);
50
		$workflowExtn->requireDefaultRecords();
51
		$definition = WorkflowDefinition::get()->first();
52
		$this->assertNotNull($definition);
53
	}
54
}
55