forked from laravel/jetstream
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathUpdateTeamTest.php
69 lines (50 loc) · 1.65 KB
/
UpdateTeamTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
namespace Laravel\Jetstream\Tests;
use App\Actions\Jetstream\CreateTeam;
use App\Actions\Jetstream\UpdateTeamName;
use App\Models\Team;
use Illuminate\Support\Facades\Gate;
use Illuminate\Validation\ValidationException;
use Laravel\Jetstream\Jetstream;
use Laravel\Jetstream\Tests\Fixtures\TeamPolicy;
use Laravel\Jetstream\Tests\Fixtures\User;
class UpdateTeamTest extends OrchestraTestCase
{
public function setUp(): void
{
parent::setUp();
Gate::policy(Team::class, TeamPolicy::class);
Jetstream::useUserModel(User::class);
}
public function test_team_name_can_be_updated()
{
$this->migrate();
$team = $this->createTeam();
$action = new UpdateTeamName;
$action->update($team->owner, $team, ['name' => 'Test Team Updated']);
$this->assertSame('Test Team Updated', $team->fresh()->name);
}
public function test_name_is_required()
{
$this->expectException(ValidationException::class);
$this->migrate();
$team = $this->createTeam();
$action = new UpdateTeamName;
$action->update($team->owner, $team, ['name' => '']);
}
protected function createTeam()
{
$action = new CreateTeam;
$user = User::forceCreate([
'name' => 'Taylor Otwell',
'email' => 'taylor@laravel.com',
'password' => 'secret',
]);
return $action->create($user, ['name' => 'Test Team']);
}
protected function migrate()
{
// $this->loadLaravelMigrations(['--database' => 'testbench']);
$this->artisan('migrate', ['--database' => 'testbench'])->run();
}
}