1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Contains ViewsContentPanesTest.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* Tests rendering views content pane displays.
|
10
|
*/
|
11
|
class ViewsContentPanesTest extends ViewsSqlTest {
|
12
|
|
13
|
/**
|
14
|
* {@inheritdoc}
|
15
|
*/
|
16
|
public static function getInfo() {
|
17
|
return array(
|
18
|
'name' => 'Views content panes tests',
|
19
|
'description' => 'Tests rendering views content pane displays.',
|
20
|
'group' => 'ctools',
|
21
|
'dependencies' => array('ctools', 'views'),
|
22
|
);
|
23
|
}
|
24
|
|
25
|
/**
|
26
|
* {@inheritdoc}
|
27
|
*/
|
28
|
public function setUp(array $modules = array()) {
|
29
|
$modules[] = 'ctools';
|
30
|
$modules[] = 'views_content';
|
31
|
$modules[] = 'views_content_test';
|
32
|
parent::setUp($modules);
|
33
|
}
|
34
|
|
35
|
/**
|
36
|
* Tests rendering a content pane with a more link.
|
37
|
*/
|
38
|
public function testViewMoreLink() {
|
39
|
// The view "views_content_more_link" has two displays: a content pane
|
40
|
// display and a page display. The content pane display displays 3 nodes,
|
41
|
// the page display displays all items.
|
42
|
// On the content pane display a "more" link is configured that should link
|
43
|
// to the page.
|
44
|
$view = views_get_view('views_content_more_link');
|
45
|
|
46
|
// Create four nodes that the view will display. The first three
|
47
|
// will get displayed on the content pane display and the remaining
|
48
|
// on the page display.
|
49
|
for ($i = 0; $i < 4; $i++) {
|
50
|
$this->drupalCreateNode();
|
51
|
}
|
52
|
|
53
|
// Render the content pane display and assert that a more link is shown.
|
54
|
$view->set_display('panel_pane_1');
|
55
|
$rendered_output = $view->preview();
|
56
|
$this->verbose($rendered_output);
|
57
|
$this->storeViewPreview($rendered_output);
|
58
|
|
59
|
$this->assertLink('more');
|
60
|
$this->assertLinkByHref('views-content-more-link');
|
61
|
}
|
62
|
|
63
|
/**
|
64
|
* Stores a view output in the elements.
|
65
|
*
|
66
|
* @param string $output
|
67
|
* The Views HTML output.
|
68
|
*/
|
69
|
protected function storeViewPreview($output) {
|
70
|
$html_dom = new DOMDocument();
|
71
|
@$html_dom->loadHTML($output);
|
72
|
if ($html_dom) {
|
73
|
// It's much easier to work with simplexml than DOM, luckily enough
|
74
|
// we can just simply import our DOM tree.
|
75
|
$this->elements = simplexml_import_dom($html_dom);
|
76
|
}
|
77
|
}
|
78
|
|
79
|
}
|