function ClassifiedBasicTest::test1287674 in Classified Ads 6.3
Bug 1287674
Node title and categories are doubly escaped in recent/popular blocks.
File
- tests/
classified_basic.test, line 308 - Basic test for known bugs in previous versions.
Class
Code
function test1287674() {
$this->group = __FUNCTION__;
$this
->createUsers(array(
'admin',
));
$this
->pass(t('Enable "count content views".'), $this->group);
variable_set('statistics_count_content_views', 1);
$deltas = array(
'popular',
'recent',
);
$this
->drupalLogin($this->adminUser);
foreach ($deltas as $delta) {
$block = array();
$block['module'] = 'classified';
$block['delta'] = $delta;
// Set the created block to a specific region.
$edit = array();
$edit[$block['module'] . '_' . $block['delta'] . '[region]'] = 'left';
$this
->drupalPost('admin/build/block', $edit, t('Save blocks'));
}
$this
->pass('Classified blocks enabled', $this->group);
// Get the Classified vocabulary id.
$vid = _classified_get('vid');
// Create a term in it, do not assign a specific lifetime.
$term_name = $this
->randomName(4) . " ' " . $this
->randomName(4);
$term = array(
'name' => $term_name,
'description' => $this
->randomString(20),
'vid' => $vid,
);
$status = taxonomy_save_term($term);
$tid = $term['tid'];
$this
->assertEqual($status, SAVED_NEW, t('Term @tid created in default vocabulary.', array(
'@tid' => $tid,
)), 'setup');
// Create a node bearing that term.
$quoted_title = $this
->randomName(4) . " ' " . $this
->randomName(4);
$node = $this
->createNode(array(
'taxonomy' => array(
$vid => $tid,
),
'title' => $quoted_title,
));
$this
->drupalGet('node/' . $node->nid);
foreach ($deltas as $delta) {
$content = $this
->xpath("//*[@id='block-classified-{$delta}']/*[@class='content']/descendant::a[@href]");
// SimpleXMLElement.
$content = reset($content);
$this
->assertNotIdentical(FALSE, strpos($content, $quoted_title), t('Title found in @delta block', array(
'@delta' => $delta,
)), $this->group);
$this
->assertNotIdentical(FALSE, strpos($content, $term_name), t('Term found in @delta block', array(
'@delta' => $delta,
)), $this->group);
}
// $pattern = '/'. t('Recent ads') .'.*'. htmlentities($quoted_title, ENT_QUOTES) .' \('. htmlentities($term_name, ENT_QUOTES) .'\).*' . t('Popular ads') .'/ms';
// debug($pattern);
// $this->assertPattern($pattern, t('Ad correctly listed in the "Recent ads" block.'), $this->group);
}