Passed
Push — 1.0.0-dev ( b68981...00dab9 )
by nguereza
05:23
created
tests/tnhfw/classes/models/DBSessionHandlerModelTest.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -1,31 +1,31 @@
 block discarded – undo
1 1
 <?php 
2 2
 
3
-	use PHPUnit\Framework\TestCase;
3
+    use PHPUnit\Framework\TestCase;
4 4
 
5
-	class DBSessionHandlerModelTest extends TestCase
6
-	{	
5
+    class DBSessionHandlerModelTest extends TestCase
6
+    {	
7 7
 	
8
-		public static function setUpBeforeClass()
9
-		{
8
+        public static function setUpBeforeClass()
9
+        {
10 10
 		
11
-		}
11
+        }
12 12
 		
13
-		public static function tearDownAfterClass()
14
-		{
13
+        public static function tearDownAfterClass()
14
+        {
15 15
 			
16
-		}
16
+        }
17 17
 		
18
-		protected function setUp()
19
-		{
20
-		}
18
+        protected function setUp()
19
+        {
20
+        }
21 21
 
22
-		protected function tearDown()
23
-		{
24
-		}
22
+        protected function tearDown()
23
+        {
24
+        }
25 25
 		
26
-		public function testNotYet()
27
-		{
28
-			$this->markTestSkipped();
29
-		}
26
+        public function testNotYet()
27
+        {
28
+            $this->markTestSkipped();
29
+        }
30 30
 
31
-	}
32 31
\ No newline at end of file
32
+    }
33 33
\ No newline at end of file
Please login to merge, or discard this patch.
tests/tnhfw/classes/DatabaseTest.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -1,31 +1,31 @@
 block discarded – undo
1 1
 <?php 
2 2
 
3
-	use PHPUnit\Framework\TestCase;
3
+    use PHPUnit\Framework\TestCase;
4 4
 
5
-	class DatabaseTest extends TestCase
6
-	{	
5
+    class DatabaseTest extends TestCase
6
+    {	
7 7
 	
8
-		public static function setUpBeforeClass()
9
-		{
8
+        public static function setUpBeforeClass()
9
+        {
10 10
 		
11
-		}
11
+        }
12 12
 		
13
-		public static function tearDownAfterClass()
14
-		{
13
+        public static function tearDownAfterClass()
14
+        {
15 15
 			
16
-		}
16
+        }
17 17
 		
18
-		protected function setUp()
19
-		{
20
-		}
18
+        protected function setUp()
19
+        {
20
+        }
21 21
 
22
-		protected function tearDown()
23
-		{
24
-		}
22
+        protected function tearDown()
23
+        {
24
+        }
25 25
 		
26
-		public function testNotYet()
27
-		{
28
-			$this->markTestSkipped();
29
-		}
26
+        public function testNotYet()
27
+        {
28
+            $this->markTestSkipped();
29
+        }
30 30
 
31
-	}
32 31
\ No newline at end of file
32
+    }
33 33
\ No newline at end of file
Please login to merge, or discard this patch.
tests/tnhfw/classes/ConfigTest.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -1,31 +1,31 @@
 block discarded – undo
1 1
 <?php 
2 2
 
3
-	use PHPUnit\Framework\TestCase;
3
+    use PHPUnit\Framework\TestCase;
4 4
 
5
-	class ConfigTest extends TestCase
6
-	{	
5
+    class ConfigTest extends TestCase
6
+    {	
7 7
 	
8
-		public static function setUpBeforeClass()
9
-		{
8
+        public static function setUpBeforeClass()
9
+        {
10 10
 		
11
-		}
11
+        }
12 12
 		
13
-		public static function tearDownAfterClass()
14
-		{
13
+        public static function tearDownAfterClass()
14
+        {
15 15
 			
16
-		}
16
+        }
17 17
 		
18
-		protected function setUp()
19
-		{
20
-		}
18
+        protected function setUp()
19
+        {
20
+        }
21 21
 
22
-		protected function tearDown()
23
-		{
24
-		}
22
+        protected function tearDown()
23
+        {
24
+        }
25 25
 		
26
-		public function testNotYet()
27
-		{
28
-			$this->markTestSkipped();
29
-		}
26
+        public function testNotYet()
27
+        {
28
+            $this->markTestSkipped();
29
+        }
30 30
 
31
-	}
32 31
\ No newline at end of file
32
+    }
33 33
\ No newline at end of file
Please login to merge, or discard this patch.
tests/tnhfw/classes/SecurityTest.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -1,31 +1,31 @@
 block discarded – undo
1 1
 <?php 
2 2
 
3
-	use PHPUnit\Framework\TestCase;
3
+    use PHPUnit\Framework\TestCase;
4 4
 
5
-	class SecurityTest extends TestCase
6
-	{	
5
+    class SecurityTest extends TestCase
6
+    {	
7 7
 	
8
-		public static function setUpBeforeClass()
9
-		{
8
+        public static function setUpBeforeClass()
9
+        {
10 10
 		
11
-		}
11
+        }
12 12
 		
13
-		public static function tearDownAfterClass()
14
-		{
13
+        public static function tearDownAfterClass()
14
+        {
15 15
 			
16
-		}
16
+        }
17 17
 		
18
-		protected function setUp()
19
-		{
20
-		}
18
+        protected function setUp()
19
+        {
20
+        }
21 21
 
22
-		protected function tearDown()
23
-		{
24
-		}
22
+        protected function tearDown()
23
+        {
24
+        }
25 25
 		
26
-		public function testNotYet()
27
-		{
28
-			$this->markTestSkipped();
29
-		}
26
+        public function testNotYet()
27
+        {
28
+            $this->markTestSkipped();
29
+        }
30 30
 
31
-	}
32 31
\ No newline at end of file
32
+    }
33 33
\ No newline at end of file
Please login to merge, or discard this patch.
tests/tnhfw/classes/cache/FileCacheTest.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -1,31 +1,31 @@
 block discarded – undo
1 1
 <?php 
2 2
 
3
-	use PHPUnit\Framework\TestCase;
3
+    use PHPUnit\Framework\TestCase;
4 4
 
5
-	class FileCacheTest extends TestCase
6
-	{	
5
+    class FileCacheTest extends TestCase
6
+    {	
7 7
 	
8
-		public static function setUpBeforeClass()
9
-		{
8
+        public static function setUpBeforeClass()
9
+        {
10 10
 		
11
-		}
11
+        }
12 12
 		
13
-		public static function tearDownAfterClass()
14
-		{
13
+        public static function tearDownAfterClass()
14
+        {
15 15
 			
16
-		}
16
+        }
17 17
 		
18
-		protected function setUp()
19
-		{
20
-		}
18
+        protected function setUp()
19
+        {
20
+        }
21 21
 
22
-		protected function tearDown()
23
-		{
24
-		}
22
+        protected function tearDown()
23
+        {
24
+        }
25 25
 		
26
-		public function testNotYet()
27
-		{
28
-			$this->markTestSkipped();
29
-		}
26
+        public function testNotYet()
27
+        {
28
+            $this->markTestSkipped();
29
+        }
30 30
 
31
-	}
32 31
\ No newline at end of file
32
+    }
33 33
\ No newline at end of file
Please login to merge, or discard this patch.
tests/tnhfw/classes/cache/ApcCacheTest.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -1,31 +1,31 @@
 block discarded – undo
1 1
 <?php 
2 2
 
3
-	use PHPUnit\Framework\TestCase;
3
+    use PHPUnit\Framework\TestCase;
4 4
 
5
-	class ApcCacheTest extends TestCase
6
-	{	
5
+    class ApcCacheTest extends TestCase
6
+    {	
7 7
 	
8
-		public static function setUpBeforeClass()
9
-		{
8
+        public static function setUpBeforeClass()
9
+        {
10 10
 		
11
-		}
11
+        }
12 12
 		
13
-		public static function tearDownAfterClass()
14
-		{
13
+        public static function tearDownAfterClass()
14
+        {
15 15
 			
16
-		}
16
+        }
17 17
 		
18
-		protected function setUp()
19
-		{
20
-		}
18
+        protected function setUp()
19
+        {
20
+        }
21 21
 
22
-		protected function tearDown()
23
-		{
24
-		}
22
+        protected function tearDown()
23
+        {
24
+        }
25 25
 		
26
-		public function testNotYet()
27
-		{
28
-			$this->markTestSkipped();
29
-		}
26
+        public function testNotYet()
27
+        {
28
+            $this->markTestSkipped();
29
+        }
30 30
 
31
-	}
32 31
\ No newline at end of file
32
+    }
33 33
\ No newline at end of file
Please login to merge, or discard this patch.
tests/tnhfw/classes/ControllerTest.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -1,31 +1,31 @@
 block discarded – undo
1 1
 <?php 
2 2
 
3
-	use PHPUnit\Framework\TestCase;
3
+    use PHPUnit\Framework\TestCase;
4 4
 
5
-	class ControllerTest extends TestCase
6
-	{	
5
+    class ControllerTest extends TestCase
6
+    {	
7 7
 	
8
-		public static function setUpBeforeClass()
9
-		{
8
+        public static function setUpBeforeClass()
9
+        {
10 10
 		
11
-		}
11
+        }
12 12
 		
13
-		public static function tearDownAfterClass()
14
-		{
13
+        public static function tearDownAfterClass()
14
+        {
15 15
 			
16
-		}
16
+        }
17 17
 		
18
-		protected function setUp()
19
-		{
20
-		}
18
+        protected function setUp()
19
+        {
20
+        }
21 21
 
22
-		protected function tearDown()
23
-		{
24
-		}
22
+        protected function tearDown()
23
+        {
24
+        }
25 25
 		
26
-		public function testNotYet()
27
-		{
28
-			$this->markTestSkipped();
29
-		}
26
+        public function testNotYet()
27
+        {
28
+            $this->markTestSkipped();
29
+        }
30 30
 
31
-	}
32 31
\ No newline at end of file
32
+    }
33 33
\ No newline at end of file
Please login to merge, or discard this patch.
tests/tnhfw/classes/DBSessionHandlerTest.php 1 patch
Indentation   +204 added lines, -204 removed lines patch added patch discarded remove patch
@@ -1,226 +1,226 @@
 block discarded – undo
1 1
 <?php 
2 2
 
3
-	use PHPUnit\Framework\TestCase;
3
+    use PHPUnit\Framework\TestCase;
4 4
 
5
-	class DBSessionHandlerTest extends TestCase
6
-	{	
5
+    class DBSessionHandlerTest extends TestCase
6
+    {	
7 7
 	
8
-		private $db = null;
8
+        private $db = null;
9 9
 		
10
-		private $model = null;
10
+        private $model = null;
11 11
 		
12
-		private $secret = 'bXlzZWNyZXQ';
12
+        private $secret = 'bXlzZWNyZXQ';
13 13
 		
14
-		private static $config = null;
14
+        private static $config = null;
15 15
 		
16
-		public function __construct(){
17
-			$this->db = new Database(array(
18
-								'driver'    =>  'sqlite',
19
-								'database'  =>  TESTS_PATH . 'assets/db_tests.db',
20
-								'charset'   => 'utf8',
21
-								'collation' => 'utf8_general_ci',
22
-							));
16
+        public function __construct(){
17
+            $this->db = new Database(array(
18
+                                'driver'    =>  'sqlite',
19
+                                'database'  =>  TESTS_PATH . 'assets/db_tests.db',
20
+                                'charset'   => 'utf8',
21
+                                'collation' => 'utf8_general_ci',
22
+                            ));
23 23
             $qr = new DatabaseQueryRunner($this->db->getPdo());
24 24
             $qr->setBenchmark(new Benchmark());
25 25
             $qr->setDriver('sqlite');
26 26
             $this->db->setQueryRunner($qr);
27
-		}
27
+        }
28 28
 		
29
-		public static function setUpBeforeClass()
30
-		{
31
-			require APPS_MODEL_PATH . 'DBSessionModel.php';
32
-			self::$config = new Config();
33
-			self::$config->init();
34
-		}
29
+        public static function setUpBeforeClass()
30
+        {
31
+            require APPS_MODEL_PATH . 'DBSessionModel.php';
32
+            self::$config = new Config();
33
+            self::$config->init();
34
+        }
35 35
 		
36 36
 		
37
-		public static function tearDownAfterClass()
38
-		{
37
+        public static function tearDownAfterClass()
38
+        {
39 39
 			
40
-		}
40
+        }
41 41
 		
42
-		protected function setUp()
43
-		{
44
-			$this->model = new DBSessionModel($this->db);
42
+        protected function setUp()
43
+        {
44
+            $this->model = new DBSessionModel($this->db);
45 45
             //to prevent old data conflict
46
-			$this->model->truncate();
47
-		}
46
+            $this->model->truncate();
47
+        }
48 48
 
49
-		protected function tearDown()
50
-		{
51
-		}
49
+        protected function tearDown()
50
+        {
51
+        }
52 52
 
53 53
 		
54 54
 		
55
-		public function testUsingSessionConfiguration(){
56
-			//using value in the configuration
57
-			self::$config->set('session_save_path', 'DBSessionModel');
58
-			self::$config->set('session_secret', $this->secret);
59
-			$dbsh = new DBSessionHandler();
60
-			//assign Database instance manually
61
-			$o = &get_instance();
62
-			$o->database = $this->db;
63
-			
64
-			$this->assertTrue($dbsh->open(null, null));
65
-			$this->assertTrue($dbsh->close());
66
-			$this->assertNull($dbsh->read('foo'));
67
-			$this->assertTrue($dbsh->write('foo', '444'));
68
-			$this->assertNotEmpty($dbsh->read('foo'));
69
-			$this->assertEquals($dbsh->read('foo'), '444');
70
-			//do update of existing data
71
-			$this->assertTrue($dbsh->write('foo', '445'));
72
-			$this->assertEquals($dbsh->read('foo'), '445');	
73
-			$this->assertTrue($dbsh->destroy('foo'));
74
-			$this->assertNull($dbsh->read('foo'));
75
-			$this->assertTrue($dbsh->gc(13));
76
-			$encoded = $dbsh->encode('foo');
77
-			$this->assertNotEmpty($encoded);
78
-			$this->assertEquals($dbsh->decode($encoded), 'foo');
79
-		}
80
-		
81
-		public function testWhenDataIsExpired(){
82
-			$dbsh = new DBSessionHandler($this->model);
83
-			$dbsh->setSessionSecret($this->secret);
84
-			
85
-			$this->assertTrue($dbsh->open(null, null));
86
-			$this->assertTrue($dbsh->write('foo', '444'));
87
-			$this->assertNotEmpty($dbsh->read('foo'));
88
-			$this->assertEquals($dbsh->read('foo'), '444');
89
-			//put it in expired
90
-			$this->model->update('foo', array('s_time' => 1234567));
91
-			$this->assertNull($dbsh->read('foo'));
92
-		}
93
-		
94
-		public function testWhenDataAlreadyExistDoUpdate(){
95
-			$dbsh = new DBSessionHandler($this->model);
96
-			$dbsh->setSessionSecret($this->secret);
97
-			
98
-			$this->assertTrue($dbsh->open(null, null));
99
-			$this->assertTrue($dbsh->write('foo', '444'));
100
-			$this->assertNotEmpty($dbsh->read('foo'));
101
-			$this->assertEquals($dbsh->read('foo'), '444');
102
-			//do update of existing data
103
-			$this->assertTrue($dbsh->write('foo', '445'));
104
-			$this->assertEquals($dbsh->read('foo'), '445');	
105
-		}
106
-		
107
-		public function testUsingCustomModelInstance(){
108
-			$dbsh = new DBSessionHandler($this->model);
109
-			$dbsh->setSessionSecret($this->secret);
110
-			
111
-			$this->assertTrue($dbsh->open(null, null));
112
-			$this->assertTrue($dbsh->close());
113
-			$this->assertNull($dbsh->read('foo'));
114
-			$this->assertTrue($dbsh->write('foo', '444'));
115
-			$this->assertNotEmpty($dbsh->read('foo'));
116
-			$this->assertEquals($dbsh->read('foo'), '444');
117
-			//put it in expired
118
-			$this->model->update('foo', array('s_time' => 1234567));
119
-			
120
-			$this->assertNull($dbsh->read('foo'));
121
-			$this->assertTrue($dbsh->write('foo', '444'));
122
-			
123
-			//do update of existing data
124
-			$this->assertTrue($dbsh->write('foo', '445'));
125
-			$this->assertEquals($dbsh->read('foo'), '445');	
126
-			$this->assertTrue($dbsh->destroy('foo'));
127
-			$this->assertNull($dbsh->read('foo'));
128
-			$this->assertTrue($dbsh->gc(13));
129
-			$encoded = $dbsh->encode('foo');
130
-			$this->assertNotEmpty($encoded);
131
-			$this->assertEquals($dbsh->decode($encoded), 'foo');
132
-		}
133
-			
134
-			
135
-		public function testUsingCustomLogInstance(){
136
-			$dbsh = new DBSessionHandler($this->model, new Log());
137
-			$dbsh->setSessionSecret($this->secret);
138
-			
139
-			$this->assertTrue($dbsh->open(null, null));
140
-			$this->assertTrue($dbsh->close());
141
-			$this->assertNull($dbsh->read('foo'));
142
-			$this->assertTrue($dbsh->write('foo', '444'));
143
-			$this->assertNotEmpty($dbsh->read('foo'));
144
-			$this->assertEquals($dbsh->read('foo'), '444');
145
-			//put it in expired
146
-			$this->model->update('foo', array('s_time' => 1234567));
147
-			
148
-			$this->assertNull($dbsh->read('foo'));
149
-			$this->assertTrue($dbsh->write('foo', '444'));
150
-			
151
-			//do update of existing data
152
-			$this->assertTrue($dbsh->write('foo', '445'));
153
-			$this->assertEquals($dbsh->read('foo'), '445');	
154
-			$this->assertTrue($dbsh->destroy('foo'));
155
-			$this->assertNull($dbsh->read('foo'));
156
-			$this->assertTrue($dbsh->gc(13));
157
-			$encoded = $dbsh->encode('foo');
158
-			$this->assertNotEmpty($encoded);
159
-			$this->assertEquals($dbsh->decode($encoded), 'foo');
160
-		}
161
-		
162
-		public function testUsingCustomLoaderInstance(){
163
-			$dbsh = new DBSessionHandler($this->model, null, new Loader());
164
-			$dbsh->setSessionSecret($this->secret);
165
-			
166
-			$this->assertTrue($dbsh->open(null, null));
167
-			$this->assertTrue($dbsh->close());
168
-			$this->assertNull($dbsh->read('foo'));
169
-			$this->assertTrue($dbsh->write('foo', '444'));
170
-			$this->assertNotEmpty($dbsh->read('foo'));
171
-			$this->assertEquals($dbsh->read('foo'), '444');
172
-			//put it in expired
173
-			$this->model->update('foo', array('s_time' => 1234567));
174
-			
175
-			$this->assertNull($dbsh->read('foo'));
176
-			$this->assertTrue($dbsh->write('foo', '444'));
177
-			
178
-			//do update of existing data
179
-			$this->assertTrue($dbsh->write('foo', '445'));
180
-			$this->assertEquals($dbsh->read('foo'), '445');	
181
-			$this->assertTrue($dbsh->destroy('foo'));
182
-			$this->assertNull($dbsh->read('foo'));
183
-			$this->assertTrue($dbsh->gc(13));
184
-			$encoded = $dbsh->encode('foo');
185
-			$this->assertNotEmpty($encoded);
186
-			$this->assertEquals($dbsh->decode($encoded), 'foo');
187
-		}
188
-		
189
-		
190
-		public function testWhenModelInsanceIsNotSet(){
191
-			$dbsh = new DBSessionHandler(null, null, new Loader());
192
-			$dbsh->setSessionSecret($this->secret);
193
-			
194
-			$this->assertTrue($dbsh->open(null, null));
195
-			$this->assertTrue($dbsh->close());
196
-			$this->assertNull($dbsh->read('foo'));
197
-			$this->assertTrue($dbsh->write('foo', '444'));
198
-			$this->assertNotEmpty($dbsh->read('foo'));
199
-			$this->assertEquals($dbsh->read('foo'), '444');
200
-			//put it in expired
201
-			$this->model->update('foo', array('s_time' => 1234567));
202
-			
203
-			$this->assertNull($dbsh->read('foo'));
204
-			$this->assertTrue($dbsh->write('foo', '444'));
205
-			
206
-			//do update of existing data
207
-			$this->assertTrue($dbsh->write('tnh', '445'));
208
-			$this->assertTrue($dbsh->write('foo', '445'));
209
-			$this->assertEquals($dbsh->read('foo'), '445');	
210
-			$this->assertTrue($dbsh->destroy('foo'));
211
-			$this->assertNull($dbsh->read('foo'));
212
-			$this->assertTrue($dbsh->gc(13));
213
-			$encoded = $dbsh->encode('foo');
214
-			$this->assertNotEmpty($encoded);
215
-			$this->assertEquals($dbsh->decode($encoded), 'foo');
216
-		}
217
-		
218
-		public function testWhenModelTableColumnsIsNotSet(){
219
-			//session table is empty
220
-			$this->model->setSessionTableColumns(array());
221
-			$dbsh = new DBSessionHandler($this->model);
222
-			$this->assertTrue($dbsh->open(null, null));
223
-		}
224
-		
225
-		
226
-	}
227 55
\ No newline at end of file
56
+        public function testUsingSessionConfiguration(){
57
+            //using value in the configuration
58
+            self::$config->set('session_save_path', 'DBSessionModel');
59
+            self::$config->set('session_secret', $this->secret);
60
+            $dbsh = new DBSessionHandler();
61
+            //assign Database instance manually
62
+            $o = &get_instance();
63
+            $o->database = $this->db;
64
+			
65
+            $this->assertTrue($dbsh->open(null, null));
66
+            $this->assertTrue($dbsh->close());
67
+            $this->assertNull($dbsh->read('foo'));
68
+            $this->assertTrue($dbsh->write('foo', '444'));
69
+            $this->assertNotEmpty($dbsh->read('foo'));
70
+            $this->assertEquals($dbsh->read('foo'), '444');
71
+            //do update of existing data
72
+            $this->assertTrue($dbsh->write('foo', '445'));
73
+            $this->assertEquals($dbsh->read('foo'), '445');	
74
+            $this->assertTrue($dbsh->destroy('foo'));
75
+            $this->assertNull($dbsh->read('foo'));
76
+            $this->assertTrue($dbsh->gc(13));
77
+            $encoded = $dbsh->encode('foo');
78
+            $this->assertNotEmpty($encoded);
79
+            $this->assertEquals($dbsh->decode($encoded), 'foo');
80
+        }
81
+		
82
+        public function testWhenDataIsExpired(){
83
+            $dbsh = new DBSessionHandler($this->model);
84
+            $dbsh->setSessionSecret($this->secret);
85
+			
86
+            $this->assertTrue($dbsh->open(null, null));
87
+            $this->assertTrue($dbsh->write('foo', '444'));
88
+            $this->assertNotEmpty($dbsh->read('foo'));
89
+            $this->assertEquals($dbsh->read('foo'), '444');
90
+            //put it in expired
91
+            $this->model->update('foo', array('s_time' => 1234567));
92
+            $this->assertNull($dbsh->read('foo'));
93
+        }
94
+		
95
+        public function testWhenDataAlreadyExistDoUpdate(){
96
+            $dbsh = new DBSessionHandler($this->model);
97
+            $dbsh->setSessionSecret($this->secret);
98
+			
99
+            $this->assertTrue($dbsh->open(null, null));
100
+            $this->assertTrue($dbsh->write('foo', '444'));
101
+            $this->assertNotEmpty($dbsh->read('foo'));
102
+            $this->assertEquals($dbsh->read('foo'), '444');
103
+            //do update of existing data
104
+            $this->assertTrue($dbsh->write('foo', '445'));
105
+            $this->assertEquals($dbsh->read('foo'), '445');	
106
+        }
107
+		
108
+        public function testUsingCustomModelInstance(){
109
+            $dbsh = new DBSessionHandler($this->model);
110
+            $dbsh->setSessionSecret($this->secret);
111
+			
112
+            $this->assertTrue($dbsh->open(null, null));
113
+            $this->assertTrue($dbsh->close());
114
+            $this->assertNull($dbsh->read('foo'));
115
+            $this->assertTrue($dbsh->write('foo', '444'));
116
+            $this->assertNotEmpty($dbsh->read('foo'));
117
+            $this->assertEquals($dbsh->read('foo'), '444');
118
+            //put it in expired
119
+            $this->model->update('foo', array('s_time' => 1234567));
120
+			
121
+            $this->assertNull($dbsh->read('foo'));
122
+            $this->assertTrue($dbsh->write('foo', '444'));
123
+			
124
+            //do update of existing data
125
+            $this->assertTrue($dbsh->write('foo', '445'));
126
+            $this->assertEquals($dbsh->read('foo'), '445');	
127
+            $this->assertTrue($dbsh->destroy('foo'));
128
+            $this->assertNull($dbsh->read('foo'));
129
+            $this->assertTrue($dbsh->gc(13));
130
+            $encoded = $dbsh->encode('foo');
131
+            $this->assertNotEmpty($encoded);
132
+            $this->assertEquals($dbsh->decode($encoded), 'foo');
133
+        }
134
+			
135
+			
136
+        public function testUsingCustomLogInstance(){
137
+            $dbsh = new DBSessionHandler($this->model, new Log());
138
+            $dbsh->setSessionSecret($this->secret);
139
+			
140
+            $this->assertTrue($dbsh->open(null, null));
141
+            $this->assertTrue($dbsh->close());
142
+            $this->assertNull($dbsh->read('foo'));
143
+            $this->assertTrue($dbsh->write('foo', '444'));
144
+            $this->assertNotEmpty($dbsh->read('foo'));
145
+            $this->assertEquals($dbsh->read('foo'), '444');
146
+            //put it in expired
147
+            $this->model->update('foo', array('s_time' => 1234567));
148
+			
149
+            $this->assertNull($dbsh->read('foo'));
150
+            $this->assertTrue($dbsh->write('foo', '444'));
151
+			
152
+            //do update of existing data
153
+            $this->assertTrue($dbsh->write('foo', '445'));
154
+            $this->assertEquals($dbsh->read('foo'), '445');	
155
+            $this->assertTrue($dbsh->destroy('foo'));
156
+            $this->assertNull($dbsh->read('foo'));
157
+            $this->assertTrue($dbsh->gc(13));
158
+            $encoded = $dbsh->encode('foo');
159
+            $this->assertNotEmpty($encoded);
160
+            $this->assertEquals($dbsh->decode($encoded), 'foo');
161
+        }
162
+		
163
+        public function testUsingCustomLoaderInstance(){
164
+            $dbsh = new DBSessionHandler($this->model, null, new Loader());
165
+            $dbsh->setSessionSecret($this->secret);
166
+			
167
+            $this->assertTrue($dbsh->open(null, null));
168
+            $this->assertTrue($dbsh->close());
169
+            $this->assertNull($dbsh->read('foo'));
170
+            $this->assertTrue($dbsh->write('foo', '444'));
171
+            $this->assertNotEmpty($dbsh->read('foo'));
172
+            $this->assertEquals($dbsh->read('foo'), '444');
173
+            //put it in expired
174
+            $this->model->update('foo', array('s_time' => 1234567));
175
+			
176
+            $this->assertNull($dbsh->read('foo'));
177
+            $this->assertTrue($dbsh->write('foo', '444'));
178
+			
179
+            //do update of existing data
180
+            $this->assertTrue($dbsh->write('foo', '445'));
181
+            $this->assertEquals($dbsh->read('foo'), '445');	
182
+            $this->assertTrue($dbsh->destroy('foo'));
183
+            $this->assertNull($dbsh->read('foo'));
184
+            $this->assertTrue($dbsh->gc(13));
185
+            $encoded = $dbsh->encode('foo');
186
+            $this->assertNotEmpty($encoded);
187
+            $this->assertEquals($dbsh->decode($encoded), 'foo');
188
+        }
189
+		
190
+		
191
+        public function testWhenModelInsanceIsNotSet(){
192
+            $dbsh = new DBSessionHandler(null, null, new Loader());
193
+            $dbsh->setSessionSecret($this->secret);
194
+			
195
+            $this->assertTrue($dbsh->open(null, null));
196
+            $this->assertTrue($dbsh->close());
197
+            $this->assertNull($dbsh->read('foo'));
198
+            $this->assertTrue($dbsh->write('foo', '444'));
199
+            $this->assertNotEmpty($dbsh->read('foo'));
200
+            $this->assertEquals($dbsh->read('foo'), '444');
201
+            //put it in expired
202
+            $this->model->update('foo', array('s_time' => 1234567));
203
+			
204
+            $this->assertNull($dbsh->read('foo'));
205
+            $this->assertTrue($dbsh->write('foo', '444'));
206
+			
207
+            //do update of existing data
208
+            $this->assertTrue($dbsh->write('tnh', '445'));
209
+            $this->assertTrue($dbsh->write('foo', '445'));
210
+            $this->assertEquals($dbsh->read('foo'), '445');	
211
+            $this->assertTrue($dbsh->destroy('foo'));
212
+            $this->assertNull($dbsh->read('foo'));
213
+            $this->assertTrue($dbsh->gc(13));
214
+            $encoded = $dbsh->encode('foo');
215
+            $this->assertNotEmpty($encoded);
216
+            $this->assertEquals($dbsh->decode($encoded), 'foo');
217
+        }
218
+		
219
+        public function testWhenModelTableColumnsIsNotSet(){
220
+            //session table is empty
221
+            $this->model->setSessionTableColumns(array());
222
+            $dbsh = new DBSessionHandler($this->model);
223
+            $this->assertTrue($dbsh->open(null, null));
224
+        }
225
+		
226
+		
227
+    }
228 228
\ No newline at end of file
Please login to merge, or discard this patch.
tests/tnhfw/classes/ResponseTest.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -1,31 +1,31 @@
 block discarded – undo
1 1
 <?php 
2 2
 
3
-	use PHPUnit\Framework\TestCase;
3
+    use PHPUnit\Framework\TestCase;
4 4
 
5
-	class ResponseTest extends TestCase
6
-	{	
5
+    class ResponseTest extends TestCase
6
+    {	
7 7
 	
8
-		public static function setUpBeforeClass()
9
-		{
8
+        public static function setUpBeforeClass()
9
+        {
10 10
 		
11
-		}
11
+        }
12 12
 		
13
-		public static function tearDownAfterClass()
14
-		{
13
+        public static function tearDownAfterClass()
14
+        {
15 15
 			
16
-		}
16
+        }
17 17
 		
18
-		protected function setUp()
19
-		{
20
-		}
18
+        protected function setUp()
19
+        {
20
+        }
21 21
 
22
-		protected function tearDown()
23
-		{
24
-		}
22
+        protected function tearDown()
23
+        {
24
+        }
25 25
 		
26
-		public function testNotYet()
27
-		{
28
-			$this->markTestSkipped();
29
-		}
26
+        public function testNotYet()
27
+        {
28
+            $this->markTestSkipped();
29
+        }
30 30
 
31
-	}
32 31
\ No newline at end of file
32
+    }
33 33
\ No newline at end of file
Please login to merge, or discard this patch.