|
|
|
@ -3,6 +3,7 @@
|
|
|
|
|
namespace yiiunit\framework\web; |
|
|
|
|
|
|
|
|
|
use Yii; |
|
|
|
|
use yii\db\ActiveQuery; |
|
|
|
|
use yii\db\Connection; |
|
|
|
|
use yii\db\Query; |
|
|
|
|
use yii\web\DbSession; |
|
|
|
@ -41,6 +42,21 @@ class DbSessionTest extends TestCase
|
|
|
|
|
$this->assertEquals('', $session->readSession('test')); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testEncodeDataRW() |
|
|
|
|
{ |
|
|
|
|
$session = new DbSession(['encodeData' => true]); |
|
|
|
|
|
|
|
|
|
$session->writeSession('test', 'session data'); |
|
|
|
|
$session->id; |
|
|
|
|
|
|
|
|
|
$data = (new Query())->select(['data'])->from('session')->where(['id' => 'test'])->scalar(); |
|
|
|
|
$this->assertNotRegExp('~[^0-9a-zA-Z+/=]~', $data, 'The session data contains non-base64 characters'); |
|
|
|
|
|
|
|
|
|
$this->assertEquals('session data', $session->readSession('test')); |
|
|
|
|
$session->destroySession('test'); |
|
|
|
|
$this->assertEquals('', $session->readSession('test')); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @depends testReadWrite |
|
|
|
|
*/ |
|
|
|
@ -82,4 +98,4 @@ class DbSessionTest extends TestCase
|
|
|
|
|
$this->assertEquals('session data', $sessionRow['data']); |
|
|
|
|
$this->assertEquals(15, $sessionRow['user_id']); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|