Skip to content

Commit 7063d61

Browse files
committed
chore(laravel): fix phpstan errors in policy test (#8870)
1 parent 34b8bfd commit 7063d61

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

‎src/Laravel/Tests/Policy/PolicyBeforeDeserializationTest.php‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ protected function defineEnvironment($app): void
4141

4242
public function testPatchPolicyIsEvaluatedOnTheStoredRecord(): void
4343
{
44-
$owner = UserFactory::new()->create();
45-
$attacker = UserFactory::new()->create();
46-
$note = OwnedNoteFactory::new()->create(['user_id' => $owner->getKey(), 'title' => 'original']);
44+
$owner = UserFactory::new()->createOne();
45+
$attacker = UserFactory::new()->createOne();
46+
$note = OwnedNoteFactory::new()->createOne(['user_id' => $owner->getKey(), 'title' => 'original']);
4747

4848
$response = $this->actingAs($attacker)->patchJson(
4949
'/api/owned_notes/'.$note->getKey(),
@@ -55,14 +55,14 @@ public function testPatchPolicyIsEvaluatedOnTheStoredRecord(): void
5555
);
5656

5757
$response->assertStatus(403);
58-
$stored = OwnedNote::findOrFail($note->getKey());
59-
$this->assertSame($owner->getKey(), $stored->user_id);
60-
$this->assertSame('original', $stored->title);
58+
$note->refresh();
59+
$this->assertSame($owner->getKey(), $note->getAttribute('user_id'));
60+
$this->assertSame('original', $note->getAttribute('title'));
6161
}
6262

6363
public function testGraphQlCreateMutationUsesTheCreatePolicy(): void
6464
{
65-
$user = UserFactory::new()->create();
65+
$user = UserFactory::new()->createOne();
6666

6767
$response = $this->actingAs($user)->postJson('/api/graphql', ['query' => \sprintf('mutation {
6868
createOwnedNote(input: {title: "x", userId: %d}) {

0 commit comments

Comments
 (0)