1
+ <?php
2
+
3
+ namespace Gitlab \Tests \Model ;
4
+
5
+ use Gitlab \Client ;
6
+ use Gitlab \Model \Group ;
7
+ use Gitlab \Model \GroupMilestone ;
8
+ use PHPUnit \Framework \TestCase ;
9
+
10
+ class GroupMilestoneTest extends TestCase
11
+ {
12
+ public function testConstruct ()
13
+ {
14
+ $ client = $ this ->getMockBuilder (Client::class)
15
+ ->disableOriginalConstructor ()
16
+ ->getMock ();
17
+
18
+ $ group = $ this ->getMockBuilder (Group::class)
19
+ ->disableOriginalConstructor ()
20
+ ->getMock ();
21
+
22
+ $ groupMilestone = new GroupMilestone ($ group , 1 , $ client );
23
+
24
+ $ this ->assertSame (1 , $ groupMilestone ->id );
25
+ $ this ->assertSame ($ group , $ groupMilestone ->group );
26
+ $ this ->assertSame ($ client , $ groupMilestone ->getClient ());
27
+ }
28
+
29
+ public function testFromArray ()
30
+ {
31
+ $ client = $ this ->getMockBuilder (Client::class)
32
+ ->disableOriginalConstructor ()
33
+ ->getMock ();
34
+
35
+ $ group = $ this ->getMockBuilder (Group::class)
36
+ ->disableOriginalConstructor ()
37
+ ->getMock ();
38
+
39
+ $ data = [
40
+ 'id ' => 1 ,
41
+ 'iid ' => 2 ,
42
+ 'group_id ' => 3 ,
43
+ 'title ' => 'Title ' ,
44
+ 'description ' => 'My Group Milestone ' ,
45
+ 'state ' => 'open ' ,
46
+ 'created_at ' => '2019-04-30T23:59:59.000Z ' ,
47
+ 'updated_at ' => '2019-04-30T23:59:59.000Z ' ,
48
+ 'due_date ' => '2019-05-10 ' ,
49
+ 'start_date ' => '2019-05-03 '
50
+ ];
51
+
52
+ $ groupMilestone = GroupMilestone::fromArray ($ client , $ group , $ data );
53
+
54
+ $ this ->assertInstanceOf (GroupMilestone::class, $ groupMilestone );
55
+ $ this ->assertSame ($ data ['id ' ], $ groupMilestone ->id );
56
+ $ this ->assertSame ($ data ['iid ' ], $ groupMilestone ->iid );
57
+ $ this ->assertSame ($ data ['group_id ' ], $ groupMilestone ->group_id );
58
+ $ this ->assertSame ($ data ['title ' ], $ groupMilestone ->title );
59
+ $ this ->assertSame ($ data ['description ' ], $ groupMilestone ->description );
60
+ $ this ->assertSame ($ data ['state ' ], $ groupMilestone ->state );
61
+ $ this ->assertSame ($ data ['created_at ' ], $ groupMilestone ->created_at );
62
+ $ this ->assertSame ($ data ['updated_at ' ], $ groupMilestone ->updated_at );
63
+ $ this ->assertSame ($ data ['due_date ' ], $ groupMilestone ->due_date );
64
+ $ this ->assertSame ($ data ['start_date ' ], $ groupMilestone ->start_date );
65
+ }
66
+ }
0 commit comments