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 tests to expectation API
  • Loading branch information
lukeraymonddowning committed Aug 28, 2021
commit bab7469377c269869d71e3b03b277d3b3023f034
4 changes: 2 additions & 2 deletions stubs/pest-tests/EmailVerificationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

Event::assertDispatched(Verified::class);

$this->assertTrue($user->fresh()->hasVerifiedEmail());
expect($user->fresh()->hasVerifiedEmail())->toBeTrue();
$response->assertRedirect(RouteServiceProvider::HOME.'?verified=1');
});

Expand All @@ -63,5 +63,5 @@

$this->actingAs($user)->get($verificationUrl);

$this->assertFalse($user->fresh()->hasVerifiedEmail());
expect($user->fresh()->hasVerifiedEmail())->toBeFalse();
});
6 changes: 3 additions & 3 deletions stubs/pest-tests/livewire/ApiTokenPermissionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
]])
->call('updateApiToken');

$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/livewire/CreateApiTokenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
]])
->call('createApiToken');

$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/livewire/CreateTeamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
->set(['state' => ['name' => 'Test Team']])
->call('createTeam');

$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/livewire/DeleteAccountTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
->set('password', 'password')
->call('deleteUser');

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

test('correct_password_must_be_provided_before_account_can_be_deleted', function () {
nunomaduro marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -31,5 +31,5 @@
->call('deleteUser')
->assertHasErrors(['password']);

$this->assertNotNull($user->fresh());
expect($user->fresh())->not->toBeNull();
});
2 changes: 1 addition & 1 deletion stubs/pest-tests/livewire/DeleteApiTokenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@
->set(['apiTokenIdBeingDeleted' => $token->id])
->call('deleteApiToken');

$this->assertCount(0, $user->fresh()->tokens);
expect($user->fresh()->tokens)->toHaveCount(0);
});
6 changes: 3 additions & 3 deletions stubs/pest-tests/livewire/DeleteTeamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
$component = Livewire::test(DeleteTeamForm::class, ['team' => $team->fresh()])
->call('deleteTeam');

$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 @@ -30,5 +30,5 @@
->call('deleteTeam')
->assertHasErrors(['team']);

$this->assertNotNull($user->currentTeam->fresh());
expect($user->currentTeam->fresh())->not->toBeNull();
});
4 changes: 2 additions & 2 deletions stubs/pest-tests/livewire/InviteTeamMemberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,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 @@ -37,5 +37,5 @@
// Cancel the team invitation...
$component->call('cancelTeamInvitation', $invitationId);

$this->assertCount(0, $user->currentTeam->fresh()->teamInvitations);
expect($user->currentTeam->fresh()->teamInvitations)->toHaveCount(0);
});
4 changes: 2 additions & 2 deletions stubs/pest-tests/livewire/LeaveTeamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
$component = Livewire::test(TeamMemberManager::class, ['team' => $user->currentTeam])
->call('leaveTeam');

$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 @@ -26,5 +26,5 @@
->call('leaveTeam')
->assertHasErrors(['team']);

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

$component = Livewire::test(UpdateProfileInformationForm::class);

$this->assertEquals($user->name, $component->state['name']);
$this->assertEquals($user->email, $component->state['email']);
expect($component->state['name'])->toEqual($user->name);
expect($component->state['email'])->toEqual($user->email);
});

test('profile information can be updated', function () {
Expand All @@ -20,6 +20,6 @@
->set('state', ['name' => 'Test Name', 'email' => '[email protected]'])
->call('updateProfileInformation');

$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/livewire/RemoveTeamMemberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
->set('teamMemberIdBeingRemoved', $otherUser->id)
->call('removeTeamMember');

$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
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

$user = $user->fresh();

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

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

$component->call('regenerateRecoveryCodes');

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

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

$component->call('disableTwoFactorAuthentication');

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

$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 @@ -31,7 +31,7 @@
->call('updatePassword')
->assertHasErrors(['current_password']);

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

test('new passwords must match', function () {
Expand All @@ -46,5 +46,5 @@
->call('updatePassword')
->assertHasErrors(['password']);

$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/livewire/UpdateTeamMemberRoleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
->set('currentRole', 'editor')
->call('updateRole');

$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 @@ -36,7 +36,7 @@
->call('updateRole')
->assertStatus(403);

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

$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');
});