1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use Dynamic\ViewableDataObject\VDOInterfaces\ViewableDataObjectInterface; |
4
|
|
|
|
5
|
|
|
class ViewableDataObjectTest extends SapphireTest |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* @var array |
9
|
|
|
*/ |
10
|
|
|
protected static $fixture_file = array( |
11
|
|
|
'viewable-dataobject/tests/fixtures.yml', |
12
|
|
|
); |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @var array |
16
|
|
|
*/ |
17
|
|
|
protected $extraDataObjects = array( |
18
|
|
|
'ViewableTestObject', |
19
|
|
|
); |
20
|
|
|
|
21
|
|
|
protected function getObject() |
22
|
|
|
{ |
23
|
|
|
return $this->objFromFixture('ViewableTestObject', 'one'); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function testUpdateCMSFields() |
27
|
|
|
{ |
28
|
|
|
$object = $this->getObject(); |
29
|
|
|
$fields = $object->getCMSFields(); |
30
|
|
|
$this->assertInstanceOf('FieldList', $fields); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function testHasParentPage() |
34
|
|
|
{ |
35
|
|
|
$object = $this->getObject(); |
36
|
|
|
$this->assertInstanceOf('Page', $object->getParentPage()); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function testHasViewAction() |
40
|
|
|
{ |
41
|
|
|
$object = $this->getObject(); |
42
|
|
|
$this->assertEquals($object->hasViewAction(), 'view'); |
|
|
|
|
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function testLink() |
46
|
|
|
{ |
47
|
|
|
$object = $this->getObject(); |
48
|
|
|
$page = $this->objFromFixture('Page', 'default'); |
49
|
|
|
$this->assertEquals($page->Link() . 'view/' . $object->URLSegment, $object->Link()); |
|
|
|
|
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function testGetAbsoluteLink() |
53
|
|
|
{ |
54
|
|
|
$object = $this->getObject(); |
55
|
|
|
$page = $this->objFromFixture('Page', 'default'); |
56
|
|
|
$this->assertEquals($page->AbsoluteLink() . 'view/' . $object->URLSegment, $object->getAbsoluteLink()); |
|
|
|
|
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function testValidURLSegment() |
60
|
|
|
{ |
61
|
|
|
$object = $this->objFromFixture('ViewableTestObject', 'one'); |
62
|
|
|
$object2 = $this->objFromFixture('ViewableTestObject', 'two'); |
63
|
|
|
$object->URLSegment = $object2->URLSegment; |
64
|
|
|
$this->assertFalse($object->validURLSegment()); |
|
|
|
|
65
|
|
|
$object->URLSegment = 'object-one'; |
66
|
|
|
$this->assertTrue($object->validURLSegment()); |
|
|
|
|
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function testBreadcrumbs() |
70
|
|
|
{ |
71
|
|
|
$object = $this->objFromFixture('ViewableTestObject', 'one'); |
72
|
|
|
$this->assertInstanceOf("HTMLText", $object->Breadcrumbs()); |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
class ViewableTestObject extends DataObject implements TestOnly, Dynamic\ViewableDataObject\VDOInterfaces\ViewableDataObjectInterface |
|
|
|
|
77
|
|
|
{ |
78
|
|
|
private static $db = [ |
79
|
|
|
'Title' => 'Varchar(255)', |
80
|
|
|
'Content' => 'HtmlText', |
81
|
|
|
]; |
82
|
|
|
|
83
|
|
|
private static $extensions = [ |
84
|
|
|
'Dynamic\ViewableDataObject\Extensions\ViewableDataObject', |
85
|
|
|
]; |
86
|
|
|
|
87
|
|
|
public function getParentPage() |
88
|
|
|
{ |
89
|
|
|
return Page::get()->first(); |
90
|
|
|
} |
91
|
|
|
} |
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.