Permalink
Browse files

removing files so we can rename them for case sensitivity.

  • Loading branch information...
1 parent 4bbd077 commit 7879a1d2250262d2463e30a6c896dd5244c40c86 @gwoo committed Oct 11, 2011
Showing with 0 additions and 201 deletions.
  1. +0 −132 tests/cases/extensions/adapter/data/source/http/GithubTest.php
  2. +0 −69 tests/mocks/MockGithubSocket.php
@@ -1,132 +0,0 @@
-<?php
-
-namespace li3_github\tests\cases\extensions\adapter\data\source\http;
-
-use lithium\data\Connections;
-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 {
-
- protected $_models = array(
- 'issues' => 'li3_github\models\Issues',
- 'repos' => 'li3_github\models\Repos'
- );
-
- public function setUp() {
- Connections::add('test-gh', array(
- 'type' => 'Http',
- 'adapter' => 'Github',
- 'login' => '',
- 'password' => '',
- 'socket' => 'li3_github\tests\mocks\MockGithubSocket'
- ));
- Issues::config(array('connection' => 'test-gh'));
- Repos::config(array('connection' => 'test-gh'));
- Users::config(array('connection' => 'test-gh'));
- Orgs::config(array('connection' => 'test-gh'));
- }
-
- public function testBasicGet() {
- $gh = Connections::get('test-gh');
- $headers = array('Content-Type' => 'application/json');
- $expected = 'User';
- $results = json_decode(
- $gh->connection->get('users/octocat', array(), compact('headers'))
- );
- $this->assertEqual($expected, $results->type);
- }
-
- public function testIssuesRead() {
- $gh = Connections::get('test-gh');
- $query = new Query(array('model' => $this->_models['issues']));
- $results = $gh->read($query);
- $expected = 'octocat';
- $result = $results->first();
- $this->assertEqual($expected, $result->user->login);
- }
-
- public function testRepoIssues() {
- $issues = Repos::issues(array(
- 'conditions' => array(
- 'user' => 'octocat', 'repo' => 'Hello-World'
- )
- ));
- $expected = 'octocat';
- $result = $issues->first();
- $this->assertEqual($expected, $result->user->login);
- }
-
- public function testRepoIssuesCreate() {
- $data = array(
- 'title' => 'New Bug',
- 'body' => 'this is a new bug',
- );
- $result = Repos::create($data, array(
- 'type' => 'issues',
- 'user' => 'apiheadbanger',
- 'repo' => 'demo',
- ));
- $this->assertTrue($result->save());
- }
-
- public function testRepoIssuesWithSortCreatedAsc() {
- $issues = Repos::issues(array(
- 'conditions' => array(
- 'user' => 'octocat', 'repo' => 'Hello-World',
- 'sort' => 'created', 'direction' => 'asc'
- )
- ));
- $expected = '1347';
- $result = $issues->first();
- $this->assertEqual($expected, $result->number);
- }
-
- public function testRepoIssuesWithSortCreatedDesc() {
- $issues = Repos::issues(array(
- 'conditions' => array(
- 'user' => 'octocat', 'repo' => 'Hello-World',
- 'sort' => 'created', 'direction' => 'desc'
- )
- ));
- $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');
- }
-
- public function testUserOrgs() {
- $orgs = Users::orgs(array(
- 'conditions' => array(
- 'user' => 'octocat'
- )
- ));
-
- $result = $orgs->first();
- $this->assertEqual($result->login, 'github');
- $this->assertEqual($result->id, 1);
- $this->assertEqual($result->url, 'https://api.github.com/orgs/1');
- }
-}
@@ -1,69 +0,0 @@
-<?php
-
-namespace li3_github\tests\mocks;
-
-class MockGithubSocket extends \lithium\net\Socket {
-
- protected $_data = null;
-
- public function open(array $options = array()) {
- parent::open($options);
- return true;
- }
-
- public function close() {
- return true;
- }
-
- public function eof() {
- return true;
- }
-
- public function read() {
- return join("\r\n", array(
- 'HTTP/1.1 200 OK',
- 'Header: Value',
- 'Connection: close',
- 'Content-Type: text/html;charset=UTF-8',
- '',
- $this->_data
- ));
-
- // Status: 200 OK
- // Link: <https://api.github.com/resource?page=2>; rel="next",
- // <https://api.github.com/resource?page=5>; rel="last"
- // X-RateLimit-Limit: 5000
- // X-RateLimit-Remaining: 4999
- }
-
- public function write($data) {
- $url = $data->to('url');
- return $this->_data = $this->_response($url);
- }
-
- public function timeout($time) {
- return true;
- }
-
- public function encoding($charset) {
- return true;
- }
-
- 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 = '/responses/users/repos.json';
- }
- if (strpos($url, '/users/octocat/orgs')) {
- $json = '/responses/users/orgs.json';
- }
- if (strpos($url, '/issues')) {
- $json = '/responses/issues.json';
- }
- return file_get_contents(__DIR__ . $json);
- }
-}
-
-?>

0 comments on commit 7879a1d

Please sign in to comment.