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

AutoCompleteOptionTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1
Metric Value
dl 0
loc 4
ccs 4
cts 4
cp 1
rs 10
cc 1
eloc 3
nc 1
nop 0
crap 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