-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Started some tests for Session library
- Loading branch information
1 parent
e69777b
commit 0634ac6
Showing
5 changed files
with
418 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php namespace CodeIgniter\Session; | ||
|
||
/** | ||
* Class MockSession | ||
* | ||
* Provides a safe way to test the Session class itself, | ||
* that doesn't interact with the session or cookies at all. | ||
*/ | ||
class MockSession extends Session | ||
{ | ||
/** | ||
* Holds our "cookie" data. | ||
* @var array | ||
*/ | ||
public $cookies = []; | ||
|
||
public $didRegenerate = false; | ||
|
||
//-------------------------------------------------------------------- | ||
|
||
/** | ||
* Sets the driver as the session handler in PHP. | ||
* Extracted for easier testing. | ||
*/ | ||
protected function setSaveHandler() | ||
{ | ||
// session_set_save_handler($this->driver, true); | ||
} | ||
|
||
//-------------------------------------------------------------------- | ||
|
||
/** | ||
* Starts the session. | ||
* Extracted for testing reasons. | ||
*/ | ||
protected function startSession() | ||
{ | ||
// session_start(); | ||
} | ||
|
||
//-------------------------------------------------------------------- | ||
|
||
/** | ||
* Takes care of setting the cookie on the client side. | ||
* Extracted for testing reasons. | ||
*/ | ||
protected function setCookie() | ||
{ | ||
$this->cookies[] = [ | ||
$this->sessionCookieName, | ||
session_id(), | ||
(empty($this->sessionExpiration) ? 0 : time()+$this->sessionExpiration), | ||
$this->cookiePath, | ||
$this->cookieDomain, | ||
$this->cookieSecure, | ||
true | ||
]; | ||
} | ||
|
||
//-------------------------------------------------------------------- | ||
|
||
public function regenerate(bool $destroy = false) | ||
{ | ||
$this->didRegenerate = true; | ||
$_SESSION['__ci_last_regenerate'] = time(); | ||
} | ||
|
||
//-------------------------------------------------------------------- | ||
} |
Oops, something went wrong.