'Solr/query breadcrumb', 'desc' => 'Make sure breadcrumbs get formed correctly.', 'group' => 'Apache Solr tests'); } private $breadcrumb; private $menu_active_breadcrumb; function setUp() { parent::setUp(); $types = node_get_types('types'); shuffle($types); $type = array_pop($types); $this->query_string = "sudo tid:44 uid:46 type:". $type->type .' tid:58'; $query =& apachesolr_drupal_query($this->query_string, TRUE); $this->breadcrumb = $query->get_breadcrumb(); $this->menu_active_breadcrumb = menu_get_active_breadcrumb(); } function testBreadcrumbIsArray() { return $this->assertTrue(is_array($this->breadcrumb)); } function testBreadcrumbCount() { $query_count = count(explode(' ', $this->query_string)); $menu_active_count = count($this->menu_active_breadcrumb); $expected_breadcrumb_count = $menu_active_count + $query_count; $query_breadcrumb_count = count($this->breadcrumb); $message = 'The number of items in the breadcrumb (@breadcrumb_count) ' . 'should be equal to the number of items in $menu_active_breadcrumb ' . '(@menu_active_count) plus the number of words in $query ' . '(@query_count).'; $vars = array( '@breadcrumb_count' => $query_breadcrumb_count, '@menu_active_count' => $menu_active_count, '@query_count' => $query_count, ); return $this->assertEqual($query_breadcrumb_count, $expected_breadcrumb_count, "'%s' ". t($message, $vars)); } function testBreadcrumbLinks() { $link_part = 'breadcrumb); ++$i) { $result &= $this->assertTrue(strpos($this->breadcrumb[$i], $link_part) !== FALSE, 'Breadcrumb items other than the ' . 'last should be links. But ' . ($i + 1) . 'th item is: ' . str_replace('%', '%%', $this->breadcrumb[$i]) . (is_array($this->breadcrumb[$i]) ? ' true' : ' false')); } $result &= $this->assertTrue( strpos($this->breadcrumb[count($this->breadcrumb) - 1], $link_part) === FALSE, 'Last breadcrumb item should not be a link.'); return $result; } function testBreadcrumbsClean() { $result = TRUE; $prefix_re = '/\w+:/'; foreach ($this->breadcrumb as $item) { $this->assertTrue(preg_match($prefix_re, strip_tags($item)) == 0, 'Field prefixes like "uid:" should be stripped from the breadcrumbs.'); } return $result; } }