Skip to content

Commit

Permalink
Fixed integration test with session data due to refactor in [3.4.0], …
Browse files Browse the repository at this point in the history
…now the Session object is shared from the Request instead of creating a new one.
  • Loading branch information
jamielsharief committed Aug 24, 2020
1 parent 4735859 commit ab46e56
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 16 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [3.4.1] - 2020-08-24

### Fixed

- Fixed integration test with session data due to refactor in [3.4.0], now the Session object is shared from the Request instead of creating a new one.

## [3.4.0] - 2020-08-22

### Added
Expand Down
8 changes: 2 additions & 6 deletions src/Http/Controller/Component/SessionComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,13 @@ class SessionComponent extends Component
protected $session = null;

/**
* Lazy loads the session object
* Gets the Session object from the Request
*
* @return \Origin\Http\Session
*/
protected function session(): Session
{
if ($this->session === null) {
$this->session = new Session();
}

return $this->session;
return $this->request()->session();
}
/**
* Reads a value of a session
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ public function headers($header = null)
/**
* Returns the session object
*
* @return Session
* @return \Origin\Http\Session
*/
public function session(): Session
{
Expand Down
8 changes: 2 additions & 6 deletions src/Http/View/Helper/SessionHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,13 @@ class SessionHelper extends Helper
protected $session = null;

/**
* Lazy loads the session object
* Gets the Session object from the Request
*
* @return \Origin\Http\Session
*/
protected function session(): Session
{
if ($this->session === null) {
$this->session = new Session();
}

return $this->session;
return $this->request()->session();
}

/**
Expand Down
5 changes: 2 additions & 3 deletions src/TestSuite/IntegrationTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,7 @@ protected function sendRequest(string $method, $url, array $data = [])
}

$this->request = new Request($url);
$this->request->session()->destroy();


$this->response = $this->getMockBuilder(Response::class)
->setMethods(['send','stop'])
->getMock();
Expand All @@ -329,7 +328,7 @@ protected function sendRequest(string $method, $url, array $data = [])
foreach ($this->session as $key => $value) {
$this->request->session()->write($key, $value);
}

// Send Headers
foreach ($this->headers as $header => $value) {
$this->response->header($header, $value);
Expand Down

0 comments on commit ab46e56

Please sign in to comment.