Skip to content

Commit eca3bc8

Browse files
DBLacim1guelpf
authored andcommitted
#446 - update tests
1 parent af496fc commit eca3bc8

File tree

3 files changed

+58
-4
lines changed

3 files changed

+58
-4
lines changed

test/Gitlab/Tests/Api/GroupsTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,8 @@ public function shouldGetAllSubgroups()
320320
public function shouldGetLabels()
321321
{
322322
$expectedArray = array(
323-
array('name' => 'bug', 'color' => '#000000'),
324-
array('name' => 'feature', 'color' => '#ff0000')
323+
array('id' => 987, 'name' => 'bug', 'color' => '#000000'),
324+
array('id' => 123, 'name' => 'feature', 'color' => '#ff0000')
325325
);
326326

327327
$api = $this->getApiMock();

test/Gitlab/Tests/Api/ProjectsTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,8 +1058,8 @@ public function shouldGetEventsWithPagination()
10581058
public function shouldGetLabels()
10591059
{
10601060
$expectedArray = array(
1061-
array('name' => 'bug', 'color' => '#000000'),
1062-
array('name' => 'feature', 'color' => '#ff0000')
1061+
array('id' => 987, 'name' => 'bug', 'color' => '#000000'),
1062+
array('id' => 123, 'name' => 'feature', 'color' => '#ff0000')
10631063
);
10641064

10651065
$api = $this->getApiMock();
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
namespace Gitlab\Tests\Model;
4+
5+
use Gitlab\Api\Issues;
6+
use Gitlab\Api\IssueLinks;
7+
use Gitlab\Api\Projects;
8+
use Gitlab\Client;
9+
use Gitlab\Model\Issue;
10+
use Gitlab\Model\IssueLink;
11+
use Gitlab\Model\Label;
12+
use Gitlab\Model\Project;
13+
use PHPUnit\Framework\TestCase;
14+
15+
class LabelTest extends TestCase
16+
{
17+
public function testCorrectConstructWithoutClient()
18+
{
19+
$project = new Project();
20+
21+
$sUT = new Label($project);
22+
23+
$this->assertSame(null, $sUT->getClient());
24+
}
25+
26+
public function testCorrectConstruct()
27+
{
28+
$project = new Project();
29+
$client = $this->getMockBuilder(Client::class)
30+
->disableOriginalConstructor()
31+
->getMock()
32+
;
33+
34+
$sUT = new Label($project, $client);
35+
36+
$this->assertSame($client, $sUT->getClient());
37+
}
38+
39+
public function testFromArray()
40+
{
41+
$project = new Project();
42+
$client = $this->getMockBuilder(Client::class)
43+
->disableOriginalConstructor()
44+
->getMock()
45+
;
46+
47+
$sUT = Label::fromArray($client, $project, ['color' => '#FF0000', 'name' => 'Testing', 'id' => 123]);
48+
49+
$this->assertSame('#FF0000', $sUT->color);
50+
$this->assertSame('Testing', $sUT->name);
51+
$this->assertSame(123, $sUT->id);
52+
$this->assertSame($client, $sUT->getClient());
53+
}
54+
}

0 commit comments

Comments
 (0)