[Joomla-commits] r18742 - in development/trunk: installation libraries/joomla/application/component tests/unit/suite/libraries/joomla/application/component

0 views
Skip to first unread message

eddi...@jcode001.directrouter.com

unread,
Aug 31, 2010, 9:02:34 PM8/31/10
to joomla-...@joomlacode.org
Author: eddieajau
Date: 2010-08-31 20:02:34 -0500 (Tue, 31 Aug 2010)
New Revision: 18742

Modified:
development/trunk/installation/CHANGELOG
development/trunk/libraries/joomla/application/component/controller.php
development/trunk/tests/unit/suite/libraries/joomla/application/component/JControllerHelper.php
development/trunk/tests/unit/suite/libraries/joomla/application/component/JControllerTest.php
Log:
Fixed issue [#22118] The setRedirect method() overwrites an already set messageType (Roland Dalmulder, Artyom Bisyarin).

Modified: development/trunk/installation/CHANGELOG
===================================================================
--- development/trunk/installation/CHANGELOG 2010-08-31 19:24:28 UTC (rev 18741)
+++ development/trunk/installation/CHANGELOG 2010-09-01 01:02:34 UTC (rev 18742)
@@ -27,6 +27,9 @@
- -> Removed
! -> Note

+01-Sep-2010 Andrew Eddie (and Happy 5th Birthday Joomla!)
+ # Fixed issue [#22118] The setRedirect method() overwrites an already set messageType (Roland Dalmulder, Artyom Bisyarin).
+
31-Aug-2010 Jean-Marie Simonet
# [#22150] hathor menu type - unable to select type. Thanks Bill.
# [#22161] edit article - show icons and + param missing

Modified: development/trunk/libraries/joomla/application/component/controller.php
===================================================================
--- development/trunk/libraries/joomla/application/component/controller.php 2010-08-31 19:24:28 UTC (rev 18741)
+++ development/trunk/libraries/joomla/application/component/controller.php 2010-09-01 01:02:34 UTC (rev 18742)
@@ -809,7 +809,15 @@
}

// Ensure the type is not overwritten by a previous call to setMessage.
- $this->messageType = ($type === null || empty($this->messageType)) ? 'message' : $type;
+ if (empty($type)) {
+ if (empty($this->messageType)) {
+ $this->messageType = 'message';
+ }
+ }
+ // If the type is explicitly set, set it.
+ else {
+ $this->messageType = $type;
+ }

return $this;
}

Modified: development/trunk/tests/unit/suite/libraries/joomla/application/component/JControllerHelper.php
===================================================================
--- development/trunk/tests/unit/suite/libraries/joomla/application/component/JControllerHelper.php 2010-08-31 19:24:28 UTC (rev 18741)
+++ development/trunk/tests/unit/suite/libraries/joomla/application/component/JControllerHelper.php 2010-09-01 01:02:34 UTC (rev 18742)
@@ -20,6 +20,20 @@
{
return $this->paths;
}
+
+ /**
+ * Method for inspecting protected variables
+ */
+ public function __get($name)
+ {
+ if (property_exists($this, $name)) {
+ return $this->$name;
+ }
+ else {
+ trigger_error('Undefined or private property: ' . __CLASS__.'::'.$name, E_USER_ERROR);
+ return;
+ }
+ }
}

class TestController extends JController

Modified: development/trunk/tests/unit/suite/libraries/joomla/application/component/JControllerTest.php
===================================================================
--- development/trunk/tests/unit/suite/libraries/joomla/application/component/JControllerTest.php 2010-08-31 19:24:28 UTC (rev 18741)
+++ development/trunk/tests/unit/suite/libraries/joomla/application/component/JControllerTest.php 2010-09-01 01:02:34 UTC (rev 18742)
@@ -289,8 +289,22 @@
*/
public function testSetMessage()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
+ $controller = new JControllerInspector;
+ $controller->setMessage('Hello World');
+
+ $this->assertEquals($controller->message, 'Hello World',
+ 'Line:'.__LINE__.' The message text does not equal with previuosly set one');
+
+ $this->assertEquals($controller->messageType, 'message',
+ 'Line:'.__LINE__.' Default message type should be "message"');
+
+ $controller->setMessage('Morning Universe', 'notice');
+
+ $this->assertEquals($controller->message, 'Morning Universe',
+ 'Line:'.__LINE__.' The message text does not equal with previuosly set one');
+
+ $this->assertEquals($controller->messageType, 'notice',
+ 'Line:'.__LINE__.' The message type does not equal with previuosly set one');
}

/**
@@ -307,7 +321,245 @@
*/
public function testSetRedirect()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete('This test has not been implemented yet.');
+ $controller = new JControllerInspector;
+
+ // Set the URL only
+ $controller->setRedirect('index.php?option=com_foobar');
+
+ $this->assertEquals(
+ $controller->redirect,
+ 'index.php?option=com_foobar',
+ 'Line:'.__LINE__.' The redirect address does not equal with passed one'
+ );
+
+ $this->assertNull(
+ $controller->message,
+ 'Line:'.__LINE__.' The message is not set, so it should be null'
+ );
+
+ $this->assertEquals(
+ $controller->messageType,
+ 'message',
+ 'Line:'.__LINE__.' Default message type should be "message"'
+ );
+
+ // Set the URL and message
+ $controller->setRedirect('index.php?option=com_foobar', 'Hello World');
+
+ $this->assertEquals(
+ $controller->redirect,
+ 'index.php?option=com_foobar',
+ 'Line:'.__LINE__.' The redirect address does not equal with passed one'
+ );
+
+ $this->assertEquals(
+ $controller->message,
+ 'Hello World',
+ 'Line:'.__LINE__.' The message text does not equal with passed one'
+ );
+
+ $this->assertEquals(
+ $controller->messageType,
+ 'message',
+ 'Line:'.__LINE__.' Default message type should be "message"'
+ );
+
+ // URL, message and message type
+ $controller->setRedirect('index.php?option=com_foobar', 'Morning Universe', 'notice');
+
+ $this->assertEquals(
+ $controller->redirect,
+ 'index.php?option=com_foobar',
+ 'Line:'.__LINE__.' The redirect address does not equal with passed one'
+ );
+
+ $this->assertEquals(
+ $controller->message,
+ 'Morning Universe',
+ 'Line:'.__LINE__.' The message text does not equal with passed one');
+
+ $this->assertEquals(
+ $controller->messageType,
+ 'notice',
+ 'Line:'.__LINE__.' The message type does not equal with passed one'
+ );
+
+ // With previously set message
+ // URL
+ $controller->setMessage('Hi all');
+ $controller->setRedirect('index.php?option=com_foobar');
+
+ $this->assertEquals(
+ $controller->redirect,
+ 'index.php?option=com_foobar',
+ 'Line:'.__LINE__.' The redirect address does not equal with passed one'
+ );
+
+ $this->assertEquals(
+ $controller->message,
+ 'Hi all',
+ 'Line:'.__LINE__.' The message text does not equal with previously set one'
+ );
+
+ $this->assertEquals(
+ $controller->messageType,
+ 'message',
+ 'Line:'.__LINE__.' Default message type should be "message"'
+ );
+
+ // URL and message
+ $controller->setMessage('Hi all');
+ $controller->setRedirect('index.php?option=com_foobar', 'Bye all');
+
+ $this->assertEquals(
+ $controller->redirect,
+ 'index.php?option=com_foobar',
+ 'Line:'.__LINE__.' The redirect address does not equal with passed one'
+ );
+
+ $this->assertEquals(
+ $controller->message,
+ 'Bye all',
+ 'Line:'.__LINE__.' The message text should be overridden'
+ );
+
+ $this->assertEquals(
+ $controller->messageType,
+ 'message',
+ 'Line:'.__LINE__.' Default message type should be "message"'
+ );
+
+ // URL, message and message type
+ $controller->setMessage('Hi all');
+ $controller->setRedirect('index.php?option=com_foobar', 'Bye all', 'notice');
+
+ $this->assertEquals(
+ $controller->redirect,
+ 'index.php?option=com_foobar',
+ 'Line:'.__LINE__.' The redirect address does not equal with passed one'
+ );
+
+ $this->assertEquals(
+ $controller->message,
+ 'Bye all',
+ 'Line:'.__LINE__.' The message text should be overridden'
+ );
+
+ $this->assertEquals(
+ $controller->messageType,
+ 'notice',
+ 'Line:'.__LINE__.' The message type should be overridden'
+ );
+
+ // URL and message type
+ $controller->setMessage('Hi all');
+ $controller->setRedirect('index.php?option=com_foobar', null, 'notice');
+
+ $this->assertEquals(
+ $controller->redirect,
+ 'index.php?option=com_foobar',
+ 'Line:'.__LINE__.' The redirect address does not equal with passed one'
+ );
+
+ $this->assertEquals(
+ $controller->message,
+ 'Hi all',
+ 'Line:'.__LINE__.' The message text should not be overridden'
+ );
+
+ $this->assertEquals(
+ $controller->messageType,
+ 'notice',
+ 'Line:'.__LINE__.' The message type should be overridden'
+ );
+
+ // With previously set message and message type
+ // URL
+ $controller->setMessage('Hello folks', 'notice');
+ $controller->setRedirect('index.php?option=com_foobar');
+
+ $this->assertEquals(
+ $controller->redirect,
+ 'index.php?option=com_foobar',
+ 'Line:'.__LINE__.' The redirect address does not equal with passed one'
+ );
+
+ $this->assertEquals(
+ $controller->message,
+ 'Hello folks',
+ 'Line:'.__LINE__.' The message text does not equal with previously set one'
+ );
+
+ $this->assertEquals(
+ $controller->messageType,
+ 'notice',
+ 'Line:'.__LINE__.' The message type does not equal with previously set one'
+ );
+
+ // URL and message
+ $controller->setMessage('Hello folks', 'notice');
+ $controller->setRedirect('index.php?option=com_foobar', 'Bye, Folks');
+
+ $this->assertEquals(
+ $controller->redirect,
+ 'index.php?option=com_foobar',
+ 'Line:'.__LINE__.' The redirect address does not equal with passed one'
+ );
+
+ $this->assertEquals(
+ $controller->message,
+ 'Bye, Folks',
+ 'Line:'.__LINE__.' The message text should be overridden'
+ );
+
+ $this->assertEquals(
+ $controller->messageType,
+ 'notice',
+ 'Line:'.__LINE__.' The message type does not equal with previously set one'
+ );
+
+ // URL, message and message type
+ $controller->setMessage('Hello folks', 'notice');
+ $controller->setRedirect('index.php?option=com_foobar', 'Bye, folks', 'notice');
+
+ $this->assertEquals(
+ $controller->redirect,
+ 'index.php?option=com_foobar',
+ 'Line:'.__LINE__.' The redirect address does not equal with passed one'
+ );
+
+ $this->assertEquals(
+ $controller->message,
+ 'Bye, folks',
+ 'Line:'.__LINE__.' The message text should be overridden'
+ );
+
+ $this->assertEquals(
+ $controller->messageType,
+ 'notice',
+ 'Line:'.__LINE__.' The message type should be overridden'
+ );
+
+ // URL and message type
+ $controller->setMessage('Folks?', 'notice');
+ $controller->setRedirect('index.php?option=com_foobar', null, 'question');
+
+ $this->assertEquals(
+ $controller->redirect,
+ 'index.php?option=com_foobar',
+ 'Line:'.__LINE__.' The redirect address does not equal with passed one'
+ );
+
+ $this->assertEquals(
+ $controller->message,
+ 'Folks?',
+ 'Line:'.__LINE__.' The message text should not be overridden'
+ );
+
+ $this->assertEquals(
+ $controller->messageType,
+ 'question',
+ 'Line:'.__LINE__.' The message type should be overridden'
+ );
}
}
\ No newline at end of file

_______________________________________________
Joomla-commits mailing list
Joomla-...@joomlacode.org
http://joomlacode.org/mailman/listinfo/joomla-commits

Reply all
Reply to author
Forward
0 new messages