Skip to content

Commit

Permalink
Add test for session.close
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Aug 28, 2018
1 parent 91e19a5 commit 64e46c6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Http/Session.php
Expand Up @@ -369,7 +369,7 @@ public function start()
}

/**
* Write datas and close the session
* Write data and close the session
*
* @return bool True if session was started
*/
Expand Down
20 changes: 20 additions & 0 deletions tests/TestCase/Http/SessionTest.php
Expand Up @@ -19,6 +19,7 @@
use Cake\Http\Session\CacheSession;
use Cake\Http\Session\DatabaseSession;
use Cake\TestSuite\TestCase;
use RuntimeException;

/**
* TestCacheSession
Expand Down Expand Up @@ -304,6 +305,25 @@ public function testStarted()
$this->assertTrue($session->started());
}

/**
* test close method
*
* @return void
*/
public function testCloseFailure()
{
$session = new Session();
$session->started();
$this->assertTrue($session->start());
try {
$session->close();
} catch (RuntimeException $e) {
// closing the session in CLI should raise an error
// and won't close the session.
$this->assertTrue($session->started());
}
}

/**
* testClear method
*
Expand Down

0 comments on commit 64e46c6

Please sign in to comment.