+--------------------------------------------------------------------+
| CiviCRM version 5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2018 |
+ | Copyright CiviCRM LLC (c) 2004-2020 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
*/
protected $pageContent;
+ /**
+ * @var \CRM_Core_Page
+ */
+ protected $page;
+
+ /**
+ * @var string
+ */
+ protected $tplName;
+
/**
* Variables assigned to smarty.
*
*/
protected $smartyVariables = [];
+ protected $context;
+
/**
* @param string $content
* @param string $context
*/
public function checkPageContent(&$content, $context, $tplName, &$object) {
$this->pageContent = $content;
+ $this->tplName = $tplName;
+ $this->page = $object;
+ $this->context = $context;
// Ideally we would validate $content as valid html here.
// Suppress console output.
$content = '';
* @param $expectedStrings
*/
protected function assertPageContains($expectedStrings) {
+ unset($this->smartyVariables['config']);
+ unset($this->smartyVariables['session']);
foreach ($expectedStrings as $expectedString) {
- $this->assertContains($expectedString, $this->pageContent);
+ $this->assertContains($expectedString, $this->pageContent, print_r($this->contributions, TRUE) . print_r($this->smartyVariables, TRUE));
}
}
}
}
+ /**
+ * 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'
+ 'checkPageContent',
]);
}