Browse Source

[HttpFoundation] Added test that exposes error in session saving

Daniel Holmes 13 years ago
parent
commit
777f876b90
1 changed files with 32 additions and 0 deletions
  1. 32 0
      tests/Symfony/Tests/Component/HttpFoundation/SessionTest.php

+ 32 - 0
tests/Symfony/Tests/Component/HttpFoundation/SessionTest.php

@@ -200,6 +200,38 @@ class SessionTest extends \PHPUnit_Framework_TestCase
         $this->assertSame(array(), $this->session->getFlashes());
         $this->assertSame(array(), $this->session->all());
     }
+    
+    public function testSavedOnDestruct()
+    {
+        $this->session->set('foo', 'bar');
+        
+        $this->session->__destruct();
+        
+        $expected = array(
+            'attributes'=>array('foo'=>'bar'),
+            'flashes'=>array(),
+            'locale'=>'en'
+        );
+        $saved = $this->storage->read('_symfony2');
+        $this->assertSame($expected, $saved);
+    }
+    
+    public function testSavedOnDestructAfterManualSave()
+    {
+        $this->session->set('foo', 'nothing');
+        $this->session->save();
+        $this->session->set('foo', 'bar');
+        
+        $this->session->__destruct();
+        
+        $expected = array(
+            'attributes'=>array('foo'=>'bar'),
+            'flashes'=>array(),
+            'locale'=>'en'
+        );
+        $saved = $this->storage->read('_symfony2');
+        $this->assertSame($expected, $saved);
+    }
 
     public function testStorageRegenerate()
     {