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