/
SoapBase.php
172 lines (141 loc) · 5 KB
/
SoapBase.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<?php
# MantisBT - A PHP based bugtracking system
# MantisBT is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# MantisBT is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with MantisBT. If not, see <http://www.gnu.org/licenses/>.
/**
* @package Tests
* @subpackage UnitTests
* @copyright Copyright (C) 2000 - 2002 Kenzaburo Ito - kenito@300baud.org
* @copyright Copyright (C) 2002 - 2013 MantisBT Team - mantisbt-dev@lists.sourceforge.net
* @link http://www.mantisbt.org
*/
$t_root_path = dirname( dirname( dirname( __FILE__ ) ) ) . DIRECTORY_SEPARATOR;
/**
* MantisBT constants
*/
require_once ( $t_root_path . DIRECTORY_SEPARATOR . 'core/constant_inc.php' );
/**
* Test cases for SoapEnum class.
*/
class SoapBase extends PHPUnit_Framework_TestCase {
protected $client;
protected $userName = 'administrator';
protected $password = 'root';
protected $email = 'root@localhost';
protected $userId = '1';
protected $mantisPath;
private $issueIdsToDelete = array();
private $versionIdsToDelete = array();
private $tagIdsToDelete = array();
private $defaultSoapClientOptions = array( 'trace' => true,
'exceptions' => true,
'cache_wsdl' => WSDL_CACHE_NONE,
'trace' => true
);
protected function setUp()
{
if (!isset($GLOBALS['MANTIS_TESTSUITE_SOAP_ENABLED']) ||
!$GLOBALS['MANTIS_TESTSUITE_SOAP_ENABLED']) {
$this->markTestSkipped( 'The Soap tests are disabled.' );
}
$this->client = new
SoapClient(
$GLOBALS['MANTIS_TESTSUITE_SOAP_HOST'],
array_merge($this->defaultSoapClientOptions, $this->extraSoapClientFlags()
)
);
$this->mantisPath = substr($GLOBALS['MANTIS_TESTSUITE_SOAP_HOST'], 0, -strlen('api/soap/mantisconnect.php?wsdl'));
}
/**
* @return an array of extra options to be passed to the SoapClient constructor
*/
protected function extraSoapClientFlags() {
return array();
}
protected function tearDown() {
foreach ( $this->versionIdsToDelete as $versionIdToDelete ) {
$this->client->mc_project_version_delete($this->userName, $this->password, $versionIdToDelete);
}
foreach ( $this->issueIdsToDelete as $issueIdToDelete ) {
$this->client->mc_issue_delete(
$this->userName,
$this->password,
$issueIdToDelete);
}
foreach ( $this->tagIdsToDelete as $tagIdToDelete ) {
$this->client->mc_tag_delete ( $this->userName, $this->password, $tagIdToDelete );
}
}
protected function getProjectId() {
return 1;
}
protected function getCategory() {
return 'General';
}
protected function skipIfTimeTrackingIsNotEnabled() {
$timeTrackingEnabled = $this->client->mc_config_get_string($this->userName, $this->password, 'time_tracking_enabled');
if ( !$timeTrackingEnabled ) {
$this->markTestSkipped('Time tracking is not enabled');
}
}
protected function getIssueToAdd( $testCase ) {
return array(
'summary' => $testCase . ': test issue: ' . rand(1, 1000000),
'description' => 'description of test issue.',
'project' => array( 'id' => $this->getProjectId() ),
'category' => $this->getCategory() );
}
/**
* Registers an issue for deletion after the test method has run
*
* @param int $issueId
* @return void
*/
protected function deleteAfterRun( $issueId ) {
$this->issueIdsToDelete[] = $issueId;
}
/**
* Registers an version for deletion after the test method has run
*
* @param int $versionId
* @return void
*/
protected function deleteVersionAfterRun( $versionId ) {
$this->versionIdsToDelete[] = $versionId;
}
/**
* Registers a tag for deletion after the test method has run
*
* @param int $tagId
* @return void
*/
protected function deleteTagAfterRun ( $tagId ) {
$this->tagIdsToDelete[] = $tagId;
}
protected function skipIfDueDateIsNotEnabled() {
if ( $this->client->mc_config_get_string( $this->userName, $this->password, 'due_date_view_threshold' ) > 90 ||
$this->client->mc_config_get_string( $this->userName, $this->password, 'due_date_update_threshold' ) > 90 ) {
$this->markTestSkipped('Due date thresholds are too high.');
}
}
protected function skipIfAllowNoCategoryIsDisabled() {
if ( $this->client->mc_config_get_string($this->userName, $this->password, 'allow_no_category' ) != true ) {
$this->markTestSkipped( 'g_allow_no_category is not ON.' );
}
}
protected function skipIsZlibIsNotAvailable() {
if( !extension_loaded( 'zlib' ) ) {
$this->markTestSkipped('zlib extension not found.');
}
}
}