<?php require_once dirname(__FILE__) . '/../../vendor/lime.php'; require_once dirname(__FILE__) . '/../../lib/phpGitHubApi.php'; $t = new lime_test(4); $api = new phpGitHubApi(true); $t->comment('Test ->searchUsers'); $users = $api->searchUsers('diem-project'); $t->is(count($users), 1, 'Found one user'); $t->is(array_keys($users), array('diem-project'), 'Found diem-project user'); $t->comment('Test ->showUser'); $user = $api->showUser('diem-project'); $t->is($user['login'], 'diem-project', 'Found infos about diem-project user'); $message = 'Found no infos about this-user-probably-doesnt-exist user'; try { $user = $api->showUser('this-user-probably-doesnt-exist'); $t->fail($message); } catch (phpGitHubApiRequestException $e) { $t->pass($message); }
<?php require_once dirname(__FILE__) . '/vendor/lime.php'; require_once dirname(__FILE__) . '/../lib/phpGitHubApi.php'; $t = new lime_test(16); $username = '******'; $token = 'fd8144e29b4a85e9487d1cacbcd4e26c'; $github = new phpGitHubApi(true); $t->comment('Search users'); $users = $github->getUserApi()->search($username); $t->is(count($users), 1, 'Found one user'); $t->is(array_keys($users), array($username), 'Found ' . $username . ' user'); $t->is_deeply($github->searchUsers($username), $users, 'Both new and BC syntax work'); $t->comment('Show a user'); $user = $github->getUserApi()->show($username); $t->is($user['login'], $username, 'Found infos about ' . $username . ' user'); $t->is_deeply($github->showUser($username), $user, 'Both new and BC syntax work'); $t->comment('Show a non-existing user'); try { $user = $github->getUserApi()->show('this-user-probably-doesnt-exist'); $t->fail('Found no infos about this-user-probably-doesnt-exist user'); } catch (phpGitHubApiRequestException $e) { $t->pass('Found no infos about this-user-probably-doesnt-exist user'); } $t->comment('Get following users'); $users = $github->getUserApi()->getFollowing('ornicar'); $t->ok(count($users), 'Found ' . 'ornicar' . ' following users'); $t->comment('Get follower users'); $users = $github->getUserApi()->getFollowers('ornicar'); $t->ok(count($users), 'Found ' . 'ornicar' . ' followers users'); $t->comment('Authenticate ' . $username);