Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Airlock::actingAs #50

Closed
leemcd56 opened this issue Jan 20, 2020 · 5 comments
Closed

Airlock::actingAs #50

leemcd56 opened this issue Jan 20, 2020 · 5 comments

Comments

@leemcd56
Copy link
Contributor

I would really like to use this as an alternative to Passport for an API I am building, but a lot of my tests use Passport::actingAs for roles and permissions tests.

How could one go about mocking this functionality for the time being so I could write in tests like this:

   /**
     * Test DELETE /api/properties/{id}.
     *
     * @return void
     */
    public function testDeleteProperty()
    {
        Airlock::actingAs(
            factory(\App\User::class)->create()->attachRole('admin')
        );

        $property = factory(\App\Property::class)->create();
        $response = $this->deleteJson('/api/properties/' . $property->id);

        $response
            ->assertOk()
            ->assertJsonPath('message', 'Deleted property.');

        $this->assertSoftDeleted('properties', [
            'id' => $property->id,
        ]);
    }
@driesvints
Copy link
Member

Feel free to attempt a PR.

@amaelftah
Copy link
Contributor

@leemcd56 i have a quick question . does $this->actingAs($user) can solve the case ?

@leemcd56
Copy link
Contributor Author

@leemcd56 i have a quick question . does $this->actingAs($user) can solve the case ?

@Te7a-Houdini It doesn't create a new personal access token to provide the proper access.

I have opened up PR #51 to add in ::actingAs. I am having an issue creating a new token because, even though migrations are running, the personal_access_tokens table does not appear to exist during the test.

@amaelftah
Copy link
Contributor

Got it thanks for the clarification

@driesvints
Copy link
Member

PR was merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants