Permalink
Browse files

Merge branch 'feature/form_decorator_refactor' into ucsf/develop

Conflicts:
	root/assets/lib/decorator/html/tag.class.php
	root/assets/lib/decorator/site/footer.class.php
	root/assets/lib/decorator/site/menu.class.php
  • Loading branch information...
2 parents b34b695 + aac975b commit 24751330b4ce97fcc19abf9305dc57b6b1cdcb59 @Trott committed Mar 30, 2012
@@ -83,16 +83,6 @@ public function flush_inner() {
/**
- * If you really must pass raw HTML to the decorator, well, don't. But if
- * you have to, this is the method to use.
- *
- * @return string
- */
- public function render_raw() {
- return $this->render(true);
- }
-
- /**
* Render the tag for output.
*
* @param boolean $raw set to TRUE if the tag's content is raw markup and should remain unescaped
@@ -59,7 +59,8 @@ public function &show_powered_by($val = true) {
return $this;
}
- public function render($raw) {
+
+ public function render($raw = false) {
$this->set_param('id', 'footer');
if ($this->_copyright || $this->_footer_link_urls) {
@@ -135,10 +135,9 @@ public function render($raw = false) {
if ($this->_homescreen && Classification::is_full() && Config::get('frontpage', 'configurable_homescreen')) {
$js = 'mwf.full.configurableMenu("homescreen_layout").render("main_menu_list",' .
json_encode(
- array_map(function($obj) {
+ array_map(function($obj, $raw) {
return $obj->render($raw);
- }, $this->_list)) . ');';
-
+ }, $this->_list, array_fill(0, count($this->_list), $raw))) . ');';
$this->add_inner(HTML_Decorator::tag('ol')->set_param('id', 'main_menu_list'));
$this->add_inner(HTML_Decorator::tag('script', $js));
} else {
@@ -1,14 +1,15 @@
<?php
-require_once dirname(__FILE__) . '/../../../../../../../root/assets/lib/decorator/html/tag.class.php';
+require_once dirname(dirname(dirname(dirname(dirname(dirname(dirname(__DIR__)))))))
+ . '/root/assets/lib/decorator/html/tag.class.php';
/**
* Test class for Tag_HTML_Decorator.
*
* @author trott
* @copyright Copyright (c) 2012 UC Regents
* @license http://mwf.ucla.edu/license
- * @version 20120318
+ * @version 20120329
*
* @uses PHPUnit_Framework_TestCase
* @uses Tag_HTML_Decorator
@@ -47,11 +48,20 @@ public function render_rawHTML_convertedToEntities() {
/**
* @test
*/
- public function renderRaw_rawHTML_notConvertedToEntities() {
+ public function render_rawFlagTruerawHTML_notConvertedToEntities() {
$this->object = HTML_Decorator::tag('p', '&<br>');
- $this->assertEquals('<p>&<br></p>', $this->object->render_raw());
+ $this->assertEquals('<p>&<br></p>', $this->object->render(true));
}
+ /**
+ * @test
+ */
+ public function render_rawFlagTrueHTMLDecorator_notConvertedToEntities() {
+ $this->object = HTML_Decorator::tag('p')
+ ->add_inner_tag('i', "& don't encode me either, Broseph!");
+ $this->assertEquals("<p><i>& don't encode me either, Broseph!</i></p>",
+ $this->object->render(true));
+ }
}
?>
@@ -0,0 +1,57 @@
+<?php
+
+require_once dirname(__FILE__) . '/../../../../../../../root/assets/lib/decorator/site/footer.class.php';
+
+/**
+ * Test class for Footer_Site_Decorator.
+ * Generated by PHPUnit on 2012-03-29 at 23:26:46.
+ */
+class Footer_Site_DecoratorTest extends PHPUnit_Framework_TestCase {
+
+ /**
+ * @var Footer_Site_Decorator
+ */
+ protected $object;
+
+ /**
+ * Sets up the fixture, for example, opens a network connection.
+ * This method is called before a test is executed.
+ */
+ protected function setUp() {
+ $this->object = new Footer_Site_Decorator;
+ }
+
+ /**
+ * Tears down the fixture, for example, closes a network connection.
+ * This method is called after a test is executed.
+ */
+ protected function tearDown() {
+
+ }
+
+ /**
+ * @test
+ */
+ public function render_noRawFlag_encodesResult() {
+ $this->object->add_inner('&');
+ $this->assertContains('&amp;', $this->object->render());
+ }
+
+ /**
+ * @test
+ */
+ public function render_rawFlagTrue_doesNotEncodesResult() {
+ $this->object->add_inner('&');
+ $this->assertNotContains('&amp;', $this->object->render(true));
+ }
+
+ /**
+ * @test
+ */
+ public function render_rawFlagFalse_doesNotEncodesResult() {
+ $this->object->add_inner('&');
+ $this->assertContains('&amp;', $this->object->render(false));
+ }
+
+}
+
@@ -6,7 +6,7 @@
* @author trott
* @copyright Copyright (c) 2010-12 UC Regents
* @license http://mwf.ucla.edu/license
- * @version 20120218
+ * @version 20120229
*
* @uses PHPUnit_Framework_TestCase
* @uses Menu_Site_Decorator
@@ -25,7 +25,7 @@ public function setUp() {
* @runInSeparateProcess
*/
public function render_ampersandInUrlParam_ampersandEntityUsed() {
- require dirname(dirname(dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))))) . '/root/assets/lib/decorator/site/menu.class.php';
+ require dirname(dirname(dirname(dirname(dirname(dirname(dirname(__DIR__))))))) . '/root/assets/lib/decorator/site/menu.class.php';
$this->object = new Menu_Site_Decorator;
@@ -38,7 +38,7 @@ public function render_ampersandInUrlParam_ampersandEntityUsed() {
* @runInSeparateProcess
*/
public function render_quotesInUrlParam_quotesReplacedWithEntities() {
- require dirname(dirname(dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))))) . '/root/assets/lib/decorator/site/menu.class.php';
+ require dirname(dirname(dirname(dirname(dirname(dirname(dirname(__DIR__))))))) . '/root/assets/lib/decorator/site/menu.class.php';
$this->object = new Menu_Site_Decorator;
@@ -51,7 +51,7 @@ public function render_quotesInUrlParam_quotesReplacedWithEntities() {
* @runInSeparateProcess
*/
public function setHomescreen_noParam_isHomescreen() {
- require dirname(dirname(dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))))) . '/root/assets/lib/decorator/site/menu.class.php';
+ require dirname(dirname(dirname(dirname(dirname(dirname(dirname(__DIR__))))))) . '/root/assets/lib/decorator/site/menu.class.php';
$this->object = new Menu_Site_Decorator;
@@ -66,12 +66,12 @@ public function setHomescreen_noParam_isHomescreen() {
* @runInSeparateProcess
*/
public function render_homescreenAndFull_jsObject() {
- require_once dirname(dirname(dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))))) . '/root/assets/lib/config.class.php';
+ require_once dirname(dirname(dirname(dirname(dirname(dirname(dirname(__DIR__))))))) . '/root/assets/lib/config.class.php';
Config::set('frontpage', 'configurable_homescreen', true);
Config::set('global', 'cookie_prefix', 'mwftest_');
$_COOKIE['mwftest_classification'] = '{"mobile":false,"basic":true,"standard":true,"full":true,"native":false}';
- require_once dirname(dirname(dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))))) . '/root/assets/lib/classification.class.php';
- require_once dirname(dirname(dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))))) . '/root/assets/lib/decorator/site/menu.class.php';
+ require_once dirname(dirname(dirname(dirname(dirname(dirname(dirname(__DIR__))))))) . '/root/assets/lib/classification.class.php';
+ require_once dirname(dirname(dirname(dirname(dirname(dirname(dirname(__DIR__))))))) . '/root/assets/lib/decorator/site/menu.class.php';
$this->object = new Menu_Site_Decorator;
$this->object->set_homescreen();

0 comments on commit 2475133

Please sign in to comment.