Skip to content

Commit 5af507d

Browse files
authored
Merge pull request #173 from kbsali/misc
Misc
2 parents a8efda4 + 12e031f commit 5af507d

File tree

7 files changed

+28
-6
lines changed

7 files changed

+28
-6
lines changed

lib/Redmine/Api/AbstractApi.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ protected function retrieveAll($endpoint, array $params = array())
175175
* Attaches Custom Fields to a create/update query.
176176
*
177177
* @param \SimpleXMLElement $xml XML Element the custom fields are attached to
178-
* @param array $fields array of fields to attach, each field needs name, id and value set
178+
* @param array $fields array of fields to attach, each field needs name, id and value set
179179
*
180180
* @return \SimpleXMLElement $xml
181181
*

lib/Redmine/Api/Project.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,9 @@ protected function prepareParamsXml($params)
153153

154154
$xml = new \SimpleXMLElement('<?xml version="1.0"?><project></project>');
155155
foreach ($params as $k => $v) {
156-
if (isset($_params[$k]) && is_array($v)) {
156+
if ('custom_fields' === $k && is_array($v)) {
157+
$this->attachCustomFieldXML($xml, $v);
158+
} elseif (isset($_params[$k]) && is_array($v)) {
157159
$array = $xml->addChild($k, '');
158160
$array->addAttribute('type', 'array');
159161
foreach ($v as $id) {

lib/Redmine/Api/User.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function getIdByUsername($username, array $params = array())
9494
* - memberships: adds extra information about user's memberships and roles on the projects
9595
* - groups (added in 2.1): adds extra information about user's groups
9696
* - api_key: the API key of the user, visible for admins and for yourself (added in 2.3.0)
97-
* - status: a numeric id representing the status of the user, visible for admins only (added in 2.4.0).
97+
* - status: a numeric id representing the status of the user, visible for admins only (added in 2.4.0)
9898
*
9999
* @param string $id the user id
100100
* @param array $params extra associated data

lib/Redmine/Client.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,12 +492,11 @@ public function getCurlOptions()
492492
* @param string $method
493493
* @param string $data
494494
*
495-
* @return resource a cURL handle on success, <b>FALSE</b> on errors.
495+
* @return resource a cURL handle on success, <b>FALSE</b> on errors
496496
*/
497497
public function prepareRequest($path, $method = 'GET', $data = '')
498498
{
499499
$this->responseCode = null;
500-
$this->curlOptions = array();
501500
$curl = curl_init();
502501

503502
// General cURL options

test/Redmine/Fixtures/MockClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
/**
88
* Mock client class.
9-
*
9+
*
1010
* The runRequest method of this client class just returns the value of
1111
* the path, method and data or the $runRequestReturnValue value if set.
1212
*/

test/Redmine/Tests/ClientTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,9 +362,13 @@ public function testPrepareXmlPutRequestWithHttpUsernameAndPassword()
362362

363363
// Perform the tests
364364
$data = array(1 => 'post_1', '25' => 'post_25');
365+
$client->setCurlOption(CURLOPT_PROXY, 'PROXYURL:PORT');
365366
$client->prepareRequest('/issues.xml', 'PUT', $data);
367+
366368
$curlOptions = $client->getCurlOptions();
369+
367370
$this->assertRegExp('/username\:secret/m', $curlOptions[CURLOPT_USERPWD]);
371+
$this->assertSame('PROXYURL:PORT', $curlOptions[CURLOPT_PROXY]);
368372
$this->assertSame(CURLAUTH_BASIC, $curlOptions[CURLOPT_HTTPAUTH]);
369373
$this->assertSame('http://test.local/issues.xml', $curlOptions[CURLOPT_URL]);
370374
$this->assertSame(0, $curlOptions[CURLOPT_VERBOSE]);

test/Redmine/Tests/ProjectXmlTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,29 @@ public function testCreateComplex()
2828
$res = $this->client->api('project')->create(array(
2929
'name' => 'some name',
3030
'identifier' => 'the_identifier',
31+
'custom_fields' => array(
32+
array(
33+
'id' => 123,
34+
'name' => 'cf_name',
35+
'field_format' => 'string',
36+
'value' => array(1, 2, 3),
37+
),
38+
),
3139
));
3240

3341
$xml = '<?xml version="1.0"?>
3442
<project>
3543
<name>some name</name>
3644
<identifier>the_identifier</identifier>
45+
<custom_fields type="array">
46+
<custom_field name="cf_name" field_format="string" id="123" multiple="true">
47+
<value type="array">
48+
<value>1</value>
49+
<value>2</value>
50+
<value>3</value>
51+
</value>
52+
</custom_field>
53+
</custom_fields>
3754
</project>';
3855
$this->assertEquals($this->formatXml($xml), $this->formatXml($res['data']));
3956
}

0 commit comments

Comments
 (0)