. */ use Illuminate\Foundation\Testing\WithoutMiddleware; use Illuminate\Foundation\Testing\DatabaseMigrations; use Illuminate\Foundation\Testing\DatabaseTransactions; use Poniverse\Ponyfm\User; class ApiAuthTest extends TestCase { use DatabaseMigrations; /** * Ensures that when we call the Pony.fm API with a user who has never * logged into Pony.fm before, a Pony.fm account is created for them using * their Poniverse details. */ public function testApiCreatesNewUser() { $user = factory(User::class)->make(); $accessTokenInfo = new \Poniverse\AccessTokenInfo('nonsense-token'); $accessTokenInfo->setIsActive(true); $accessTokenInfo->setScopes(['basic', 'ponyfm-upload-track']); $poniverse = Mockery::mock('overload:Poniverse'); $poniverse->shouldReceive('getUser') ->andReturn([ 'username' => $user->username, 'display_name' => $user->display_name, 'email' => $user->email, ]); $poniverse->shouldReceive('setAccessToken'); $poniverse ->shouldReceive('getAccessTokenInfo') ->andReturn($accessTokenInfo); $this->dontSeeInDatabase('users', ['username' => $user->username]); $this->post('/api/v1/tracks', ['access_token' => 'nonsense-token']); $this->seeInDatabase('users', ['username' => $user->username]); } }