Skip to content

Commit d4af179

Browse files
Stéphane Demonchauxm1guelpf
Stéphane Demonchaux
authored andcommitted
iid instead of id in issue contruct
1 parent 62b4684 commit d4af179

File tree

3 files changed

+78
-16
lines changed

3 files changed

+78
-16
lines changed

lib/Gitlab/Model/Issue.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class Issue extends AbstractModel implements Noteable
5050
*/
5151
public static function fromArray(Client $client, Project $project, array $data)
5252
{
53-
$issue = new static($project, $data['id'], $client);
53+
$issue = new static($project, $data['iid'], $client);
5454

5555
if (isset($data['author'])) {
5656
$data['author'] = User::fromArray($client, $data['author']);
@@ -65,14 +65,14 @@ public static function fromArray(Client $client, Project $project, array $data)
6565

6666
/**
6767
* @param Project $project
68-
* @param int $id
68+
* @param int $iid
6969
* @param Client $client
7070
*/
71-
public function __construct(Project $project, $id = null, Client $client = null)
71+
public function __construct(Project $project, $iid = null, Client $client = null)
7272
{
7373
$this->setClient($client);
7474
$this->setData('project', $project);
75-
$this->setData('id', $id);
75+
$this->setData('iid', $iid);
7676
}
7777

7878
/**

lib/Gitlab/Model/Project.php

+12-12
Original file line numberDiff line numberDiff line change
@@ -807,47 +807,47 @@ public function createIssue($title, array $params = array())
807807
}
808808

809809
/**
810-
* @param int $id
810+
* @param int $iid
811811
* @return Issue
812812
*/
813-
public function issue($id)
813+
public function issue($iid)
814814
{
815-
$issue = new Issue($this, $id, $this->getClient());
815+
$issue = new Issue($this, $iid, $this->getClient());
816816

817817
return $issue->show();
818818
}
819819

820820
/**
821-
* @param int $id
821+
* @param int $iid
822822
* @param array $params
823823
* @return Issue
824824
*/
825-
public function updateIssue($id, array $params)
825+
public function updateIssue($iid, array $params)
826826
{
827-
$issue = new Issue($this, $id, $this->getClient());
827+
$issue = new Issue($this, $iid, $this->getClient());
828828

829829
return $issue->update($params);
830830
}
831831

832832
/**
833-
* @param int $id
833+
* @param int $iid
834834
* @param string $comment
835835
* @return Issue
836836
*/
837-
public function closeIssue($id, $comment = null)
837+
public function closeIssue($iid, $comment = null)
838838
{
839-
$issue = new Issue($this, $id, $this->getClient());
839+
$issue = new Issue($this, $iid, $this->getClient());
840840

841841
return $issue->close($comment);
842842
}
843843

844844
/**
845-
* @param int $id
845+
* @param int $iid
846846
* @return Issue
847847
*/
848-
public function openIssue($id)
848+
public function openIssue($iid)
849849
{
850-
$issue = new Issue($this, $id, $this->getClient());
850+
$issue = new Issue($this, $iid, $this->getClient());
851851

852852
return $issue->open();
853853
}

test/Gitlab/Tests/Model/IssueTest.php

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
3+
namespace Gitlab\Tests\Model;
4+
5+
use Gitlab\Client;
6+
use Gitlab\Model\Issue;
7+
use Gitlab\Model\Project;
8+
9+
class IssueTest extends \PHPUnit_Framework_TestCase
10+
{
11+
public function testCorrectConstructWithoutIidAndClient()
12+
{
13+
$project = new Project();
14+
15+
$sUT = new Issue($project);
16+
17+
$this->assertSame($project, $sUT->project);
18+
$this->assertSame(null, $sUT->iid);
19+
$this->assertSame(null, $sUT->getClient());
20+
}
21+
22+
public function testCorrectConstructWithoutClient()
23+
{
24+
$project = new Project();
25+
26+
$sUT = new Issue($project, 10);
27+
28+
$this->assertSame($project, $sUT->project);
29+
$this->assertSame(10, $sUT->iid);
30+
$this->assertSame(null, $sUT->getClient());
31+
}
32+
33+
public function testCorrectConstruct()
34+
{
35+
$project = new Project();
36+
$client = $this->getMockBuilder(Client::class)
37+
->disableOriginalConstructor()
38+
->getMock()
39+
;
40+
41+
$sUT = new Issue($project, 10, $client);
42+
43+
$this->assertSame($project, $sUT->project);
44+
$this->assertSame(10, $sUT->iid);
45+
$this->assertSame($client, $sUT->getClient());
46+
}
47+
48+
public function testFromArray()
49+
{
50+
$project = new Project();
51+
$client = $this->getMockBuilder(Client::class)
52+
->disableOriginalConstructor()
53+
->getMock()
54+
;
55+
56+
$sUT = Issue::fromArray($client, $project, ['iid' => 10]);
57+
58+
$this->assertSame($project, $sUT->project);
59+
$this->assertSame(10, $sUT->iid);
60+
$this->assertSame($client, $sUT->getClient());
61+
}
62+
}

0 commit comments

Comments
 (0)