| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- <?php
- /**
- * @file
- * Entities tests
- */
- class dsViewsTests extends dsBaseTest {
- /**
- * Implements getInfo().
- */
- public static function getInfo() {
- return array(
- 'name' => t('Views'),
- 'description' => t('Tests for Display Suite Views integration.'),
- 'group' => t('Display Suite'),
- );
- }
- /**
- * Test views integration.
- */
- function testDSViews() {
- $edit_tag_1 = array(
- 'field_tags[und]' => 'Tag 1',
- );
- $edit_tag_2 = array(
- 'field_tags[und]' => 'Tag 2',
- );
- // Create 3 nodes.
- $settings_1 = array(
- 'type' => 'article',
- 'title' => 'Article 1',
- 'created' => REQUEST_TIME,
- );
- $node_1 = $this->drupalCreateNode($settings_1);
- $this->drupalPost('node/' . $node_1->nid . '/edit', $edit_tag_1, t('Save'));
- $settings_2 = array(
- 'type' => 'article',
- 'title' => 'Article 2',
- 'created' => REQUEST_TIME + 3600,
- );
- $node_2 = $this->drupalCreateNode($settings_2);
- $this->drupalPost('node/' . $node_2->nid . '/edit', $edit_tag_1, t('Save'));
- $settings_3 = array(
- 'type' => 'article',
- 'title' => 'Article 3',
- 'created' => REQUEST_TIME + 7200,
- );
- $node_3 = $this->drupalCreateNode($settings_3);
- $this->drupalPost('node/' . $node_3->nid . '/edit', $edit_tag_2, t('Save'));
- // Configure teaser and full layout.
- $layout = array(
- 'additional_settings[layout]' => 'ds_2col',
- );
- $fields = array(
- 'fields[title][region]' => 'left',
- 'fields[body][region]' => 'right',
- );
- $assert = array(
- 'regions' => array(
- 'left' => '<td colspan="8">' . t('Left') . '</td>',
- 'right' => '<td colspan="8">' . t('Right') . '</td>',
- ),
- );
- $this->dsSelectLayout($layout, $assert, 'admin/structure/types/manage/article/display/teaser');
- $this->dsConfigureUI($fields, 'admin/structure/types/manage/article/display/teaser');
- $layout = array(
- 'additional_settings[layout]' => 'ds_4col',
- );
- $fields = array(
- 'fields[post_date][region]' => 'first',
- 'fields[body][region]' => 'second',
- 'fields[author][region]' => 'third',
- 'fields[node_link][region]' => 'fourth',
- );
- $assert = array(
- 'regions' => array(
- 'first' => '<td colspan="8">' . t('First') . '</td>',
- 'second' => '<td colspan="8">' . t('Second') . '</td>',
- 'third' => '<td colspan="8">' . t('Third') . '</td>',
- 'fourth' => '<td colspan="8">' . t('Fourth') . '</td>',
- ),
- );
- $this->dsSelectLayout($layout, $assert);
- $this->dsConfigureUI($fields);
- // Get default teaser view.
- $this->drupalGet('ds-testing');
- foreach (array('group-left', 'group-right') as $region) {
- $this->assertRaw($region, t('Region !region found', array('!region' => $region)));
- }
- $this->assertRaw('Article 1');
- $this->assertRaw('Article 2');
- $this->assertRaw('Article 3');
- // Get alternating view.
- $this->drupalGet('ds-testing-2');
- foreach (array('group-left', 'group-right', 'first', 'second', 'third', 'fourth') as $region) {
- $this->assertRaw($region, t('Region !region found', array('!region' => $region)));
- }
- $this->assertNoRaw('Article 1');
- $this->assertRaw('Article 2');
- $this->assertRaw('Article 3');
- // Get grouping view (without changing header function).
- $this->drupalGet('ds-testing-3');
- foreach (array('group-left', 'group-right') as $region) {
- $this->assertRaw($region, t('Region !region found', array('!region' => $region)));
- }
- $this->assertRaw('Article 1');
- $this->assertRaw('Article 2');
- $this->assertRaw('Article 3');
- $this->assertRaw('<h2 class="grouping-title">1</h2>');
- $this->assertRaw('<h2 class="grouping-title">2</h2>');
- // Get grouping view (with changing header function).
- $this->drupalGet('ds-testing-4');
- foreach (array('group-left', 'group-right') as $region) {
- $this->assertRaw($region, t('Region !region found', array('!region' => $region)));
- }
- $this->assertRaw('Article 1');
- $this->assertRaw('Article 2');
- $this->assertRaw('Article 3');
- $this->assertRaw('<h2 class="grouping-title">Tag 1</h2>');
- $this->assertRaw('<h2 class="grouping-title">Tag 2</h2>');
- // Get advanced function view.
- $this->drupalGet('ds-testing-5');
- $this->assertRaw('Advanced display for id 1');
- $this->assertRaw('Advanced display for id 2');
- $this->assertRaw('Advanced display for id 3');
- // Test views templates overrides.
- $this->drupalGet('admin/structure/ds/vd/manage/ds_testing-page_5/display');
- $this->assertText('No view found to layout.');
- $edit = array(
- 'vd' => 'ds_testing-page_5',
- );
- $this->drupalPost('admin/structure/ds/vd', $edit, t('Add'));
- $this->dsSelectLayout(array(), array(), 'admin/structure/ds/vd/manage/ds_testing-page_5/display');
- $edit = array(
- 'fields[pager][region]' => 'header',
- 'fields[footer][region]' => 'header',
- 'fields[rows][region]' => 'left',
- 'fields[exposed][region]' => 'right',
- 'fields[header][region]' => 'footer',
- );
- $this->dsConfigureUI($edit, 'admin/structure/ds/vd/manage/ds_testing-page_5/display');
- // Test on the views page itself.
- $this->drupalGet('ds-testing-6');
- $this->assertRaw('<div class="group-header">
- <p>Footer text</p>
- </div>');
- $this->assertRaw('<div class="group-left">
- <div class="views-row views-row-1 views-row-odd views-row-first">');
- $this->assertRaw('<div class="group-right">
- <form action="' . url('ds-testing-6') . '"');
- $this->assertRaw('<div class="group-footer">
- <p>Header text</p>');
- }
- }
|