1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
class FormBlockTest extends SapphireTest |
4
|
|
|
{ |
5
|
|
|
/** |
6
|
|
|
* @var string |
7
|
|
|
*/ |
8
|
|
|
protected static $fixture_file = 'dynamic-blocks/tests/Fixtures.yml'; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* |
12
|
|
|
*/ |
13
|
|
|
public function testGetPluralName() |
14
|
|
|
{ |
15
|
|
|
$object = singleton('FormBlock'); |
16
|
|
|
$this->assertEquals('Form Blocks', $object->plural_name()); |
|
|
|
|
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* |
21
|
|
|
*/ |
22
|
|
|
public function testGetCMSFields() |
23
|
|
|
{ |
24
|
|
|
$object = $this->objFromFixture('FormBlock', 'one'); |
25
|
|
|
$fields = $object->getCMSFields(); |
26
|
|
|
$this->assertInstanceOf('FieldList', $fields); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* |
31
|
|
|
*/ |
32
|
|
|
public function testBlockForm() |
33
|
|
|
{ |
34
|
|
|
if (class_exists('UserDefinedForm')) { |
35
|
|
|
$object = $this->objFromFixture('FormBlock', 'one'); |
36
|
|
|
$form = $object->Form(); |
37
|
|
|
$this->assertInstanceOf('UserDefinedForm', $form); |
38
|
|
|
} |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* |
43
|
|
|
*/ |
44
|
|
View Code Duplication |
public function testCanView() |
|
|
|
|
45
|
|
|
{ |
46
|
|
|
$object = $this->objFromFixture('FormBlock', 'one'); |
47
|
|
|
$admin = $this->objFromFixture('Member', 'admin'); |
48
|
|
|
$member = $this->objFromFixture('Member', 'default'); |
49
|
|
|
if (class_exists('UserDefinedForm')) { |
50
|
|
|
$this->assertTrue($object->canView($admin)); |
|
|
|
|
51
|
|
|
$this->assertTrue($object->canView($member)); |
|
|
|
|
52
|
|
|
} else { |
53
|
|
|
$this->assertFalse($object->canView($admin)); |
|
|
|
|
54
|
|
|
$this->assertFalse($object->canView($member)); |
|
|
|
|
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* |
60
|
|
|
*/ |
61
|
|
View Code Duplication |
public function testCanCreate() |
|
|
|
|
62
|
|
|
{ |
63
|
|
|
$object = $this->objFromFixture('FormBlock', 'one'); |
64
|
|
|
$admin = $this->objFromFixture('Member', 'admin'); |
65
|
|
|
$member = $this->objFromFixture('Member', 'default'); |
66
|
|
|
if (class_exists('UserDefinedForm')) { |
67
|
|
|
$this->assertTrue($object->canCreate($admin)); |
|
|
|
|
68
|
|
|
$this->assertTrue($object->canCreate($member)); |
|
|
|
|
69
|
|
|
} else { |
70
|
|
|
$this->assertFalse($object->canCreate($admin)); |
|
|
|
|
71
|
|
|
$this->assertFalse($object->canCreate($member)); |
|
|
|
|
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
} |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.