public function testSerializingTooLongValueWritesLogAndDoesntCreateCookie()
 {
     \Slim\Environment::mock(array('SCRIPT_NAME' => '/index.php', 'PATH_INFO' => '/foo'));
     $logWriter = $this->getMockBuilder('Slim\\LogWriter')->disableOriginalConstructor()->getMock();
     $logWriter->expects($this->once())->method('write')->with('WARNING! Slim\\Middleware\\SessionCookie data size is larger than 4KB. Content save failed.', \Slim\Log::ERROR);
     $app = new \Slim\Slim(array('log.writer' => $logWriter));
     $tooLongValue = $this->getTooLongValue();
     $app->get('/foo', function () use($tooLongValue) {
         $_SESSION['test'] = $tooLongValue;
         echo "Success";
     });
     $mw = new \Slim\Middleware\SessionCookie(array('expires' => '10 years'));
     $mw->setApplication($app);
     $mw->setNextMiddleware($app);
     $mw->call();
     list($status, $header, $body) = $app->response()->finalize();
     $this->assertFalse($app->response->cookies->has('slim_session'));
 }
Exemplo n.º 2
0
 /**
  * Test $_SESSION is populated as empty array if no HTTP cookie
  */
 public function testSessionIsPopulatedAsEmptyIfNoCookie()
 {
     \Slim\Environment::mock(array('SCRIPT_NAME' => '/index.php', 'PATH_INFO' => '/foo'));
     $app = new \Slim\Slim();
     $app->get('/foo', function () {
         echo "Success";
     });
     $mw = new \Slim\Middleware\SessionCookie(array('expires' => '10 years'));
     $mw->setApplication($app);
     $mw->setNextMiddleware($app);
     $mw->call();
     $this->assertEquals(array(), $_SESSION);
 }