ZF2-226: Zend_Session_SaveHandler_DbTable needs to use TableGateway

Description

DbTable has become TableGateway.

The database save handler for \Zend\Session needs to be converted to become compatible with ZF2.

Comments

I have started working on this issue, but I am not sure what to name the class file.

The original was called:

library/Zend/Session/SaveHandler/DbTable.php

Based on this document:

http://akrabat.com/wp-content/uploads/…

from Rob Allen, I have named it:

library/Zend/Session/SaveHandler/SessionsTable.php

Here is the class designation I have in place now:

class SessionsTable extends TableGateway implements Savable

Does this seem appropriate?

I could also do this without extending TableGateway, but still using TableGateway to handle the table.

Based on feedback, I am using:

class TableGateway extends BaseTableGateway implements Savable

where:

Zend\Db\TableGateway\TableGateway as BaseTableGateway

Zend\Session\SaveHandler as Savable

I have completed this issue.

Documentation, unit testing and the class itself are functional.

There is 100% code coverage in the unit tests.

Here is the output from TestDox listing of the 43 tests with 117 assertions:

h3.ZendTest\Session\SaveHandler\TableGateway

Adapter is properly instantiated

Insert two rows and pull first row

Insert and update rows

Constructor

Constructor throws an invalid argument exception when an invalid option is specified

Constructor with default configuration specified

Constructor with different configuration specified

Get data column

Set data column with a valid value

Set data column with an empty value and throw an exception

Default lifetime uses session gc max lifetime

Resetting lifetime

Setting lifetime with a valid value

Setting lifetime with negative value and throw an exception

Timestamp is equal to time minus the lifetime plus one second and session is not expired

Timestamp is equal to time minus the lifetime minus one second and session is expired

Timestamp is equal to zero and session is expired

Timestamp is equal to time minus twice the lifetime and session is expired

Timestamp is equal to now and session is not expired

Timestamp is equal to 10 seconds ago and session is not expired

Get primary

Set primary with a valid value

Set primary with an empty value and throw an exception

Set primary with an array and throw an exception

Get table name

Set table name with a valid value

Set table name with an empty value and throw an exception

Get timestamp column

Set timestamp column with a valid value

Set timestamp column with an empty value and throw an exception

Close session should return true

Destroy

Destroy session that does not exist

Garbage collection does delete session with timestamp equal to zero

Garbage collection does not delete session with timestamp equal to now

Garbage collection does not delete session with timestamp equal to now minus lifetime plus 10 seconds

Garbage collection does delete session with timestamp equal to now minus lifetime minus 10 seconds

Open session should return true and sets session name and session save path

Read session that does exist and is not expired because timestamp is now and return a string

Read session that does exist but is expired and destroy session and return an empty string

Read session that does not exist and return an empty string

Write session that does not exist and insert row and return true

Write session that does exist and update row and return true

Pull request has been issued for hotfix/ZF2-226:

https://github.com/gammamatrix/zf2/…

Was resolved in Pull Request #1187: https://github.com/zendframework/zf2/pull/1187