Skip to content

Commit bcb52c5

Browse files
KeithYehm1guelpf
authored andcommitted
Add test for Issue model
1 parent c78fd81 commit bcb52c5

File tree

2 files changed

+43
-11
lines changed

2 files changed

+43
-11
lines changed

lib/Gitlab/Client.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,6 @@ public function deployKeys()
126126
return new Api\DeployKeys($this);
127127
}
128128

129-
/**
130-
* @return Api\Environments
131-
*/
132-
public function environments()
133-
{
134-
return new Api\Environments($this);
135-
}
136-
137129
/**
138130
* @return Api\Groups
139131
*/
@@ -291,9 +283,6 @@ public function api($name)
291283
case 'deploy_keys':
292284
return $this->deployKeys();
293285

294-
case 'environments':
295-
return $this->environments();
296-
297286
case 'groups':
298287
return $this->groups();
299288

test/Gitlab/Tests/Model/IssueTest.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,47 @@ public function testFromArray()
5959
$this->assertSame(10, $sUT->iid);
6060
$this->assertSame($client, $sUT->getClient());
6161
}
62+
63+
private function getIssueMock(array $data = [])
64+
{
65+
$client = $this->getMockBuilder(Client::class)
66+
->disableOriginalConstructor()
67+
->getMock();
68+
69+
$project = new Project(1, $client);
70+
71+
return Issue::fromArray($client, $project, $data);
72+
}
73+
74+
public function testIsClosed()
75+
{
76+
$opened_data = [
77+
'iid' => 1,
78+
'state' => 'opened',
79+
];
80+
$opened_issue = $this->getIssueMock($opened_data);
81+
82+
$this->assertFalse($opened_issue->isClosed());
83+
84+
$closed_data = [
85+
'iid' => 1,
86+
'state' => 'closed',
87+
];
88+
$closed_issue = $this->getIssueMock($closed_data);
89+
90+
$this->assertTrue($closed_issue->isClosed());
91+
}
92+
93+
public function testHasLabel()
94+
{
95+
$data = [
96+
'iid' => 1,
97+
'labels' => ['foo', 'bar'],
98+
];
99+
$issue = $this->getIssueMock($data);
100+
101+
$this->assertTrue($issue->hasLabel('foo'));
102+
$this->assertTrue($issue->hasLabel('bar'));
103+
$this->assertFalse($issue->hasLabel(''));
104+
}
62105
}

0 commit comments

Comments
 (0)