$GLOBALS['registry'],
$GLOBALS['prefs'],
$app
- ),
- $app
+ )
);
}
*
* @param string $app The name of the Horde application.
*/
- protected function __construct(
- Horde_LoginTasks_Backend $backend,
- $app
- ) {
+ public function __construct(Horde_LoginTasks_Backend $backend)
+ {
$this->_backend = $backend;
- $this->_app = $app;
-
if (!$this->_backend->isAuthenticated()) {
return;
}
* have been confirmed by the user.
* @param string $url The URL to redirect to when finished.
*/
- public function runTasks($confirmed = false, $url = null, $no_redirect = false)
+ public function runTasks($confirmed = false, $url = null)
{
if (!isset($this->_tasklist) ||
($this->_tasklist === true)) {
if (!$processed && $need_display) {
$this->_tasklist->target = $url;
- if ($no_redirect) return $this->getLoginTasksUrl();
- header('Location: ' . $this->getLoginTasksUrl());
- exit;
+ return $this->_backend->redirect($this->getLoginTasksUrl());
} elseif ($processed && !$need_display) {
- if ($no_redirect) return $tasklist_target;
- header('Location: ' . $tasklist_target);
- exit;
+ return $this->_backend->redirect($tasklist_target);
}
}
abstract public function markLastRun();
/**
+ * Redirect to the given URL.
+ *
+ * @param string $url The URL to redirect to.
+ *
+ * @return NULL
+ */
+ abstract public function redirect($url);
+
+ /**
* Return the URL of the login tasks view.
*
* @return string The URL of the login tasks view
}
/**
+ * Redirect to the given URL.
+ *
+ * @param string $url The URL to redirect to.
+ *
+ * @return NULL
+ */
+ public function redirect($url)
+ {
+ header('Location: ' . $url);
+ exit;
+ }
+
+ /**
* Return the URL of the login tasks view.
*
* @return string The URL of the login tasks view
class Horde_LoginTasks_Class_LoginTasksTest extends PHPUnit_Framework_TestCase
{
- static private $_singleton_counter = 0;
-
public function testNoTasksAreRanIfNoUserIsAuthenticated()
{
Horde_LoginTasks_Stub_Task::$executed = array();
);
$last_time = serialize(
array(
- 'test' . self::$_singleton_counter => $last_time
+ 'test' => $last_time
)
);
}
$GLOBALS['registry']->expects($this->any())
->method('getAppDrivers')
->will($this->returnValue($tasks));
- return Horde_LoginTasks::singleton('test' . self::$_singleton_counter++);
+ return new Horde_LoginTasks(
+ new Horde_LoginTasks_Stub_Backend(
+ $GLOBALS['registry'],
+ $GLOBALS['prefs'],
+ 'test'
+ )
+ );
}
}
}
}
+class Horde_LoginTasks_Stub_Backend
+extends Horde_LoginTasks_Backend_Horde
+{
+ public function redirect($url)
+ {
+ return $url;
+ }
+}
+
class Horde_LoginTasks_Stub_TaskTwo
extends Horde_LoginTasks_Stub_Task
{