1
|
|
|
<?php |
2
|
|
|
|
3
|
|
View Code Duplication |
class PromoObjectTest 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 testGetCMSFields() |
14
|
|
|
{ |
15
|
|
|
$object = $this->objFromFixture('PromoObject', 'one'); |
16
|
|
|
$fields = $object->getCMSFields(); |
17
|
|
|
$this->assertInstanceOf('FieldList', $fields); |
18
|
|
|
$this->assertNotNull($fields->dataFieldByName('BlockLinkID')); |
|
|
|
|
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* |
23
|
|
|
*/ |
24
|
|
|
public function testValidateName() |
25
|
|
|
{ |
26
|
|
|
$object = $this->objFromFixture('PromoObject', 'one'); |
27
|
|
|
$object->Name = ''; |
28
|
|
|
$this->setExpectedException('ValidationException'); |
|
|
|
|
29
|
|
|
$object->write(); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* |
34
|
|
|
*/ |
35
|
|
|
public function testCanView() |
36
|
|
|
{ |
37
|
|
|
$object = $this->objFromFixture('PromoObject', 'one'); |
38
|
|
|
$admin = $this->objFromFixture('Member', 'admin'); |
39
|
|
|
$this->assertTrue($object->canView($admin)); |
|
|
|
|
40
|
|
|
$member = $this->objFromFixture('Member', 'default'); |
41
|
|
|
$this->assertTrue($object->canView($member)); |
|
|
|
|
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* |
46
|
|
|
*/ |
47
|
|
|
public function testCanEdit() |
48
|
|
|
{ |
49
|
|
|
$object = $this->objFromFixture('PromoObject', 'one'); |
50
|
|
|
$admin = $this->objFromFixture('Member', 'admin'); |
51
|
|
|
$this->assertTrue($object->canEdit($admin)); |
|
|
|
|
52
|
|
|
$member = $this->objFromFixture('Member', 'default'); |
53
|
|
|
$this->assertTrue($object->canEdit($member)); |
|
|
|
|
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* |
58
|
|
|
*/ |
59
|
|
|
public function testCanDelete() |
60
|
|
|
{ |
61
|
|
|
$object = $this->objFromFixture('PromoObject', 'one'); |
62
|
|
|
$admin = $this->objFromFixture('Member', 'admin'); |
63
|
|
|
$this->assertTrue($object->canDelete($admin)); |
|
|
|
|
64
|
|
|
$member = $this->objFromFixture('Member', 'default'); |
65
|
|
|
$this->assertTrue($object->canDelete($member)); |
|
|
|
|
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* |
70
|
|
|
*/ |
71
|
|
|
public function testCanCreate() |
72
|
|
|
{ |
73
|
|
|
$object = $this->objFromFixture('PromoObject', 'one'); |
74
|
|
|
$admin = $this->objFromFixture('Member', 'admin'); |
75
|
|
|
$this->assertTrue($object->canCreate($admin)); |
|
|
|
|
76
|
|
|
$member = $this->objFromFixture('Member', 'default'); |
77
|
|
|
$this->assertTrue($object->canCreate($member)); |
|
|
|
|
78
|
|
|
} |
79
|
|
|
} |
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.