示例#1
0
文件: test.php 项目: thirteen/pull
class Category extends Model
{
    public function posts()
    {
        return $this->hasResource(Post::class);
    }
}
class Post extends Model
{
    public function category()
    {
        return $this->hasResource(Category::class);
    }
}
$client = new Client(['base_uri' => 'http://headless.app/api/']);
Model::setHttpClient($client);
$token = Model::authenticate(['email' => '*****@*****.**', 'password' => 'password']);
Model::setDefault('access_token', $token);
//
// $response = $client->get('posts', [
//     'query' => [
//         'limit' => 1
//     ]
// ]);
// echo $response->getBody();
// exit;
//
// $session = new Session;
//
// $session->login([
//     'email'    => '*****@*****.**',
示例#2
0
 /**
  * Set the guzzle instance.
  */
 private function mockGuzzle($callback)
 {
     $guzzle = Mockery::mock(GuzzleHttp::class);
     $callback($guzzle);
     Model::setHttpClient($guzzle);
 }