Completed
Pull Request — master (#5776)
by Damian
10:49
created

PopoverFieldTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 24
rs 10
wmc 1
lcom 0
cbo 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A testPopoverField() 0 21 1
1
<?php
2
3
class PopoverFieldTest extends SapphireTest
4
{
5
	public function testPopoverField() {
6
		// Test normal constructor
7
		$field = new PopoverField('My Title', [
8
			new TextField('Name')
9
		]);
10
		$field->setPopoverTitle('Popover Title');
11
		$this->assertEquals('My Title', $field->Title());
12
		$this->assertEquals('Popover Title', $field->getPopoverTitle());
13
		$this->assertEquals('Name', $field->getChildren()->first()->Title());
14
15
		// Test single array argument
16
		$field2 = new PopoverField([ new TextField('Other')]);
17
		$this->assertEmpty($field2->Title());
18
		$this->assertEquals('Other', $field2->getChildren()->first()->Title());
19
20
		// Test variable length constructor
21
		$field3 = new PopoverField('Field Title', new TextField('First'), new TextField('Second'));
22
		$this->assertEquals('Field Title', $field3->Title());
23
		$this->assertEquals('First', $field3->getChildren()->first()->Title());
24
		$this->assertEquals('Second', $field3->getChildren()->last()->Title());
25
	}
26
}
27