pageContent = $content; $this->tplName = $tplName; $this->page = $object; $this->context = $context; // Ideally we would validate $content as valid html here. // Suppress console output. $content = ''; $this->smartyVariables = CRM_Core_Smarty::singleton()->get_template_vars(); } /** * Assert that the page output contains the expected strings. * * @param $expectedStrings */ protected function assertPageContains($expectedStrings) { unset($this->smartyVariables['config']); unset($this->smartyVariables['session']); foreach ($expectedStrings as $expectedString) { $this->assertContains($expectedString, $this->pageContent, print_r($this->contributions, TRUE) . print_r($this->smartyVariables, TRUE)); } } /** * Assert that the expected variables have been assigned to Smarty. * * @param $expectedVariables */ protected function assertSmartyVariables($expectedVariables) { foreach ($expectedVariables as $variableName => $expectedValue) { $this->assertEquals($expectedValue, $this->smartyVariables[$variableName]); } } /** * Check an array assigned to smarty for the inclusion of the expected variables. * * @param string $variableName * @param $index * @param $expected */ protected function assertSmartyVariableArrayIncludes($variableName, $index, $expected) { $smartyVariable = $this->smartyVariables[$variableName]; if ($index !== NULL) { $smartyVariable = $smartyVariable[$index]; } foreach ($expected as $key => $value) { $this->assertEquals($value, $smartyVariable[$key], 'Checking ' . $key); } } /** * Set up environment to listen for page content. */ protected function listenForPageContent() { $this->hookClass->setHook('civicrm_alterContent', [ $this, 'checkPageContent', ]); } }