/** * Test the content rendering of a widget */ public function testGetContent() { /** @var modManagerController $controller Fake running the welcome controller */ $controller = new WelcomeManagerController($this->modx, array('namespace' => 'core', 'namespace_name' => 'core', 'namespace_path' => MODX_MANAGER_PATH, 'lang_topics' => 'dashboards', 'controller' => 'system/dashboards')); /** @var modDashboard $dashboard */ $output = $this->widget->getContent($controller); $this->assertNotEmpty($output); }
/** * Specify the language topics to load * @return array */ public function getLanguageTopics() { $topics = array('dashboards', 'user'); if ($this->widget) { $lexicon = $this->widget->get('lexicon'); if (!empty($lexicon) && $lexicon != 'core:dashboards') { $topics[] = $lexicon; } } return $topics; }
/** * Render the widget content as if it were a Snippet * * @param string $content * @return string */ public function renderAsSnippet($content = '') { if (empty($content)) { $content = $this->widget->get('content'); } $content = str_replace(array('<?php', '?>'), '', $content); $closure = create_function('$scriptProperties', 'global $modx;if (is_array($scriptProperties)) {extract($scriptProperties, EXTR_SKIP);}' . $content); return $closure(array('controller' => $this->controller)); }