public function test_me()
 {
     $client = Phake::mock('\\Quartet\\BaseApi\\Client');
     Phake::when($client)->request('get', '/1/users/me')->thenReturn(['user' => ['test' => 'test']]);
     $em = Phake::mock('\\Quartet\\BaseApi\\EntityManager');
     Phake::when($em)->getEntity('User', ['test' => 'test'])->thenReturn('entity');
     $usersApi = new Users($client, $em);
     $this->assertEquals('entity', $usersApi->me());
 }
Example #2
0
 * Place this file on the path which is accessible with your REDIRECT URI.
 */
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/config.php';
use Quartet\BaseApi\Api\Items;
use Quartet\BaseApi\Api\Users;
use Quartet\BaseApi\Client;
$scopes = ['read_users', 'read_items'];
$client = new Client(CLIENT_ID, CLIENT_SECRET, REDIRECT_URI, $scopes);
if (isset($_GET['code'])) {
    $client->authenticate($_GET['code']);
} else {
    $client->authorize();
}
// Users api.
$usersApi = new Users($client);
$user = $usersApi->me();
var_dump($user);
// object(Quartet\BaseApi\Entity\User)[30]
//   public 'shop_id' => string 'sample_shop' (length=11)
//   public 'shop_name' => string 'sample shop name' (length=16)
//   public 'shop_introduction' => string '' (length=0)
//   public 'shop_url' => string 'http://sample_shop.thebase.in' (length=29)
//   public 'twitter_id' => string '' (length=0)
//   public 'facebook_id' => string '' (length=0)
//   public 'ameba_id' => string '' (length=0)
//   public 'instagram_id' => string '' (length=0)
//   public 'background' => null
//   public 'logo' => null
//   public 'mail_address' => null
// Items api.