Completed
Push — dev2 ( 507d7b...9f9038 )
by Gordon
11:12
created

AutoCompleteOptionTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%
Metric Value
wmc 5
lcom 1
cbo 3
dl 0
loc 45
ccs 0
cts 26
cp 0
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A testCanCreate() 0 4 1
A testCanDelete() 0 4 1
A testCanEdit() 0 4 1
A testRequireDefaultRecords() 0 13 1
1
<?php
2
3
class AutoCompleteOptionTest extends ElasticsearchBaseTest {
4
5
	public function setUp() {
6
		$this->AutoCompleteOption = new AutoCompleteOption();
0 ignored issues
show
Bug introduced by
The property AutoCompleteOption does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
7
		parent::setUp();
8
	}
9
10
	public function testCanCreate() {
11
		$this->assertFalse($this->AutoCompleteOption->can_create(), 'CMS users should not be able to
12
				create this');
13
	}
14
15
	public function testCanDelete() {
16
		$this->assertFalse($this->AutoCompleteOption->can_delete(), 'CMS users should not be able to
17
				delete this');
18
	}
19
20
	public function testCanEdit() {
21
		$this->assertFalse($this->AutoCompleteOption->can_edit(), 'CMS users should not be able to
22
				edit this');
23
	}
24
25
26
	/*
27
	Check that requireDefaultRecords only creates 3 options
28
	- similar
29
	- search
30
	- go to record
31
	 */
32
	public function testRequireDefaultRecords() {
33
		$this->AutoCompleteOption->requireDefaultRecords();
34
35
		$similar = AutoCompleteOption::get()->filter('Name','Similar')->first();
36
		$this->assertEquals(1, $similar->ID);
37
38
		$search = AutoCompleteOption::get()->filter('Name','Search')->first();
39
		$this->assertEquals(2, $search->ID);
40
41
		$goto = AutoCompleteOption::get()->filter('Name','GoToRecord')->first();
42
		$this->assertEquals(3, $goto->ID);
43
44
	}
45
46
47
}
48