Browse Source

Added "memory" (array based) session driver to ease the unit testing of session reliant operations.

Signed-off-by: Taylor Otwell <taylorotwell@gmail.com>
Taylor Otwell 12 years ago
parent
commit
3c9a4b1aad
2 changed files with 52 additions and 0 deletions
  1. 3 0
      laravel/session.php
  2. 49 0
      laravel/session/drivers/memory.php

+ 3 - 0
laravel/session.php

@@ -64,6 +64,9 @@ class Session {
 			case 'memcached':
 				return new Session\Drivers\Memcached(Cache::driver('memcached'));
 
+			case 'memory':
+				return new Session\Drivers\Memory;
+
 			case 'redis':
 				return new Session\Drivers\Redis(Cache::driver('redis'));
 

+ 49 - 0
laravel/session/drivers/memory.php

@@ -0,0 +1,49 @@
+<?php namespace Laravel\Session\Drivers;
+
+class Memory extends Driver {
+
+	/**
+	 * The session payload that will be returned by the driver.
+	 *
+	 * @var array
+	 */
+	public $session;
+
+	/**
+	 * Load a session from storage by a given ID.
+	 *
+	 * If no session is found for the ID, null will be returned.
+	 *
+	 * @param  string  $id
+	 * @return array
+	 */
+	public function load($id)
+	{
+		return $this->session;
+	}
+
+	/**
+	 * Save a given session to storage.
+	 *
+	 * @param  array  $session
+	 * @param  array  $config
+	 * @param  bool   $exists
+	 * @return void
+	 */
+	public function save($session, $config, $exists)
+	{
+		//
+	}
+
+	/**
+	 * Delete a session from storage by a given ID.
+	 *
+	 * @param  string  $id
+	 * @return void
+	 */
+	public function delete($id)
+	{
+		//
+	}
+
+}