Skip to content
Browse files

Add tests for user/org repos

  • Loading branch information...
1 parent d4464d3 commit 903d14fe36a9e0dd0fc53ed29fcc3c6e40ecac9a @dshafik dshafik committed Oct 11, 2011
View
22 tests/cases/extensions/adapter/data/source/http/GithubTest.php
@@ -6,6 +6,8 @@
use lithium\data\model\Query;
use li3_github\models\Issues;
use li3_github\models\Repos;
+use li3_github\models\Orgs;
+use li3_github\models\Users;
class GithubTest extends \lithium\test\Unit {
@@ -91,4 +93,24 @@ public function testRepoIssuesWithSortCreatedDesc() {
$result = $issues->first();
$this->assertTrue($result->number > 2);
}
+
+ public function testUsersRepos() {
+ $repos = Users::repos(array(
+ 'conditions' => array(
+ 'user' => 'octocat'
+ )
+ ));
+ $result = $repos->first();
+ $this->assertEqual($result->name, 'Hello-World');
+ }
+
+ public function testOrgsRepos() {
+ $repos = Orgs::repos(array(
+ 'conditions' => array(
+ 'org' => 'octocat'
+ )
+ ));
+ $result = $repos->first();
+ $this->assertEqual($result->name, 'Hello-World');
+ }
}
View
3 tests/mocks/MockGithubSocket.php
@@ -53,6 +53,9 @@ private function _response($url) {
if (strpos($url, '/users/octocat')) {
$json = '/responses/users/octocat.json';
}
+ if (strpos($url, '/users/octocat/repos') || strpos($url, '/orgs/octocat/repos')) {
+ $json = '/reponses/users/repos.json';
+ }
if (strpos($url, '/issues')) {
$json = '/responses/issues.json';
}
View
29 tests/mocks/responses/users/repos.json
@@ -0,0 +1,29 @@
+[
+ {
+ "url": "https://api.github.com/repos/octocat/Hello-World",
+ "html_url": "https://github.com/octocat/Hello-World",
+ "clone_url": "https://github.com/octocat/Hello-World.git",
+ "git_url": "git://github.com/octocat/Hello-World.git",
+ "ssh_url": "git@github.com:octocat/Hello-World.git",
+ "svn_url": "https://svn.github.com/octocat/Hello-World",
+ "owner": {
+ "login": "octocat",
+ "id": 1,
+ "avatar_url": "https://github.com/images/error/octocat_happy.gif",
+ "url": "https://api.github.com/users/octocat"
+ },
+ "name": "Hello-World",
+ "description": "This your first repo!",
+ "homepage": "https://github.com",
+ "language": null,
+ "private": false,
+ "fork": false,
+ "forks": 9,
+ "watchers": 80,
+ "size": 108,
+ "master_branch": "master",
+ "open_issues": 0,
+ "pushed_at": "2011-01-26T19:06:43Z",
+ "created_at": "2011-01-26T19:01:12Z"
+ }
+]

0 comments on commit 903d14f

Please sign in to comment.
Something went wrong with that request. Please try again.