diff --git a/src/Http/Session.php b/src/Http/Session.php index 4216de36f52..a129d30a34c 100644 --- a/src/Http/Session.php +++ b/src/Http/Session.php @@ -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 */ diff --git a/tests/TestCase/Http/SessionTest.php b/tests/TestCase/Http/SessionTest.php index 2ddb93d7e49..28a6661ce78 100644 --- a/tests/TestCase/Http/SessionTest.php +++ b/tests/TestCase/Http/SessionTest.php @@ -19,6 +19,7 @@ use Cake\Http\Session\CacheSession; use Cake\Http\Session\DatabaseSession; use Cake\TestSuite\TestCase; +use RuntimeException; /** * TestCacheSession @@ -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 *