Skip to content

Commit

Permalink
Merge pull request #495 from pacoorozco/shift-111696
Browse files Browse the repository at this point in the history
PHPUnit 10 Shift
  • Loading branch information
pacoorozco authored Mar 8, 2024
2 parents 1181430 + 48cc64f commit 0daa96a
Show file tree
Hide file tree
Showing 54 changed files with 386 additions and 405 deletions.
5 changes: 3 additions & 2 deletions tests/Feature/Actions/CreateUserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@

namespace Tests\Feature\Actions;

use PHPUnit\Framework\Attributes\Test;
use Gamify\Actions\CreateUserAction;
use Gamify\Models\User;
use Gamify\Models\UserProfile;
use Tests\Feature\TestCase;

class CreateUserTest extends TestCase
final class CreateUserTest extends TestCase
{
/** @test */
#[Test]
public function it_should_create_a_user_with_its_profile(): void
{
/** @var User $want */
Expand Down
17 changes: 9 additions & 8 deletions tests/Feature/Actions/PublishQuestionActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

namespace Tests\Feature\Actions;

use PHPUnit\Framework\Attributes\Test;
use Gamify\Actions\PublishQuestionAction;
use Gamify\Events\QuestionPublished;
use Gamify\Exceptions\QuestionPublishingException;
Expand All @@ -33,9 +34,9 @@
use Illuminate\Support\Facades\Event;
use Tests\Feature\TestCase;

class PublishQuestionActionTest extends TestCase
final class PublishQuestionActionTest extends TestCase
{
/** @test */
#[Test]
public function it_triggers_an_event_when_a_question_is_published(): void
{
/** @var Question $question */
Expand All @@ -57,7 +58,7 @@ public function it_triggers_an_event_when_a_question_is_published(): void
$this->assertEquals(Question::PUBLISH_STATUS, $question->status);
}

/** @test */
#[Test]
public function it_does_not_trigger_an_event_when_a_question_was_already_published(): void
{
/** @var Question $question */
Expand All @@ -78,7 +79,7 @@ public function it_does_not_trigger_an_event_when_a_question_was_already_publish
$this->assertEquals(Question::PUBLISH_STATUS, $question->status);
}

/** @test */
#[Test]
public function it_throws_an_exception_when_trying_to_publish_a_question_without_at_least_two_choices(): void
{
$this->withoutExceptionHandling();
Expand All @@ -95,7 +96,7 @@ public function it_throws_an_exception_when_trying_to_publish_a_question_without
$publisher->execute($question);
}

/** @test */
#[Test]
public function it_throws_an_exception_when_trying_to_publish_a_question_without_a_correct_choice(): void
{
$this->withoutExceptionHandling();
Expand All @@ -112,7 +113,7 @@ public function it_throws_an_exception_when_trying_to_publish_a_question_without
$publisher->execute($question);
}

/** @test */
#[Test]
public function it_publishes_question_when_date_is_on_the_past(): void
{
/** @var Question $question */
Expand All @@ -130,7 +131,7 @@ public function it_publishes_question_when_date_is_on_the_past(): void
$this->assertEquals(Question::PUBLISH_STATUS, $question->status);
}

/** @test */
#[Test]
public function it_schedules_question_publication_when_date_is_in_the_future(): void
{
/** @var Question $question */
Expand All @@ -148,7 +149,7 @@ public function it_schedules_question_publication_when_date_is_in_the_future():
$this->assertEquals(Question::FUTURE_STATUS, $question->status);
}

/** @test */
#[Test]
public function it_does_not_trigger_an_event_when_publish_fails(): void
{
/** @var Question $question */
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/Auth/AuthenticationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Illuminate\Support\Facades\Event;
use Tests\Feature\TestCase;

class AuthenticationTest extends TestCase
final class AuthenticationTest extends TestCase
{
public function test_login_screen_can_be_rendered(): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/Auth/EmailVerificationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Illuminate\Support\Facades\URL;
use Tests\Feature\TestCase;

class EmailVerificationTest extends TestCase
final class EmailVerificationTest extends TestCase
{
public function test_email_verification_screen_can_be_rendered(): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/Auth/PasswordConfirmationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Gamify\Models\User;
use Tests\Feature\TestCase;

class PasswordConfirmationTest extends TestCase
final class PasswordConfirmationTest extends TestCase
{
public function test_confirm_password_screen_can_be_rendered(): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/Auth/PasswordResetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Illuminate\Support\Facades\Notification;
use Tests\Feature\TestCase;

class PasswordResetTest extends TestCase
final class PasswordResetTest extends TestCase
{
public function test_reset_password_link_screen_can_be_rendered(): void
{
Expand Down
11 changes: 5 additions & 6 deletions tests/Feature/Auth/RegistrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

namespace Tests\Feature\Auth;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
use Gamify\Models\User;
use Gamify\Providers\RouteServiceProvider;
use Generator;
use Tests\Feature\TestCase;

class RegistrationTest extends TestCase
final class RegistrationTest extends TestCase
{
public function test_registration_screen_can_be_rendered(): void
{
Expand All @@ -30,11 +32,8 @@ public function test_new_users_can_register(): void
$this->assertAuthenticated();
}

/**
* @test
*
* @dataProvider provideWrongDataForUserRegistration
*/
#[Test]
#[DataProvider('provideWrongDataForUserRegistration')]
public function it_should_get_errors_when_registering_with_wrong_data(
array $data,
array $errors
Expand Down
5 changes: 3 additions & 2 deletions tests/Feature/Auth/SocialAuthenticationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@

namespace Tests\Feature\Auth;

use PHPUnit\Framework\Attributes\Test;
use Gamify\Events\SocialLogin;
use Gamify\Providers\RouteServiceProvider;
use Illuminate\Support\Facades\Event;
use Laravel\Socialite\Facades\Socialite;
use Mockery;
use Tests\Feature\TestCase;

class SocialAuthenticationTest extends TestCase
final class SocialAuthenticationTest extends TestCase
{
/** @test */
#[Test]
public function it_should_authenticate_users_using_social_login(): void
{
$this->mockSocialLogin();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@

namespace Tests\Feature\Console\Commands;

use PHPUnit\Framework\Attributes\Test;
use Gamify\Models\Question;
use Tests\Feature\TestCase;

class PublishScheduledQuestionsTest extends TestCase
final class PublishScheduledQuestionsTest extends TestCase
{
/** @test */
#[Test]
public function it_should_not_publish_questions_if_it_is_not_the_right_time_yet(): void
{
/** @var Question $question */
Expand All @@ -50,7 +51,7 @@ public function it_should_not_publish_questions_if_it_is_not_the_right_time_yet(
$this->assertEquals(Question::FUTURE_STATUS, $question->status);
}

/** @test */
#[Test]
public function it_should_raise_an_error_when_questions_can_not_be_published(): void
{
// Create a question without choices().
Expand All @@ -71,7 +72,7 @@ public function it_should_raise_an_error_when_questions_can_not_be_published():
$this->assertEquals(Question::FUTURE_STATUS, $question->status);
}

/** @test */
#[Test]
public function it_should_sent_two_questions_to_publication(): void
{
$questions = Question::factory()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@

namespace Tests\Feature\Http\Controllers\Account;

use PHPUnit\Framework\Attributes\Test;
use Gamify\Models\User;
use Illuminate\Support\Facades\Hash;
use Tests\Feature\TestCase;

class ChangePasswordControllerTest extends TestCase
final class ChangePasswordControllerTest extends TestCase
{
const VALID_PASSWORD = 'foo#B4rBaz';

/** @test */
#[Test]
public function it_shows_password_change_form_for_logged_users(): void
{
/** @var User $user */
Expand All @@ -45,15 +46,15 @@ public function it_shows_password_change_form_for_logged_users(): void
->assertViewIs('account.password.index');
}

/** @test */
#[Test]
public function it_shows_error_for_non_logged_users(): void
{
$this
->get(route('account.password.index'))
->assertRedirect(route('login'));
}

/** @test */
#[Test]
public function it_shows_validation_error_if_current_password_is_invalid(): void
{
/** @var User $user */
Expand All @@ -71,7 +72,7 @@ public function it_shows_validation_error_if_current_password_is_invalid(): void
->assertInvalid(['current-password']);
}

/** @test */
#[Test]
public function it_shows_validation_error_if_new_password_confirmation_does_not_match(): void
{
/** @var User $user */
Expand All @@ -89,7 +90,7 @@ public function it_shows_validation_error_if_new_password_confirmation_does_not_
->assertInvalid(['new-password']);
}

/** @test */
#[Test]
public function it_has_success_key_on_session_when_password_has_been_changed(): void
{
/** @var User $user */
Expand Down
Loading

0 comments on commit 0daa96a

Please sign in to comment.