Example #1
0
 /** @test */
 public function it_should_support_the_database_session_handler()
 {
     $database = __DIR__ . '/session.sqlite';
     if (file_exists($database)) {
         unlink($database);
     }
     touch($database);
     $connection = ['driver' => 'sqlite', 'database' => $database, 'prefix' => ''];
     $table = 'sessions';
     $Session = new Session(['driver' => 'database', 'connection' => $connection, 'table' => $table]);
     $Session->start();
     $this->assertions($Session);
     $sid = $Session->getId();
     register_shutdown_function(function () use($sid, $connection, $table) {
         $Database = new Manager();
         $Database->addConnection($connection);
         $Db = $Database->getDatabaseManager();
         $results = $Db->select('select id from ' . $table . ' LIMIT 1');
         $this->assertEquals(1, count($results));
         $row = array_shift($results);
         $this->assertEquals($sid, $row['id']);
         unlink($connection['database']);
     });
 }