* @file
*/
-use MediaWiki\Session\SessionManager;
-
/**
* WebRequest clone which takes values from a provided array.
*
*/
class FauxRequest extends WebRequest {
private $wasPosted = false;
+ private $session = array();
private $requestUrl;
protected $cookies = array();
* @param array $data Array of *non*-urlencoded key => value pairs, the
* fake GET/POST values
* @param bool $wasPosted Whether to treat the data as POST
- * @param MediaWiki\\Session\\Session|array|null $session Session, session
- * data array, or null
+ * @param array|null $session Session array or null
* @param string $protocol 'http' or 'https'
* @throws MWException
*/
throw new MWException( "FauxRequest() got bogus data" );
}
$this->wasPosted = $wasPosted;
- if ( $session instanceof MediaWiki\Session\Session ) {
- $this->sessionId = $session->getSessionId();
- } elseif ( is_array( $session ) ) {
- $mwsession = SessionManager::singleton()->getEmptySession( $this );
- $this->sessionId = $mwsession->getSessionId();
- foreach ( $session as $key => $value ) {
- $mwsession->set( $key, $value );
- }
- } elseif ( $session !== null ) {
- throw new MWException( "FauxRequest() got bogus session" );
+ if ( $session ) {
+ $this->session = $session;
}
$this->protocol = $protocol;
}
}
}
+ public function checkSessionCookie() {
+ return false;
+ }
+
/**
* @since 1.25
*/
}
/**
+ * @param string $key
* @return array|null
*/
- public function getSessionArray() {
- if ( $this->sessionId !== null ) {
- return iterator_to_array( $this->getSession() );
+ public function getSessionData( $key ) {
+ if ( isset( $this->session[$key] ) ) {
+ return $this->session[$key];
}
return null;
}
+ /**
+ * @param string $key
+ * @param array $data
+ */
+ public function setSessionData( $key, $data ) {
+ $this->session[$key] = $data;
+ }
+
+ /**
+ * @return array|mixed|null
+ */
+ public function getSessionArray() {
+ return $this->session;
+ }
+
/**
* FauxRequests shouldn't depend on raw request data (but that could be implemented here)
* @return string