Commit 5b5d5351 authored by alexpott's avatar alexpott

Issue #1998182 by dawehner: Fixed Glossary view is broken.

parent dcfda14d
......@@ -361,7 +361,7 @@ display:
break_phrase: '0'
displays:
default: default
page: page_1
page_1: page_1
inherit_arguments: '0'
label: Glossary
module: node
......
......@@ -6,17 +6,25 @@
*/
namespace Drupal\views\Tests;
use Drupal\Component\Utility\Unicode;
/**
* Tests glossary view ( summary of arguments ).
*/
class GlossaryTest extends ViewTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('node');
public static function getInfo() {
return array(
'name' => 'Glossary tests',
'description' => 'Tests glossary functionality of views.',
'group' => 'Views',
'group' => 'Views Config',
);
}
......@@ -55,6 +63,24 @@ public function testGlossaryView() {
foreach ($view->result as $item) {
$this->assertEqual($nodes_per_char[$item->title_truncated], $item->num_records);
}
// Enable the glossary to be displayed.
$view->storage->enable()->save();
// Check the actual page response.
$this->drupalGet('glossary');
$this->assertResponse(200);
foreach ($nodes_per_char as $char => $count) {
$href = url('glossary/' . $char);
$label = Unicode::strtoupper($char);
// Get the summary link for a certain character. Filter by label and href
// to ensure that both of them are correct.
$result = $this->xpath('//a[contains(@href, :href) and normalize-space(text())=:label]/..', array(':href' => $href, ':label' => $label));
$this->assertTrue(count($result));
// The rendered output looks like "| (count)" so let's figure out the int.
$result_count = trim(str_replace(array('|', '(', ')'), '', (string) $result[0]));
$this->assertEqual($result_count, $count, 'The expected number got rendered.');
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment