Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 19
0.00% covered (danger)
0.00%
0 / 14
CRAP
0.00% covered (danger)
0.00%
0 / 1
common_test_TestUserSession
0.00% covered (danger)
0.00%
0 / 19
0.00% covered (danger)
0.00%
0 / 14
210
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
2
 getUser
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getUserUri
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getUserLabel
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getUserRoles
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getUserPropertyValues
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 setDataLanguage
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getDataLanguage
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 setInterfaceLanguage
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getInterfaceLanguage
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 setTimeZone
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getTimeZone
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 refresh
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getContexts
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3use oat\generis\model\GenerisRdf;
4
5/**
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; under version 2
9 * of the License (non-upgradable).
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19 *
20 * Copyright (c) 2013 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
21 *
22 */
23
24/**
25 * @author CRP Henri Tudor - TAO Team
26 * @license GPLv2
27 *
28 */
29
30class common_test_TestUserSession implements common_session_StatelessSession
31{
32    /**
33     * Code of the current data language to use
34     *
35     * @var string
36     */
37    private $dataLanguage = DEFAULT_LANG;
38
39    private $uiLanguage = DEFAULT_LANG;
40
41    /**
42     * @var common_test_TestUser
43     */
44    private $user;
45
46    /**
47     * Code of the timezone to use during the test
48     *
49     * @var string
50     */
51    private $timezone = TIME_ZONE;
52
53    public function __construct()
54    {
55        $this->user = new common_test_TestUser([
56            GenerisRdf::PROPERTY_USER_DEFLG => [DEFAULT_LANG],
57            GenerisRdf::PROPERTY_USER_UILG => [DEFAULT_LANG]
58        ]);
59    }
60
61    public function getUser()
62    {
63        return $this->user;
64    }
65
66    /**
67     * {@inheritDoc}
68     * @see common_session_Session::getUserUri()
69     */
70    public function getUserUri()
71    {
72        return $this->getUser()->getIdentifier();
73    }
74
75    /**
76     * {@inheritDoc}
77     * @see common_session_Session::getUserLabel()
78     */
79    public function getUserLabel()
80    {
81        return 'Virtual Test User';
82    }
83
84    /**
85     * {@inheritDoc}
86     * @see common_session_Session::getUserRoles()
87     */
88    public function getUserRoles()
89    {
90        return [];
91    }
92
93    /**
94     * (non-PHPdoc)
95     * @see common_session_Session::getUserPropertyValues()
96     */
97    public function getUserPropertyValues($property)
98    {
99        return [];
100    }
101
102
103    /**
104     * changes the current data language
105     *
106     * @param string $languageCode
107     */
108    public function setDataLanguage($languageCode)
109    {
110        $this->getUser()->setPropertyValues(GenerisRdf::PROPERTY_USER_DEFLG, [$languageCode]);
111    }
112
113    /**
114     * (non-PHPdoc)
115     * @see common_session_Session::getDataLanguage()
116     */
117    public function getDataLanguage()
118    {
119        $values = $this->getUser()->getPropertyValues(GenerisRdf::PROPERTY_USER_DEFLG);
120        return $values[0];
121    }
122
123    /**
124     * Changes the current interface language
125     *
126     * @param string $languageCode
127     */
128    public function setInterfaceLanguage($languageCode)
129    {
130        return $this->getUser()->setPropertyValues(GenerisRdf::PROPERTY_USER_UILG, [$languageCode]);
131    }
132
133    /**
134     * (non-PHPdoc)
135     * @see common_session_Session::getInterfaceLanguage()
136     */
137    public function getInterfaceLanguage()
138    {
139        $values = $this->getUser()->getPropertyValues(GenerisRdf::PROPERTY_USER_UILG);
140        return $values[0];
141    }
142
143    /**
144     * Changes the timezone of the test session
145     *
146     * @param string $timezone
147     */
148    public function setTimeZone($timezone)
149    {
150        $this->timezone = $timezone;
151    }
152
153    /**
154     * (non-PHPdoc)
155     * @see common_session_Session::getTimeZone()
156     */
157    public function getTimeZone()
158    {
159        return $this->timezone;
160    }
161
162    /**
163     * (non-PHPdoc)
164     * @see common_session_Session::refresh()
165     */
166    public function refresh()
167    {
168        // nothign to do
169    }
170
171    /**
172     * (non-PHPdoc)
173     * @see common_session_Session::getContexts()
174     */
175    public function getContexts(string $class = null): array
176    {
177        // nothign to do
178    }
179}