|
3 | 3 | namespace FOS\HttpCacheBundle\Tests\Functional\Fixtures\Session;
|
4 | 4 |
|
5 | 5 | use Symfony\Component\HttpFoundation\Session\SessionBagInterface;
|
6 |
| -use Symfony\Component\HttpFoundation\Session\Storage\MetadataBag; |
7 | 6 | use Symfony\Component\HttpFoundation\Session\Storage\SessionStorageInterface;
|
8 | 7 | use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
|
9 | 8 |
|
| 9 | +/** |
| 10 | + * {@inheritdoc} |
| 11 | + */ |
10 | 12 | class TestSessionStorage implements SessionStorageInterface
|
11 | 13 | {
|
12 | 14 | private $started = false;
|
13 | 15 |
|
14 | 16 | private $bags = array();
|
15 | 17 |
|
16 | 18 | /**
|
17 |
| - * Starts the session. |
18 |
| - * |
19 |
| - * @throws \RuntimeException If something goes wrong starting the session. |
20 |
| - * |
21 |
| - * @return bool True if started. |
22 |
| - * |
23 |
| - * @api |
| 19 | + * {@inheritdoc} |
24 | 20 | */
|
25 | 21 | public function start()
|
26 | 22 | {
|
27 |
| - $this->started = true; |
| 23 | + return $this->started = true; |
28 | 24 | }
|
29 | 25 |
|
30 | 26 | /**
|
31 |
| - * Checks if the session is started. |
32 |
| - * |
33 |
| - * @return bool True if started, false otherwise. |
| 27 | + * {@inheritdoc} |
34 | 28 | */
|
35 | 29 | public function isStarted()
|
36 | 30 | {
|
37 | 31 | return $this->started;
|
38 | 32 | }
|
39 | 33 |
|
40 | 34 | /**
|
41 |
| - * Returns the session ID |
42 |
| - * |
43 |
| - * @return string The session ID or empty. |
44 |
| - * |
45 |
| - * @api |
| 35 | + * {@inheritdoc} |
46 | 36 | */
|
47 | 37 | public function getId()
|
48 | 38 | {
|
49 | 39 | return 'test';
|
50 | 40 | }
|
51 | 41 |
|
52 | 42 | /**
|
53 |
| - * Sets the session ID |
54 |
| - * |
55 |
| - * @param string $id |
56 |
| - * |
57 |
| - * @api |
| 43 | + * {@inheritdoc} |
58 | 44 | */
|
59 | 45 | public function setId($id)
|
60 | 46 | {
|
61 | 47 | }
|
62 | 48 |
|
63 | 49 | /**
|
64 |
| - * Returns the session name |
65 |
| - * |
66 |
| - * @return mixed The session name. |
67 |
| - * |
68 |
| - * @api |
| 50 | + * {@inheritdoc} |
69 | 51 | */
|
70 | 52 | public function getName()
|
71 | 53 | {
|
72 | 54 | return 'TESTSESSID';
|
73 | 55 | }
|
74 | 56 |
|
75 | 57 | /**
|
76 |
| - * Sets the session name |
77 |
| - * |
78 |
| - * @param string $name |
79 |
| - * |
80 |
| - * @api |
| 58 | + * {@inheritdoc} |
81 | 59 | */
|
| 60 | + |
82 | 61 | public function setName($name)
|
83 | 62 | {
|
84 | 63 | }
|
85 | 64 |
|
86 | 65 | /**
|
87 |
| - * Regenerates id that represents this storage. |
88 |
| - * |
89 |
| - * This method must invoke session_regenerate_id($destroy) unless |
90 |
| - * this interface is used for a storage object designed for unit |
91 |
| - * or functional testing where a real PHP session would interfere |
92 |
| - * with testing. |
93 |
| - * |
94 |
| - * Note regenerate+destroy should not clear the session data in memory |
95 |
| - * only delete the session data from persistent storage. |
96 |
| - * |
97 |
| - * @param bool $destroy Destroy session when regenerating? |
98 |
| - * @param int $lifetime Sets the cookie lifetime for the session cookie. A null value |
99 |
| - * will leave the system settings unchanged, 0 sets the cookie |
100 |
| - * to expire with browser session. Time is in seconds, and is |
101 |
| - * not a Unix timestamp. |
102 |
| - * |
103 |
| - * @return bool True if session regenerated, false if error |
104 |
| - * |
105 |
| - * @throws \RuntimeException If an error occurs while regenerating this storage |
106 |
| - * |
107 |
| - * @api |
| 66 | + * {@inheritdoc} |
108 | 67 | */
|
109 | 68 | public function regenerate($destroy = false, $lifetime = null)
|
110 | 69 | {
|
111 | 70 | return true;
|
112 | 71 | }
|
113 | 72 |
|
114 | 73 | /**
|
115 |
| - * Force the session to be saved and closed. |
116 |
| - * |
117 |
| - * This method must invoke session_write_close() unless this interface is |
118 |
| - * used for a storage object design for unit or functional testing where |
119 |
| - * a real PHP session would interfere with testing, in which case it |
120 |
| - * it should actually persist the session data if required. |
121 |
| - * |
122 |
| - * @throws \RuntimeException If the session is saved without being started, or if the session |
123 |
| - * is already closed. |
| 74 | + * {@inheritdoc} |
124 | 75 | */
|
125 | 76 | public function save()
|
126 | 77 | {
|
127 | 78 | }
|
128 | 79 |
|
129 | 80 | /**
|
130 |
| - * Clear all session data in memory. |
| 81 | + * {@inheritdoc} |
131 | 82 | */
|
132 | 83 | public function clear()
|
133 | 84 | {
|
134 | 85 | }
|
135 | 86 |
|
136 | 87 | /**
|
137 |
| - * Gets a SessionBagInterface by name. |
138 |
| - * |
139 |
| - * @param string $name |
140 |
| - * |
141 |
| - * @return SessionBagInterface |
142 |
| - * |
143 |
| - * @throws \InvalidArgumentException If the bag does not exist |
| 88 | + * {@inheritdoc} |
144 | 89 | */
|
145 | 90 | public function getBag($name)
|
146 | 91 | {
|
147 | 92 | return $this->bags[$name];
|
148 | 93 | }
|
149 | 94 |
|
150 | 95 | /**
|
151 |
| - * Registers a SessionBagInterface for use. |
152 |
| - * |
153 |
| - * @param SessionBagInterface $bag |
| 96 | + * {@inheritdoc} |
154 | 97 | */
|
155 | 98 | public function registerBag(SessionBagInterface $bag)
|
156 | 99 | {
|
157 |
| - if ($bag->getName() == "attributes") { |
| 100 | + if ($bag->getName() == 'attributes') { |
158 | 101 | $bag->set('_security_secured_area', serialize(new UsernamePasswordToken('user', 'user', 'in_memory', array('ROLE_USER'))));
|
159 | 102 | }
|
160 | 103 |
|
161 | 104 | $this->bags[$bag->getName()] = $bag;
|
162 | 105 | }
|
163 | 106 |
|
164 | 107 | /**
|
165 |
| - * @return MetadataBag |
| 108 | + * {@inheritdoc} |
166 | 109 | */
|
167 | 110 | public function getMetadataBag()
|
168 | 111 | {
|
|
0 commit comments