public function SiteBannerRenderingUnitTestCase::testBannerContextTextChange in Site Banner 7
Tests whether multiple contexts changing a banner text is properly handled.
File
- ./
site_banner.test, line 188
Class
- SiteBannerRenderingUnitTestCase
- Implements tests for checking that banner rendering functions are correct.
Code
public function testBannerContextTextChange() {
$result = FALSE;
$baseline_banner_text = 'Example Text PrependText01 Text1/Text2 AppendText01';
$banner_text = variable_get('site_banner_text', '');
$existing_banner_text = $banner_text;
$contexts = array(
'context_1' => (object) array(
'name' => 'context_1',
'description' => 'context_1',
'tag' => 'tag1',
'conditions' => array(
'node_taxonomy' => array(
'values' => array(
1 => 1,
),
'options' => array(
'node_form' => '1',
),
),
),
'reactions' => array(
'change_banner_background_color' => '#ffffcc',
'change_banner_text' => array(
'site_banner_text' => 'Example Text',
'site_banner_tag_prepend_text' => '',
'site_banner_tag_delimiter_text' => '',
'site_banner_tag_append_text' => '',
),
'change_banner_text_color' => '#000000',
),
'condition_mode' => '0',
'table' => 'context',
'type' => 'Normal',
'export_type' => 1,
),
'context_2' => (object) array(
'name' => 'context_2',
'description' => 'context_2',
'tag' => 'tag2',
'conditions' => array(
'node_taxonomy' => array(
'values' => array(
12 => 12,
),
'options' => array(
'node_form' => '1',
),
),
),
'reactions' => array(
'change_banner_text' => array(
'site_banner_text' => 'Text1',
'site_banner_tag_prepend_text' => 'PrependText01 ',
'site_banner_tag_delimiter_text' => '/',
'site_banner_tag_append_text' => ' AppendText01',
),
),
'condition_mode' => '0',
'table' => 'context',
'type' => 'Normal',
'export_type' => 1,
),
'context_3' => (object) array(
'name' => 'context_3',
'description' => 'context_3',
'tag' => 'tag2',
'conditions' => array(
'node_taxonomy' => array(
'values' => array(
16 => 16,
),
'options' => array(
'node_form' => '1',
),
),
),
'reactions' => array(
'change_banner_text' => array(
'site_banner_text' => 'Text2',
'site_banner_tag_prepend_text' => 'PrependText01 ',
'site_banner_tag_delimiter_text' => '/',
'site_banner_tag_append_text' => ' AppendText01',
),
),
'condition_mode' => '0',
'table' => 'context',
'type' => 'Normal',
'export_type' => 1,
),
);
site_banner_generate_context_banner_text_from_contexts($contexts, $banner_text);
$result = $banner_text == $baseline_banner_text;
$message = 'Test context can render an altered banner text properly: ';
$message .= "Existing banner text = \"{$existing_banner_text}\", Updated banner text = \"{$banner_text}\"";
$message .= ", Baseline banner text = \"{$baseline_banner_text}\".";
$this
->assertTrue($result, $message);
}