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] Prevent MissingAttributeException #1213

Merged
merged 2 commits into from
Jan 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions database/factories/UserFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ public function definition(): array
'email' => $this->faker->unique()->safeEmail(),
'email_verified_at' => now(),
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
'two_factor_secret' => null,
'two_factor_recovery_codes' => null,
'remember_token' => Str::random(10),
'profile_photo_path' => null,
'current_team_id' => null,
];
}

Expand Down
8 changes: 6 additions & 2 deletions tests/OrchestraTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ protected function getPackageProviders($app)

protected function defineEnvironment($app)
{
$app['migrator']->path(__DIR__.'/../database/migrations');

$app['config']->set('database.default', 'testbench');

$app['config']->set('database.connections.testbench', [
Expand All @@ -38,6 +36,12 @@ protected function defineEnvironment($app)
]);
}

protected function defineDatabaseMigrations()
{
$this->loadMigrationsFrom(__DIR__.'/../database/migrations');
$this->loadMigrationsFrom(__DIR__.'/../vendor/laravel/fortify/database/migrations');
}

protected function defineHasTeamEnvironment($app)
{
$features = $app->config->get('jetstream.features', []);
Expand Down
17 changes: 0 additions & 17 deletions tests/UserProfileControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Laravel\Jetstream\Tests;

use Illuminate\Support\Facades\Schema;
use Laravel\Fortify\Actions\DisableTwoFactorAuthentication;
use Laravel\Fortify\Features;
use Laravel\Jetstream\Jetstream;
Expand All @@ -20,8 +19,6 @@ public function setUp(): void

public function test_empty_two_factor_state_is_noted()
{
$this->migrate();

$disable = $this->mock(DisableTwoFactorAuthentication::class);
$disable->shouldReceive('__invoke')->once();

Expand All @@ -43,8 +40,6 @@ public function test_empty_two_factor_state_is_noted()

public function test_two_factor_is_not_disabled_if_was_previously_empty_and_currently_confirming()
{
$this->migrate();

$disable = $this->mock(DisableTwoFactorAuthentication::class);
$disable->shouldReceive('__invoke')->never();

Expand All @@ -67,8 +62,6 @@ public function test_two_factor_is_not_disabled_if_was_previously_empty_and_curr

public function test_two_factor_is_disabled_if_was_previously_confirming_and_page_is_reloaded()
{
$this->migrate();

$disable = $this->mock(DisableTwoFactorAuthentication::class);
$disable->shouldReceive('__invoke')->once();

Expand All @@ -92,16 +85,6 @@ public function test_two_factor_is_disabled_if_was_previously_confirming_and_pag
$response->assertStatus(200);
}

protected function migrate()
{
$this->artisan('migrate', ['--database' => 'testbench'])->run();

Schema::table('users', function ($table) {
$table->string('two_factor_secret')->nullable();
$table->timestamp('two_factor_confirmed_at')->nullable();
});
}

protected function getEnvironmentSetUp($app)
{
parent::getEnvironmentSetUp($app);
Expand Down