IssueApiTest.js
3.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/**
* Copyright 2010 Ajax.org B.V.
*
* This product includes software developed by
* Ajax.org B.V. (http://www.ajax.org/).
*
* Author: Fabian Jaokbs <fabian@ajax.org>
*/
var sys = require("sys");
var GitHubApi = require("../lib/github").GitHubApi;
var async_testing = require('../vendor/node-async-testing/async_testing');
var suite = exports.suite = new async_testing.TestSuite();
var username = 'ornicar';
var repo = 'php-github-api';
suite.setup(function() {
this.github = new GitHubApi(true);
this.issueApi = this.github.getIssueApi();
});
suite.addTests({
"test: list issues" : function(assert, finished, test) {
test.issueApi.getList(username, repo, "closed", function(err, issues) {
assert.equal(issues[0].state, "closed");
finished();
});
}
});
if (module === require.main) {
async_testing.runSuites({IssueApi: suite});
}
//$t->is_deeply($github->listIssues($username, $repo, 'closed'), $issues, 'Both new and BC syntax work');
//
//$t->comment('Search issues');
//
//$issues = $github->getIssueApi()->search($username, $repo, 'closed', 'documentation');
//
//$t->is($issues[0]['state'], 'closed', 'Found closed issues matching "documentation"');
//
//$t->is_deeply($github->searchIssues($username, $repo, 'closed', 'documentation'), $issues, 'Both new and BC syntax work');
//
//$t->comment('Show issue');
//
//$issue = $github->getIssueApi()->show($username, $repo, 1);
//
//$t->is($issue['title'], 'Provide documentation', 'Found issue #1');
//
//$t->is_deeply($github->showIssue($username, $repo, 1), $issue, 'Both new and BC syntax work');
//
//$username = 'ornicartest';
//$token = 'fd8144e29b4a85e9487d1cacbcd4e26c';
//$repo = 'php-github-api';
//
//$t->comment('Authenticate '.$username);
//
//$github->authenticate($username, $token);
//
//$t->comment('Open a new issue');
//
//$issueTitle = 'Test new issue title '.time();
//$issue = $github->getIssueApi()->open($username, $repo, $issueTitle, 'Test new issue body');
//
//$t->is($issue['title'], $issueTitle, 'Got the new issue');
//$t->is($issue['state'], 'open', 'The new issue is open');
//
//$issueNumber = $issue['number'];
//
//$t->comment('Close the issue');
//
//$issue = $github->getIssueApi()->close($username, $repo, $issueNumber);
//
//$t->is($issue['state'], 'closed', 'The new issue is closed');
//
//$t->comment('Reopen the issue');
//
//$issue = $github->getIssueApi()->reOpen($username, $repo, $issueNumber);
//
//$t->is($issue['state'], 'open', 'The new issue is open');
//
//$t->comment('Update the issue');
//
//$issue = $github->getIssueApi()->update($username, $repo, $issueNumber, array(
// 'body' => 'Test new issue body updated'
//));
//
//$t->is($issue['body'], 'Test new issue body updated', 'The issue has been updated');
//
//$t->comment('Add an issue comment');
//$commentText = 'This is a test comment';
//
//$comment = $github->getIssueApi()->addComment($username, $repo, $issueNumber, $commentText);
//
//$t->is($comment['comment'], $commentText, 'Got the new comment');
//
//$t->comment('List issue comments');
//
//$comments = $github->getIssueApi()->getComments($username, $repo, $issueNumber);
//
//$t->is($comments[0]['body'], $commentText, 'Found the new comment');
//
//$t->comment('Add a label to the issue');
//$labelName = 'testing';
//
//$labels = $github->getIssueApi()->addLabel($username, $repo, $labelName, $issueNumber);
//
//$t->ok(in_array($labelName, $labels), 'The issue now has the label '.$labelName);
//
//$t->comment('Remove a label from the issue');
//
//$labels = $github->getIssueApi()->removeLabel($username, $repo, $labelName, $issueNumber);
//
//$t->ok(!in_array($labelName, $labels), 'The issue has no more label '.$labelName);
//
//$t->comment('List project labels');
//
//$labels = $github->getIssueApi()->getLabels($username, $repo);
//
//$t->ok(in_array($labelName, $labels), 'The project has the label '.$labelName);