Completed
Push — dev2 ( 774f9d...0919fb )
by Gordon
05:50
created

AutoCompleteOptionTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%
Metric Value
wmc 5
lcom 1
cbo 3
dl 0
loc 45
ccs 25
cts 25
cp 1
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 4
	public function setUp() {
6 4
		$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 4
		parent::setUp();
8 4
	}
9
10 1
	public function testCanCreate() {
11 1
		$this->assertFalse($this->AutoCompleteOption->can_create(), 'CMS users should not be able to
12 1
				create this');
13 1
	}
14
15 1
	public function testCanDelete() {
16 1
		$this->assertFalse($this->AutoCompleteOption->can_delete(), 'CMS users should not be able to
17 1
				delete this');
18 1
	}
19
20 1
	public function testCanEdit() {
21 1
		$this->assertFalse($this->AutoCompleteOption->can_edit(), 'CMS users should not be able to
22 1
				edit this');
23 1
	}
24
25
26
	/*
27
	Check that requireDefaultRecords only creates 3 options
28
	- similar
29
	- search
30
	- go to record
31
	 */
32 1
	public function testRequireDefaultRecords() {
33 1
		$this->AutoCompleteOption->requireDefaultRecords();
34
35 1
		$similar = AutoCompleteOption::get()->filter('Name','Similar')->first();
36 1
		$this->assertEquals(1, $similar->ID);
37
38 1
		$search = AutoCompleteOption::get()->filter('Name','Search')->first();
39 1
		$this->assertEquals(2, $search->ID);
40
41 1
		$goto = AutoCompleteOption::get()->filter('Name','GoToRecord')->first();
42 1
		$this->assertEquals(3, $goto->ID);
43
44 1
	}
45
46
47
}
48