Completed
Push — 2.0 ( 143803...4e64fa )
by grégoire
08:42 queued 04:22
created

VanillaSessionAtoum::initializeSession()

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 1
nc 1
1
<?php
2
/*
3
 * This file is part of the PommProject/Foundation package.
4
 *
5
 * (c) 2014 - 2015 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 - 2015 Grégoire HUBERT
25
 * @author    Grégoire HUBERT
26
 * @license   X11 {@link http://opensource.org/licenses/mit-license.php}
27
 * @see       Atoum
28
 * @abstract
29
 */
30
abstract class VanillaSessionAtoum extends Atoum
31
{
32
    private $session_builder;
33
34
    /**
35
     * buildSession
36
     *
37
     * A short description here
38
     *
39
     * @access protected
40
     * @param  string       $stamp
41
     * @return Session
42
     */
43
    protected function buildSession($stamp = null)
44
    {
45
        $session = $this->getSessionBuilder()->buildSession($stamp);
46
        $this->initializeSession($session);
47
48
        return $session;
49
    }
50
51
    /**
52
     * getSessionBuilder
53
     *
54
     * Return a SessionBuilder.
55
     *
56
     * @access protected
57
     * @return SessionBuilder
58
     */
59
    private function getSessionBuilder()
60
    {
61
        if ($this->session_builder === null) {
62
            $this->session_builder = $this->createSessionBuilder($GLOBALS['pomm_db1']);
63
        }
64
65
        return $this->session_builder;
66
    }
67
68
    /**
69
     * createSessionBuilder
70
     *
71
     * Instantiate a new SessionBuilder. This method is to be overloaded by
72
     * each package to instantiate their own SessionBuilder if any.
73
     *
74
     * @access protected
75
     * @param  array $configuration
76
     * @return SessionBuilder
77
     */
78
    protected function createSessionBuilder(array $configuration)
79
    {
80
        return new SessionBuilder($configuration);
81
    }
82
83
    /**
84
     * initializeSession
85
     *
86
     * If the test needs special poolers and/or client configuration, it goes
87
     * here.
88
     *
89
     * @access  protected
90
     * @param   Session $session
91
     * @return  null
92
     */
93
    abstract protected function initializeSession(Session $session);
94
}
95