github_lib.test.php 2.0 KB

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