Development

Changeset 10577

You must first sign up to be able to contribute.

Changeset 10577

Show
Ignore:
Timestamp:
08/01/08 15:13:22 (1 year ago)
Author:
nicolas
Message:

[1.2] backport of r10576 - enhanced database storage unit tests for MySQL, MySQLi and PDO connectors

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.2/test/unit/storage/sfMySQLStorageTest.php

    r9172 r10577  
    33/* 
    44 * This file is part of the symfony package. 
     5 * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com> 
    56 * (c) 2008 Dejan Spasic <spasic.dejan@yahoo.de> 
    67 * 
     
    1112require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    1213 
     14ob_start(); 
     15$plan = 12; 
     16$t = new lime_test($plan, new lime_output_color()); 
     17 
    1318if (!extension_loaded('mysql')) 
    1419{ 
    15   return false; 
     20  $t->skip('Mysql extension must be loaded', $plan); 
     21  exit(0); 
    1622} 
    1723 
    18 /* 
    19 $sfTestMysqlSessionStorage_DatabaseName = 'sf_unit_test'; 
    20 $sfTestMysqlSessionStorage_MysqlParameters = array( 
    21   'database' => $sfTestMysqlSessionStorage_DatabaseName, 
    22     'username' => 'root', 'password' => '', 'method' => 'normal'); 
    23 */ 
     24// Configure your database with the settings below in order to run the test 
     25$mysql_config = array( 
     26  'host'     => 'localhost', 
     27  'username' => 'root',  
     28  'password' => '',  
     29); 
    2430 
    25 ob_start(); 
    26 $t = new lime_test(5, new lime_output_color()); 
     31if (!isset($mysql_config)) 
     32
     33  $t->skip('Mysql credentials needed to run these tests', $plan); 
     34  exit(0); 
     35
    2736 
    28 if(isset($sfTestMysqlSessionStorage_DatabaseName, $sfTestMysqlSessionStorage_MysqlParameters)) 
     37try 
    2938{ 
    30   $connection = mysql_connect('localhost', 
    31     $sfTestMysqlSessionStorage_MysqlParameters['username'], 
    32     $sfTestMysqlSessionStorage_MysqlParameters['password']) 
    33     or $t->fail('Can not connect to mysql server'); 
     39  // Creating mysql database connection 
     40  $database = new sfMySQLDatabase($mysql_config); 
     41  $connection = $database->getResource(); 
     42
     43catch (sfDatabaseException $e) 
     44
     45  $t->diag($e->getMessage()); 
     46  $t->skip('Unable to connect to MySQL database, skipping', $plan); 
     47  exit(0); 
     48
    3449 
    35   mysql_query('DROP DATABASE ' . $sfTestMysqlSessionStorage_DatabaseName, $connection); 
    36   mysql_query('CREATE DATABASE ' . $sfTestMysqlSessionStorage_DatabaseName, $connection) 
    37     or $t->fail('Can not create database ' . $sfTestMysqlSessionStorage_DatabaseName); 
     50// Creates test database 
     51mysql_query('DROP DATABASE IF EXISTS sf_mysql_storage_unit_test', $connection); 
     52mysql_query('CREATE DATABASE sf_mysql_storage_unit_test', $connection) or $t->fail('Cannot create database sf_mysql_storage_unit_test'); 
     53mysql_select_db('sf_mysql_storage_unit_test', $connection); 
     54mysql_query("CREATE TABLE `session` ( 
     55  `sess_id` varchar(40) NOT NULL PRIMARY KEY, 
     56  `sess_time` int(10) unsigned NOT NULL default '0', 
     57  `sess_data` text collate utf8_unicode_ci 
     58) ENGINE=MyISAM", $connection)  
     59  or $t->fail('Can not create table session'); 
    3860 
    39   mysql_select_db($sfTestMysqlSessionStorage_DatabaseName, $connection); 
    40   mysql_close($connection)
     61ini_set('session.use_cookies', 0); 
     62$session_id = "1"
    4163 
    42   unset($connection); 
     64$storage = new sfMySQLSessionStorage(array( 
     65  'db_table'   => 'session', 
     66  'session_id' => $session_id, 
     67  'database'   => $database) 
     68); 
    4369 
    44   // initialize the storage 
    45   $database = new sfMySQLDatabase($sfTestMysqlSessionStorage_MysqlParameters); 
     70$t->ok($storage instanceof sfStorage, 'sfMySQLSessionStorage is an instance of sfStorage'); 
     71$t->ok($storage instanceof sfDatabaseSessionStorage, 'sfMySQLSessionStorage is an instance of sfDatabaseSessionStorage'); 
    4672 
    47   mysql_query("CREATE TABLE `session` ( 
    48     `sess_id` varchar(40) NOT NULL PRIMARY KEY, 
    49     `sess_time` int(10) unsigned NOT NULL default '0', 
    50     `sess_data` text collate utf8_unicode_ci 
    51   ) ENGINE=MyISAM", $database->getResource()) 
    52     or $t->fail('Can not create table session'); 
     73// regenerate() 
     74$storage->regenerate(false); 
     75$t->isnt(session_id(), $session_id, 'regenerate() regenerated the session id'); 
     76$session_id = session_id(); 
    5377 
    54   ini_set('session.use_cookies', 0); 
    55   $sessionId = "1"; 
     78// do some session operations 
     79$_SESSION['foo'] = 'bar'; 
     80$_SESSION['bar'] = 'foo'; 
     81unset($_SESSION['foo']); 
     82$session_data = session_encode(); 
    5683 
    57   $storage = new sfMySQLSessionStorage(array('db_table' => 'session', 
    58                                              'session_id' => $sessionId, 
    59                                              'database' => $database)); 
     84// end of session 
     85session_write_close(); 
    6086 
    61   $t->ok($storage instanceof sfStorage, 'sfMySQLSessionStorage is an instance of sfStorage'); 
    62   $t->ok($storage instanceof sfDatabaseSessionStorage, 'sfMySQLSessionStorage is an instance of sfDatabaseSessionStorage'); 
     87// check session data in the database 
     88$result = mysql_query(sprintf('SELECT sess_data FROM session WHERE sess_id = "%s"', $session_id), $connection); 
     89list($thisSessData) = mysql_fetch_row($result); 
     90$t->is(mysql_num_rows($result), 1, 'session is stored in the database'); 
     91$t->is($thisSessData, $session_data, 'session variables are stored in the database'); 
    6392 
    64   // do some session operations 
    65   $_SESSION['foo'] = 'bar'; 
    66   $_SESSION['bar'] = 'foo'; 
    67   unset($_SESSION['foo']); 
    68   $sessionData = session_encode(); 
     93mysql_free_result($result); 
     94unset($thisSessData, $result); 
    6995 
    70   // end of session 
    71   session_write_close(); 
     96// sessionRead() 
     97try 
     98
     99  $retrieved_data = $storage->sessionRead($session_id); 
     100  $t->pass('sessionRead() does not throw an exception'); 
     101
     102catch (Exception $e) 
     103
     104  $t->fail('sessionRead() does not throw an exception'); 
     105
     106$t->is($retrieved_data, $session_data, 'sessionRead() reads session data'); 
    72107 
    73   // check session data in the database 
    74   $result = mysql_query(sprintf('SELECT sess_data FROM session WHERE sess_id = "%s"', $sessionId), $database->getResource()); 
    75   list($thisSessData) = mysql_fetch_row($result); 
    76   $t->is(mysql_num_rows($result), 1, 'session is stored in the database'); 
    77   $t->is($thisSessData, $sessionData, 'session variables are stored in the database'); 
     108// sessionWrite() 
     109$_SESSION['baz'] = 'woo'; 
     110$session_data = session_encode(); 
     111try 
     112
     113  $write = $storage->sessionWrite($session_id, $session_data); 
     114  $t->pass('sessionWrite() does not throw an exception'); 
     115
     116catch (Exception $e) 
     117
     118  $t->fail('sessionWrite() does not throw an exception'); 
     119
    78120 
    79   mysql_free_result($result); 
    80   unset($thisSessData, $result); 
     121$t->ok($write, 'sessionWrite() returns true'); 
     122$t->is($storage->sessionRead($session_id), $session_data, 'sessionWrite() wrote session data'); 
    81123 
    82   // destroy the session 
    83   $storage->sessionDestroy($sessionId); 
    84   $result = mysql_query(sprintf('SELECT COUNT(sess_id) FROM session WHERE sess_id = "%s"', $sessionId), $database->getResource()); 
     124// sessionDestroy() 
     125try 
     126
     127  $storage->sessionDestroy($session_id); 
     128  $t->pass('sessionDestroy() does not throw an exception'); 
     129
     130catch (Exception $e) 
     131
     132  $t->fail('sessionDestroy() does not throw an exception'); 
     133
    85134 
    86   list($count) = mysql_fetch_row($result); 
    87   $t->is($count, 0, 'session is removed from the database'); 
     135$result = mysql_query(sprintf('SELECT COUNT(sess_id) FROM session WHERE sess_id = "%s"', $session_id), $connection); 
    88136 
    89   mysql_free_result($result); 
    90   unset($count, $result); 
     137list($count) = mysql_fetch_row($result); 
     138$t->is($count, 0, 'session is removed from the database'); 
    91139 
    92   mysql_query('DROP DATABASE ' . $sfTestMysqlSessionStorage_DatabaseName, $database->getResource()); 
     140mysql_free_result($result); 
     141unset($count, $result); 
    93142 
    94   // shutdown the storage 
    95   $storage->shutdown(); 
     143mysql_query('DROP DATABASE sf_mysql_storage_unit_test', $connection); 
    96144 
    97   // shutdown the databas
    98   $database->shutdown(); 
     145// shutdown the storag
     146$storage->shutdown(); 
    99147 
    100   unset($sfTestMysqlSessionStorage_DatabaseName, $sfTestMysqlSessionStorage_MysqlParameters); 
    101 
    102 else 
    103 
    104   $t->skip('Mysql credentials needed to run these tests', 5); 
    105 
     148// shutdown the database 
     149$database->shutdown(); 
     150 
     151unset($mysql_config); 
  • branches/1.2/test/unit/storage/sfMySQLiStorageTest.php

    r9172 r10577  
    33/* 
    44 * This file is part of the symfony package. 
     5 * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com> 
    56 * (c) 2008 Dejan Spasic <spasic.dejan@yahoo.de> 
    67 * 
     
    1112require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    1213 
     14ob_start(); 
     15$plan = 12; 
     16$t = new lime_test($plan, new lime_output_color()); 
     17 
    1318if (!extension_loaded('mysqli')) 
    1419{ 
    15   return false; 
     20  $t->skip('Mysqli extension must be loaded', $plan); 
     21  exit(0); 
    1622} 
    1723 
    18 /* 
    19 $sfTestMysqlSessionStorage_DatabaseName = 'sf_unit_test'; 
    20 $sfTestMysqlSessionStorage_MysqlParameters = array( 
    21   'database' => $sfTestMysqlSessionStorage_DatabaseName, 
    22     'username' => 'root', 'password' => '', 'method' => 'normal'); 
    23 */ 
     24// Configure your database with the settings below in order to run the test 
     25$mysqli_config = array( 
     26  'host'     => 'localhost', 
     27  'username' => 'root',  
     28  'password' => '',  
     29); 
    2430 
    25 ob_start(); 
    26 $t = new lime_test(5, new lime_output_color()); 
     31if (!isset($mysqli_config)) 
     32
     33  $t->skip('Mysql credentials needed to run these tests', $plan); 
     34  exit(0); 
     35
    2736 
    28 if(isset($sfTestMysqlSessionStorage_DatabaseName, $sfTestMysqlSessionStorage_MysqlParameters)) 
     37try 
    2938{ 
    30   $connection = mysqli_connect('localhost', 
    31     $sfTestMysqlSessionStorage_MysqlParameters['username'], 
    32     $sfTestMysqlSessionStorage_MysqlParameters['password']) 
    33     or $t->fail('Can not connect to mysql server'); 
     39  // Creating mysql database connection 
     40  $database = new sfMySQLiDatabase($mysqli_config); 
     41  $connection = $database->getResource(); 
     42
     43catch (sfDatabaseException $e) 
     44
     45  $t->diag($e->getMessage()); 
     46  $t->skip('Unable to connect to MySQL database, skipping', $plan); 
     47  exit(0); 
     48
    3449 
    35   mysqli_query($connection, 'DROP DATABASE ' . $sfTestMysqlSessionStorage_DatabaseName); 
    36   mysqli_query($connection, 'CREATE DATABASE ' . $sfTestMysqlSessionStorage_DatabaseName) 
    37     or $t->fail('Can not create database ' . $sfTestMysqlSessionStorage_DatabaseName); 
     50// Creates test database 
     51mysqli_query($connection, 'DROP DATABASE IF EXISTS sf_mysqli_storage_unit_test'); 
     52mysqli_query($connection, 'CREATE DATABASE sf_mysqli_storage_unit_test') or $t->fail('Cannot create database sf_mysqli_storage_unit_test'); 
     53mysqli_select_db($connection, 'sf_mysqli_storage_unit_test'); 
     54mysqli_query($connection, "CREATE TABLE `session` ( 
     55  `sess_id` varchar(40) NOT NULL PRIMARY KEY, 
     56  `sess_time` int(10) unsigned NOT NULL default '0', 
     57  `sess_data` text collate utf8_unicode_ci 
     58) ENGINE=MyISAM")  
     59  or $t->fail('Can not create table session'); 
    3860 
    39   mysqli_select_db($connection,$sfTestMysqlSessionStorage_DatabaseName); 
    40   mysqli_close($connection)
     61ini_set('session.use_cookies', 0); 
     62$session_id = "1"
    4163 
    42   unset($connection); 
     64$storage = new sfMySQLiSessionStorage(array( 
     65  'db_table'   => 'session', 
     66  'session_id' => $session_id, 
     67  'database'   => $database) 
     68); 
    4369 
    44   // initialize the storage 
    45   $database = new sfMySQLiDatabase($sfTestMysqlSessionStorage_MysqlParameters); 
     70$t->ok($storage instanceof sfStorage, 'sfMySQLSessionStorage is an instance of sfStorage'); 
     71$t->ok($storage instanceof sfDatabaseSessionStorage, 'sfMySQLSessionStorage is an instance of sfDatabaseSessionStorage'); 
    4672 
    47   mysqli_query($database->getResource(), 
    48   "CREATE TABLE `session` ( 
    49     `sess_id` varchar(40) NOT NULL PRIMARY KEY, 
    50     `sess_time` int(10) unsigned NOT NULL default '0', 
    51     `sess_data` text collate utf8_unicode_ci 
    52   ) ENGINE=MyISAM") 
    53     or $t->fail('Can not create table session'); 
     73// regenerate() 
     74$storage->regenerate(false); 
     75$t->isnt(session_id(), $session_id, 'regenerate() regenerated the session id'); 
     76$session_id = session_id(); 
    5477 
    55   ini_set('session.use_cookies', 0); 
    56   $sessionId = "1"; 
     78// do some session operations 
     79$_SESSION['foo'] = 'bar'; 
     80$_SESSION['bar'] = 'foo'; 
     81unset($_SESSION['foo']); 
     82$session_data = session_encode(); 
    5783 
    58   $storage = new sfMySQLiSessionStorage(array('db_table' => 'session', 
    59                                              'session_id' => $sessionId, 
    60                                              'database' => $database)); 
     84// end of session 
     85session_write_close(); 
    6186 
    62   $t->ok($storage instanceof sfStorage, 'sfMySQLSessionStorage is an instance of sfStorage'); 
    63   $t->ok($storage instanceof sfDatabaseSessionStorage, 'sfMySQLSessionStorage is an instance of sfDatabaseSessionStorage'); 
     87// check session data in the database 
     88$result = mysqli_query($connection, sprintf('SELECT sess_data FROM session WHERE sess_id = "%s"', $session_id)); 
     89list($thisSessData) = mysqli_fetch_row($result); 
     90$t->is(mysqli_num_rows($result), 1, 'session is stored in the database'); 
     91$t->is($thisSessData, $session_data, 'session variables are stored in the database'); 
    6492 
    65   // do some session operations 
    66   $_SESSION['foo'] = 'bar'; 
    67   $_SESSION['bar'] = 'foo'; 
    68   unset($_SESSION['foo']); 
    69   $sessionData = session_encode(); 
     93mysqli_free_result($result); 
     94unset($thisSessData, $result); 
    7095 
    71   // end of session 
    72   session_write_close(); 
     96// sessionRead() 
     97try 
     98
     99  $retrieved_data = $storage->sessionRead($session_id); 
     100  $t->pass('sessionRead() does not throw an exception'); 
     101
     102catch (Exception $e) 
     103
     104  $t->fail('sessionRead() does not throw an exception'); 
     105
     106$t->is($retrieved_data, $session_data, 'sessionRead() reads session data'); 
    73107 
    74   // check session data in the database 
    75   $result = mysqli_query($database->getResource(), sprintf('SELECT sess_data FROM session WHERE sess_id = "%s"', $sessionId)); 
    76   list($thisSessData) = mysqli_fetch_row($result); 
    77   $t->is(mysqli_num_rows($result), 1, 'session is stored in the database'); 
    78   $t->is($thisSessData, $sessionData, 'session variables are stored in the database'); 
     108// sessionWrite() 
     109$_SESSION['baz'] = 'woo'; 
     110$session_data = session_encode(); 
     111try 
     112
     113  $write = $storage->sessionWrite($session_id, $session_data); 
     114  $t->pass('sessionWrite() does not throw an exception'); 
     115
     116catch (Exception $e) 
     117
     118  $t->fail('sessionWrite() does not throw an exception'); 
     119
    79120 
    80   mysqli_free_result($result); 
    81   unset($thisSessData, $result); 
     121$t->ok($write, 'sessionWrite() returns true'); 
     122$t->is($storage->sessionRead($session_id), $session_data, 'sessionWrite() wrote session data'); 
    82123 
    83   // destroy the session 
    84   $storage->sessionDestroy($sessionId); 
    85   $result = mysqli_query($database->getResource(), sprintf('SELECT COUNT(sess_id) FROM session WHERE sess_id = "%s"', $sessionId)); 
     124// sessionDestroy() 
     125try 
     126
     127  $storage->sessionDestroy($session_id); 
     128  $t->pass('sessionDestroy() does not throw an exception'); 
     129
     130catch (Exception $e) 
     131
     132  $t->fail('sessionDestroy() does not throw an exception'); 
     133
    86134 
    87   list($count) = mysqli_fetch_row($result); 
    88   $t->is($count, 0, 'session is removed from the database'); 
     135$result = mysqli_query($connection, sprintf('SELECT COUNT(sess_id) FROM session WHERE sess_id = "%s"', $session_id)); 
    89136 
    90   mysqli_free_result($result); 
    91   unset($count, $result); 
     137list($count) = mysqli_fetch_row($result); 
     138$t->is($count, 0, 'session is removed from the database'); 
    92139 
    93   mysqli_query($database->getResource(), 'DROP DATABASE ' . $sfTestMysqlSessionStorage_DatabaseName); 
     140mysqli_free_result($result); 
     141unset($count, $result); 
    94142 
    95   // shutdown the storage 
    96   $storage->shutdown(); 
     143mysqli_query($connection, 'DROP DATABASE sf_mysqli_storage_unit_test'); 
    97144 
    98   // shutdown the databas
    99   $database->shutdown(); 
     145// shutdown the storag
     146$storage->shutdown(); 
    100147 
    101   unset($sfTestMysqlSessionStorage_DatabaseName, $sfTestMysqlSessionStorage_MysqlParameters); 
    102 
    103 else 
    104 
    105   $t->skip('Mysql credentials needed to run these tests', 5); 
    106 
     148// shutdown the database 
     149$database->shutdown(); 
     150 
     151unset($mysqli_config); 
  • branches/1.2/test/unit/storage/sfPDOSessionStorageTest.php

    r9662 r10577  
    1212 
    1313ob_start(); 
    14 $t = new lime_test(5, new lime_output_color()); 
     14$t = new lime_test(13, new lime_output_color()); 
    1515 
    1616if (!extension_loaded('SQLite')) 
    1717{ 
    1818  $t->skip('SQLite needed to run these tests', 5); 
     19  exit(0); 
    1920} 
    20 else 
     21 
     22// initialize the storage 
     23$database = new sfPDODatabase(array('dsn' => 'sqlite::memory:')); 
     24$connection = $database->getConnection(); 
     25$connection->exec('CREATE TABLE session (sess_id, sess_data, sess_time)'); 
     26 
     27ini_set('session.use_cookies', 0); 
     28$session_id = "1"; 
     29 
     30$storage = new sfPDOSessionStorage(array('db_table' => 'session', 'session_id' => $session_id, 'database' => $database)); 
     31$t->ok($storage instanceof sfStorage, 'sfPDOSessionStorage is an instance of sfStorage'); 
     32$t->ok($storage instanceof sfDatabaseSessionStorage, 'sfPDOSessionStorage is an instance of sfDatabaseSessionStorage'); 
     33 
     34// regenerate() 
     35$storage->regenerate(false); 
     36$t->isnt(session_id(), $session_id, 'regenerate() regenerated the session id'); 
     37$session_id = session_id(); 
     38 
     39// do some session operations 
     40$_SESSION['foo'] = 'bar'; 
     41$_SESSION['bar'] = 'foo'; 
     42unset($_SESSION['foo']); 
     43$session_data = session_encode(); 
     44 
     45// end of session 
     46session_write_close(); 
     47 
     48// check session data in the database 
     49$result = $connection->query(sprintf('SELECT sess_id, sess_data FROM session WHERE sess_id = "%s"', $session_id)); 
     50$data = $result->fetchAll(); 
     51$t->is(count($data), 1, 'session is stored in the database'); 
     52$t->is($data[0]['sess_data'], $session_data, 'session variables are stored in the database'); 
     53 
     54// sessionRead() 
     55try 
    2156{ 
    22   // initialize the storage 
    23   $database = new sfPDODatabase(array('dsn' => 'sqlite::memory:')); 
    24   $connection = $database->getConnection(); 
    25   $connection->exec('CREATE TABLE session (sess_id, sess_data, sess_time)'); 
     57  $retrieved_data = $storage->sessionRead($session_id); 
     58  $t->pass('sessionRead() does not throw an exception'); 
     59
     60catch (Exception $e) 
     61
     62  $t->fail('sessionRead() does not throw an exception'); 
     63
     64$t->is($retrieved_data, $session_data, 'sessionRead() reads session data'); 
    2665 
    27   ini_set('session.use_cookies', 0); 
    28   $session_id = "1"; 
     66// sessionWrite() 
     67$_SESSION['baz'] = 'woo'; 
     68$session_data = session_encode(); 
     69try 
     70
     71  $write = $storage->sessionWrite($session_id, $session_data); 
     72  $t->pass('sessionWrite() does not throw an exception'); 
     73
     74catch (Exception $e) 
     75
     76  $t->fail('sessionWrite() does not throw an exception'); 
     77
    2978 
    30   $storage = new sfPDOSessionStorage(array('db_table' => 'session', 'session_id' => $session_id, 'database' => $database)); 
    31   $t->ok($storage instanceof sfStorage, 'sfPDOSessionStorage is an instance of sfStorage'); 
    32   $t->ok($storage instanceof sfDatabaseSessionStorage, 'sfPDOSessionStorage is an instance of sfDatabaseSessionStorage'); 
     79$t->ok($write, 'sessionWrite() returns true'); 
     80$t->is($storage->sessionRead($session_id), $session_data, 'sessionWrite() wrote session data'); 
    3381 
    34   // do some session operations 
    35   $_SESSION['foo'] = 'bar'; 
    36   $_SESSION['bar'] = 'foo'; 
    37   unset($_SESSION['foo']); 
    38   $session_data = session_encode(); 
     82// sessionGC() 
     83try 
     84
     85  $storage->sessionGC(0); 
     86  $t->pass('sessionGC() does not throw an exception'); 
     87
     88catch (Exception $e) 
     89
     90  $t->fail('sessionGC() does not throw an exception'); 
     91
    3992 
    40   // end of session 
    41   session_write_close(); 
     93// destroy the session 
     94try 
     95
     96  $storage->sessionDestroy($session_id); 
     97  $t->pass('sessionDestroy() does not throw an exception'); 
     98
     99catch (Exception $e) 
     100
     101  $t->fail('sessionClose() does not throw an exception'); 
     102
     103$result = $connection->query(sprintf('SELECT sess_id, sess_data FROM session WHERE sess_id = "%s"', $session_id)); 
     104$data = $result->fetchAll(); 
     105$t->is(count($data), 0, 'session is removed from the database'); 
    42106 
    43   // check session data in the database 
    44   $result = $connection->query(sprintf('SELECT sess_id, sess_data FROM session WHERE sess_id = "%s"', $session_id)); 
    45   $data = $result->fetchAll(); 
    46   $t->is(count($data), 1, 'session is stored in the database'); 
    47   $t->is($data[0]['sess_data'], $session_data, 'session variables are stored in the database'); 
    48  
    49   // destroy the session 
    50   $storage->sessionDestroy($session_id); 
    51   $result = $connection->query(sprintf('SELECT sess_id, sess_data FROM session WHERE sess_id = "%s"', $session_id)); 
    52   $data = $result->fetchAll(); 
    53   $t->is(count($data), 0, 'session is removed from the database'); 
    54  
    55   // shutdown the storage 
    56   $storage->shutdown(); 
    57 
     107// shutdown the storage 
     108$storage->shutdown(); 

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting, and supporting several large Open-Source projects.