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

[2.x] Adds support for Pest #866

Merged
merged 17 commits into from
Sep 8, 2021
Merged
Prev Previous commit
Next Next commit
Moves inertia pest tests to expectation API
  • Loading branch information
lukeraymonddowning committed Aug 28, 2021
commit 584ce39bd4061865d9fea2bd6579e2e86552aff8
6 changes: 3 additions & 3 deletions stubs/pest-tests/inertia/ApiTokenPermissionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
],
]);

$this->assertTrue($user->fresh()->tokens->first()->can('delete'));
$this->assertFalse($user->fresh()->tokens->first()->can('read'));
$this->assertFalse($user->fresh()->tokens->first()->can('missing-permission'));
expect($user->fresh()->tokens->first()->can('delete'))->toBeTrue();
expect($user->fresh()->tokens->first()->can('read'))->toBeFalse();
expect($user->fresh()->tokens->first()->can('missing-permission'))->toBeFalse();
});
8 changes: 4 additions & 4 deletions stubs/pest-tests/inertia/CreateApiTokenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
],
]);

$this->assertCount(1, $user->fresh()->tokens);
$this->assertEquals('Test Token', $user->fresh()->tokens->first()->name);
$this->assertTrue($user->fresh()->tokens->first()->can('read'));
$this->assertFalse($user->fresh()->tokens->first()->can('delete'));
expect($user->fresh()->tokens)->toHaveCount(1);
expect($user->fresh()->tokens->first()->name)->toEqual('Test Token');
expect($user->fresh()->tokens->first()->can('read'))->toBeTrue();
expect($user->fresh()->tokens->first()->can('delete'))->toBeFalse();
});
4 changes: 2 additions & 2 deletions stubs/pest-tests/inertia/CreateTeamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
'name' => 'Test Team',
]);

$this->assertCount(2, $user->fresh()->ownedTeams);
$this->assertEquals('Test Team', $user->fresh()->ownedTeams()->latest('id')->first()->name);
expect($user->fresh()->ownedTeams)->toHaveCount(2);
expect($user->fresh()->ownedTeams()->latest('id')->first()->name)->toEqual('Test Team');
});
4 changes: 2 additions & 2 deletions stubs/pest-tests/inertia/DeleteAccountTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
'password' => 'password',
]);

$this->assertNull($user->fresh());
expect($user->fresh())->toBeNull();
});

test('correct password must be provided before account can be deleted', function () {
Expand All @@ -28,5 +28,5 @@
'password' => 'wrong-password',
]);

$this->assertNotNull($user->fresh());
expect($user->fresh())->not->toBeNull();
});
2 changes: 1 addition & 1 deletion stubs/pest-tests/inertia/DeleteApiTokenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@

$response = $this->delete('/user/api-tokens/'.$token->id);

$this->assertCount(0, $user->fresh()->tokens);
expect($user->fresh()->tokens)->toHaveCount(0);
});
6 changes: 3 additions & 3 deletions stubs/pest-tests/inertia/DeleteTeamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

$response = $this->delete('/teams/'.$team->id);

$this->assertNull($team->fresh());
$this->assertCount(0, $otherUser->fresh()->teams);
expect($team->fresh())->toBeNull();
expect($otherUser->fresh()->teams)->toHaveCount(0);
});

test('personal teams cant be deleted', function ()
Expand All @@ -26,5 +26,5 @@

$response = $this->delete('/teams/'.$user->currentTeam->id);

$this->assertNotNull($user->currentTeam->fresh());
expect($user->currentTeam->fresh())->not->toBeNull();
});
4 changes: 2 additions & 2 deletions stubs/pest-tests/inertia/InviteTeamMemberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

Mail::assertSent(TeamInvitation::class);

$this->assertCount(1, $user->currentTeam->fresh()->teamInvitations);
expect($user->currentTeam->fresh()->teamInvitations)->toHaveCount(1);
});

test('team member invitations can be cancelled', function () {
Expand All @@ -29,5 +29,5 @@

$response = $this->delete('/team-invitations/'.$invitation->id);

$this->assertCount(0, $user->currentTeam->fresh()->teamInvitations);
expect($user->currentTeam->fresh()->teamInvitations)->toHaveCount(0);
});
4 changes: 2 additions & 2 deletions stubs/pest-tests/inertia/LeaveTeamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

$response = $this->delete('/teams/'.$user->currentTeam->id.'/members/'.$otherUser->id);

$this->assertCount(0, $user->currentTeam->fresh()->users);
expect($user->currentTeam->fresh()->users)->toHaveCount(0);
});

test('team owners cant leave their own team', function () {
Expand All @@ -23,5 +23,5 @@

$response->assertSessionHasErrorsIn('removeTeamMember', ['team']);

$this->assertNotNull($user->currentTeam->fresh());
expect($user->currentTeam->fresh())->not->toBeNull();
});
4 changes: 2 additions & 2 deletions stubs/pest-tests/inertia/ProfileInformationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
'email' => '[email protected]',
]);

$this->assertEquals('Test Name', $user->fresh()->name);
$this->assertEquals('[email protected]', $user->fresh()->email);
expect($user->fresh()->name)->toEqual('Test Name');
expect($user->fresh()->email)->toEqual('[email protected]');
});
2 changes: 1 addition & 1 deletion stubs/pest-tests/inertia/RemoveTeamMemberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

$response = $this->delete('/teams/'.$user->currentTeam->id.'/members/'.$otherUser->id);

$this->assertCount(0, $user->currentTeam->fresh()->users);
expect($user->currentTeam->fresh()->users)->toHaveCount(0);
});

test('only team owner can remove team members', function () {
Expand Down
10 changes: 5 additions & 5 deletions stubs/pest-tests/inertia/TwoFactorAuthenticationSettingsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

$response = $this->post('/user/two-factor-authentication');

$this->assertNotNull($user->fresh()->two_factor_secret);
$this->assertCount(8, $user->fresh()->recoveryCodes());
expect($user->fresh()->two_factor_secret)->not->toBeNull();
expect($user->fresh()->recoveryCodes())->toHaveCount(8);
});

test('recovery codes can be regenerated', function () {
Expand All @@ -25,8 +25,8 @@

$this->post('/user/two-factor-recovery-codes');

$this->assertCount(8, $user->recoveryCodes());
$this->assertCount(8, array_diff($user->recoveryCodes(), $user->fresh()->recoveryCodes()));
expect($user->recoveryCodes())->toHaveCount(8);
expect(array_diff($user->recoveryCodes(), $user->fresh()->recoveryCodes()))->toHaveCount(8);
});

test('two factor authentication can be disabled', function () {
Expand All @@ -40,5 +40,5 @@

$this->delete('/user/two-factor-authentication');

$this->assertNull($user->fresh()->two_factor_secret);
expect($user->fresh()->two_factor_secret)->toBeNull();
});
6 changes: 3 additions & 3 deletions stubs/pest-tests/inertia/UpdatePasswordTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
'password_confirmation' => 'new-password',
]);

$this->assertTrue(Hash::check('new-password', $user->fresh()->password));
expect(Hash::check('new-password', $user->fresh()->password))->toBeTrue();
});

test('current password must be correct', function () {
Expand All @@ -26,7 +26,7 @@

$response->assertSessionHasErrors();

$this->assertTrue(Hash::check('password', $user->fresh()->password));
expect(Hash::check('password', $user->fresh()->password))->toBeTrue();
});

test('new passwords must match', function () {
Expand All @@ -40,5 +40,5 @@

$response->assertSessionHasErrors();

$this->assertTrue(Hash::check('password', $user->fresh()->password));
expect(Hash::check('password', $user->fresh()->password))->toBeTrue();
});
8 changes: 4 additions & 4 deletions stubs/pest-tests/inertia/UpdateTeamMemberRoleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
'role' => 'editor',
]);

$this->assertTrue($otherUser->fresh()->hasTeamRole(
expect($otherUser->fresh()->hasTeamRole(
$user->currentTeam->fresh(), 'editor'
));
))->toBeTrue();
});

test('only team owner can update team member roles', function () {
Expand All @@ -31,7 +31,7 @@
'role' => 'editor',
]);

$this->assertTrue($otherUser->fresh()->hasTeamRole(
expect($otherUser->fresh()->hasTeamRole(
$user->currentTeam->fresh(), 'admin'
));
))->toBeTrue();
});
4 changes: 2 additions & 2 deletions stubs/pest-tests/inertia/UpdateTeamNameTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
'name' => 'Test Team',
]);

$this->assertCount(1, $user->fresh()->ownedTeams);
$this->assertEquals('Test Team', $user->currentTeam->fresh()->name);
expect($user->fresh()->ownedTeams)->toHaveCount(1);
expect($user->currentTeam->fresh()->name)->toEqual('Test Team');
});