9
9
require_once 'include/pdo.php ' ;
10
10
11
11
use CDash \Database ;
12
- use CDash \Model \BuildConfigure ;
12
+ use CDash \Model \BuildGroup ;
13
+ use CDash \Model \Site ;
13
14
14
15
class PutDynamicBuildsTestCase extends KWWebTestCase
15
16
{
@@ -31,10 +32,17 @@ public function testPutDynamicBuildsDiff()
31
32
32
33
// Get one of the default buildgroups for this project.
33
34
$ stmt = $ this ->PDO ->prepare (
34
- 'SELECT id FROM buildgroup WHERE projectid = :projectid LIMIT 2 ' );
35
+ 'SELECT id FROM buildgroup WHERE projectid = :projectid LIMIT 1 ' );
35
36
$ this ->PDO ->execute ($ stmt , [':projectid ' => $ this ->ProjectId ]);
36
37
$ this ->ParentGroupId = $ stmt ->fetchColumn ();
37
- $ this ->ChildGroupId = $ stmt ->fetchColumn ();
38
+
39
+ // Create a 'Latest' buildgroup for this project.
40
+ $ buildgroup = new BuildGroup ();
41
+ $ buildgroup ->SetProjectId ($ this ->ProjectId );
42
+ $ buildgroup ->SetName ('latest results ' );
43
+ $ buildgroup ->SetType ('Latest ' );
44
+ $ buildgroup ->Save ();
45
+ $ this ->ChildGroupId = $ buildgroup ->GetId ();
38
46
39
47
// Use the API PUT a list of builds.
40
48
$ client = $ this ->getGuzzleClient ();
@@ -74,6 +82,27 @@ public function testPutDynamicBuildsDiff()
74
82
$ this ->assertTrue (strtotime ($ endtime ) > strtotime ('-1 week ' ));
75
83
}
76
84
85
+ // Verify that we can associate a dynamic build group with a rule that
86
+ // hasn't submitted any builds to this project yet.
87
+ $ site = new Site ();
88
+ $ site ->Id = 1 ;
89
+ $ site_name = $ site ->GetName ();
90
+ $ build_rules = [
91
+ [ 'match ' => 'foo ' , 'parentgroupid ' => $ this ->ParentGroupId , 'site ' => $ site_name ],
92
+ ];
93
+ $ starttime_stmt = $ this ->PDO ->prepare ("
94
+ SELECT starttime FROM build2grouprule
95
+ WHERE buildname = :buildname AND
96
+ parentgroupid = :parentgroupid AND
97
+ siteid = $ site ->Id " );
98
+ $ this ->verifyListGetsCreated ($ client , $ starttime_stmt , $ build_rules );
99
+ $ this ->login ();
100
+ $ this ->get ($ this ->url . "/api/v1/manageBuildGroup.php?projectid= {$ this ->ProjectId }" );
101
+ $ content = $ this ->getBrowser ()->getContent ();
102
+ $ jsonobj = json_decode ($ content , true );
103
+ $ this ->assertEqual ($ jsonobj ['dynamics ' ][0 ]['rules ' ][0 ]['match ' ], 'foo ' );
104
+ $ this ->assertEqual ($ jsonobj ['dynamics ' ][0 ]['rules ' ][0 ]['siteid ' ], 1 );
105
+
77
106
// Clean up.
78
107
$ this ->deleteProject ($ this ->ProjectId );
79
108
}
0 commit comments