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
|
|
|
$object = $this->objFromFixture('FormBlock', 'one'); |
35
|
|
|
$form = $object->Form(); |
36
|
|
|
$this->assertInstanceOf('UserDefinedForm', $form); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* |
41
|
|
|
*/ |
42
|
|
View Code Duplication |
public function testCanView() |
|
|
|
|
43
|
|
|
{ |
44
|
|
|
$object = $this->objFromFixture('FormBlock', 'one'); |
45
|
|
|
$admin = $this->objFromFixture('Member', 'admin'); |
46
|
|
|
$member = $this->objFromFixture('Member', 'default'); |
47
|
|
|
if (class_exists('UserDefinedForm')) { |
48
|
|
|
$this->assertTrue($object->canView($admin)); |
|
|
|
|
49
|
|
|
$this->assertTrue($object->canView($member)); |
|
|
|
|
50
|
|
|
} else { |
51
|
|
|
$this->assertFalse($object->canView($admin)); |
|
|
|
|
52
|
|
|
$this->assertFalse($object->canView($member)); |
|
|
|
|
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* |
58
|
|
|
*/ |
59
|
|
View Code Duplication |
public function testCanCreate() |
|
|
|
|
60
|
|
|
{ |
61
|
|
|
$object = $this->objFromFixture('FormBlock', 'one'); |
62
|
|
|
$admin = $this->objFromFixture('Member', 'admin'); |
63
|
|
|
$member = $this->objFromFixture('Member', 'default'); |
64
|
|
|
if (class_exists('UserDefinedForm')) { |
65
|
|
|
$this->assertTrue($object->canCreate($admin)); |
|
|
|
|
66
|
|
|
$this->assertTrue($object->canCreate($member)); |
|
|
|
|
67
|
|
|
} else { |
68
|
|
|
$this->assertFalse($object->canCreate($admin)); |
|
|
|
|
69
|
|
|
$this->assertFalse($object->canCreate($member)); |
|
|
|
|
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
} |
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.