github_lib.test.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. App::import('Lib', 'Tools.GithubLib');
  3. class GithubLibTestCase extends CakeTestCase {
  4. function setUp() {
  5. Configure::write('debug', 1);
  6. $this->GithubLib = new GithubLib();
  7. $this->assertTrue(is_object($this->GithubLib));
  8. }
  9. function TearDown() {
  10. unset($this->GithubLib);
  11. }
  12. function testFetch() {
  13. $url = 'http://github.com/api/v2/json/issues/list/';
  14. $is = $this->GithubLib->_fetch($url);
  15. echo returns($is);
  16. $this->assertFalse($is); // 401
  17. //$this->assertTrue(!empty($is));
  18. $url = 'http://github.com/api/';
  19. $is = $this->GithubLib->_fetch($url);
  20. echo returns($is);
  21. $this->assertFalse($is); // 404
  22. }
  23. function testUser() {
  24. $username = 'dereuromark';
  25. $is = $this->GithubLib->userInfo($username);
  26. echo returns($is);
  27. $this->assertTrue(!empty($is));
  28. }
  29. function testCommits() {
  30. $username = 'dereuromark';
  31. $project = 'tools';
  32. $is = $this->GithubLib->userTimeline('philsturgeon', 'codeigniter-github');
  33. echo returns($is);
  34. $this->assertTrue(!empty($is));
  35. }
  36. function testLastCommits() {
  37. $is = $this->GithubLib->lastCommits('philsturgeon', 'codeigniter-github');
  38. echo returns($is);
  39. $this->assertTrue(!empty($is));
  40. }
  41. function testSearch() {
  42. $term = 'cakephp';
  43. $language = 'php';
  44. $is = $this->GithubLib->search($term, $language);
  45. echo returns($is);
  46. $this->assertFalse($is); // WHY?
  47. //$this->assertTrue(!empty($is));
  48. }
  49. function testRepoInfo() {
  50. $user = 'dereuromark';
  51. $repo = 'tools';
  52. $is = $this->GithubLib->repoInfo($user, $repo);
  53. echo returns($is);
  54. $this->assertTrue(!empty($is));
  55. }
  56. function testRepoRefs() {
  57. $user = 'dereuromark';
  58. $repo = 'tools';
  59. $is = $this->GithubLib->repoRefs($user, $repo);
  60. echo returns($is);
  61. $this->assertTrue(empty($is));
  62. $is = $this->GithubLib->repoRefs($user, $repo, 'branches');
  63. echo returns($is);
  64. $this->assertTrue(!empty($is));
  65. }
  66. function testProjectIssues() {
  67. $user = 'dereuromark';
  68. $repo = 'tools';
  69. $is = $this->GithubLib->projectIssues($user, $repo);
  70. echo returns($is);
  71. $this->assertFalse($is);
  72. }
  73. }
  74. ?>