1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* This file is part of the PommProject/Foundation package. |
4
|
|
|
* |
5
|
|
|
* (c) 2014 - 2017 Grégoire HUBERT <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
namespace PommProject\Foundation\Tester; |
11
|
|
|
|
12
|
|
|
use PommProject\Foundation\Session\Session; |
13
|
|
|
use PommProject\Foundation\Session\SessionBuilder; |
14
|
|
|
use Atoum; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* VanillaSessionAtoum |
18
|
|
|
* |
19
|
|
|
* This is a Session aware Atoum class. It uses the vanilla session builder |
20
|
|
|
* hence produce session with no poolers nor clients. |
21
|
|
|
* It is intended to be overloaded by each package to add their own poolers. |
22
|
|
|
* |
23
|
|
|
* @package Foundation |
24
|
|
|
* @copyright 2014 - 2017 Grégoire HUBERT |
25
|
|
|
* @author Grégoire HUBERT |
26
|
|
|
* @license X11 {@link http://opensource.org/licenses/mit-license.php} |
27
|
|
|
* @see Atoum |
28
|
|
|
*/ |
29
|
|
|
abstract class VanillaSessionAtoum extends Atoum |
30
|
|
|
{ |
31
|
|
|
private $session_builder; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* buildSession |
35
|
|
|
* |
36
|
|
|
* A short description here |
37
|
|
|
* |
38
|
|
|
* @param string $stamp |
39
|
|
|
* @return Session |
40
|
|
|
*/ |
41
|
|
|
protected function buildSession($stamp = null) |
42
|
|
|
{ |
43
|
|
|
$session = $this->getSessionBuilder()->buildSession($stamp); |
44
|
|
|
$this->initializeSession($session); |
45
|
|
|
|
46
|
|
|
return $session; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* getSessionBuilder |
51
|
|
|
* |
52
|
|
|
* Return a SessionBuilder. |
53
|
|
|
* |
54
|
|
|
* @return SessionBuilder |
55
|
|
|
*/ |
56
|
|
|
private function getSessionBuilder() |
57
|
|
|
{ |
58
|
|
|
if ($this->session_builder === null) { |
59
|
|
|
$this->session_builder = $this->createSessionBuilder($GLOBALS['pomm_db1']); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
return $this->session_builder; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* createSessionBuilder |
67
|
|
|
* |
68
|
|
|
* Instantiate a new SessionBuilder. This method is to be overloaded by |
69
|
|
|
* each package to instantiate their own SessionBuilder if any. |
70
|
|
|
* |
71
|
|
|
* @param array $configuration |
72
|
|
|
* @return SessionBuilder |
73
|
|
|
*/ |
74
|
|
|
protected function createSessionBuilder(array $configuration) |
75
|
|
|
{ |
76
|
|
|
return new SessionBuilder($configuration); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* initializeSession |
81
|
|
|
* |
82
|
|
|
* If the test needs special poolers and/or client configuration, it goes |
83
|
|
|
* here. |
84
|
|
|
* |
85
|
|
|
* @param Session $session |
86
|
|
|
* @return null |
87
|
|
|
*/ |
88
|
|
|
abstract protected function initializeSession(Session $session); |
89
|
|
|
} |
90
|
|
|
|