Open Monograph Press  3.3.0
NativeFileSessionHandlerTest.php
1 <?php
2 
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11 
13 
14 use PHPUnit\Framework\TestCase;
17 
26 class NativeFileSessionHandlerTest extends TestCase
27 {
28  public function testConstruct()
29  {
30  $storage = new NativeSessionStorage(array('name' => 'TESTING'), new NativeFileSessionHandler(sys_get_temp_dir()));
31 
32  $this->assertEquals('files', $storage->getSaveHandler()->getSaveHandlerName());
33  $this->assertEquals('user', ini_get('session.save_handler'));
34 
35  $this->assertEquals(sys_get_temp_dir(), ini_get('session.save_path'));
36  $this->assertEquals('TESTING', ini_get('session.name'));
37  }
38 
42  public function testConstructSavePath($savePath, $expectedSavePath, $path)
43  {
44  $handler = new NativeFileSessionHandler($savePath);
45  $this->assertEquals($expectedSavePath, ini_get('session.save_path'));
46  $this->assertTrue(is_dir(realpath($path)));
47 
48  rmdir($path);
49  }
50 
51  public function savePathDataProvider()
52  {
53  $base = sys_get_temp_dir();
54 
55  return array(
56  array("$base/foo", "$base/foo", "$base/foo"),
57  array("5;$base/foo", "5;$base/foo", "$base/foo"),
58  array("5;0600;$base/foo", "5;0600;$base/foo", "$base/foo"),
59  );
60  }
61 
65  public function testConstructException()
66  {
67  $handler = new NativeFileSessionHandler('something;invalid;with;too-many-args');
68  }
69 
70  public function testConstructDefault()
71  {
72  $path = ini_get('session.save_path');
73  $storage = new NativeSessionStorage(array('name' => 'TESTING'), new NativeFileSessionHandler());
74 
75  $this->assertEquals($path, ini_get('session.save_path'));
76  }
77 }
Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler\NativeFileSessionHandlerTest
Definition: NativeFileSessionHandlerTest.php:26
Symfony\Component\HttpFoundation\Session\Session\$storage
$storage
Definition: lib/vendor/symfony/http-foundation/Session/Session.php:37
Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage
Definition: lib/vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php:25
Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler\NativeFileSessionHandlerTest\savePathDataProvider
savePathDataProvider()
Definition: NativeFileSessionHandlerTest.php:51
Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler\NativeFileSessionHandlerTest\testConstructException
testConstructException()
Definition: NativeFileSessionHandlerTest.php:65
Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler\NativeFileSessionHandlerTest\testConstruct
testConstruct()
Definition: NativeFileSessionHandlerTest.php:28
Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler\NativeFileSessionHandlerTest\testConstructSavePath
testConstructSavePath($savePath, $expectedSavePath, $path)
Definition: NativeFileSessionHandlerTest.php:42
Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler
Definition: MemcachedSessionHandlerTest.php:12
Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler\NativeFileSessionHandlerTest\testConstructDefault
testConstructDefault()
Definition: NativeFileSessionHandlerTest.php:70
Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler
Definition: lib/vendor/symfony/http-foundation/Session/Storage/Handler/NativeFileSessionHandler.php:21