Skip to content

Commit 1e19e02

Browse files
committed
Fix integration tests to properly account for the rule position in the API
1 parent f293c73 commit 1e19e02

File tree

9 files changed

+14
-13
lines changed

9 files changed

+14
-13
lines changed

tests/Integration/Api/Client/AccountControllerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function testEmailIsNotUpdatedWhenNotValid()
8585
]);
8686

8787
$response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY);
88-
$response->assertJsonPath('errors.0.code', 'required');
88+
$response->assertJsonPath('errors.0.meta.rule', 'required');
8989
$response->assertJsonPath('errors.0.detail', 'The email field is required.');
9090

9191
$response = $this->actingAs($user)->putJson('/api/client/account/email', [
@@ -94,7 +94,7 @@ public function testEmailIsNotUpdatedWhenNotValid()
9494
]);
9595

9696
$response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY);
97-
$response->assertJsonPath('errors.0.code', 'email');
97+
$response->assertJsonPath('errors.0.meta.rule', 'email');
9898
$response->assertJsonPath('errors.0.detail', 'The email must be a valid email address.');
9999
}
100100

@@ -156,7 +156,7 @@ public function testErrorIsReturnedIfPasswordIsNotConfirmed()
156156
]);
157157

158158
$response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY);
159-
$response->assertJsonPath('errors.0.code', 'confirmed');
159+
$response->assertJsonPath('errors.0.meta.rule', 'confirmed');
160160
$response->assertJsonPath('errors.0.detail', 'The password confirmation does not match.');
161161
}
162162
}

tests/Integration/Api/Client/ApiKeyControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public function testValidationErrorIsReturnedForBadRequests()
133133
]);
134134

135135
$response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY);
136-
$response->assertJsonPath('errors.0.code', 'required');
136+
$response->assertJsonPath('errors.0.meta.rule', 'required');
137137
$response->assertJsonPath('errors.0.detail', 'The description field is required.');
138138
}
139139

tests/Integration/Api/Client/Server/CommandControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function testValidationErrorIsReturnedIfNoCommandIsPresent()
4141
]);
4242

4343
$response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY);
44-
$response->assertJsonPath('errors.0.code', 'required');
44+
$response->assertJsonPath('errors.0.meta.rule', 'required');
4545
}
4646

4747
/**

tests/Integration/Api/Client/Server/NetworkAllocationControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function testAllocationNotesCanBeUpdated(array $permissions)
6363

6464
$this->actingAs($user)->postJson($this->link($allocation), [])
6565
->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY)
66-
->assertJsonPath('errors.0.code', 'present');
66+
->assertJsonPath('errors.0.meta.rule', 'present');
6767

6868
$this->actingAs($user)->postJson($this->link($allocation), ['notes' => 'Test notes'])
6969
->assertOk()

tests/Integration/Api/Client/Server/PowerControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function testInvalidPowerSignalResultsInError()
4040
]);
4141

4242
$response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY);
43-
$response->assertJsonPath('errors.0.code', 'in');
43+
$response->assertJsonPath('errors.0.meta.rule', 'in');
4444
$response->assertJsonPath('errors.0.detail', 'The selected signal is invalid.');
4545
}
4646

tests/Integration/Api/Client/Server/Schedule/CreateServerScheduleTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function testScheduleValidationRules()
7171
'day_of_week' => '*',
7272
])
7373
->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY)
74-
->assertJsonPath('errors.0.code', 'boolean');
74+
->assertJsonPath('errors.0.meta.rule', 'boolean');
7575
}
7676

7777
/**

tests/Integration/Api/Client/Server/ScheduleTask/CreateServerScheduleTaskTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,15 @@ public function testValidationErrorsAreReturned()
6666
'time_offset' => 0,
6767
])
6868
->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY)
69-
->assertJsonPath('errors.0.code', 'in')
69+
->assertJsonPath('errors.0.meta.rule', 'in')
7070
->assertJsonPath('errors.0.source.field', 'action');
7171

7272
$this->actingAs($user)->postJson($this->link($schedule, '/tasks'), [
7373
'action' => 'command',
7474
'time_offset' => 0,
7575
])
7676
->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY)
77-
->assertJsonPath('errors.0.code', 'required_unless')
77+
->assertJsonPath('errors.0.meta.rule', 'required_unless')
7878
->assertJsonPath('errors.0.source.field', 'payload');
7979

8080
$this->actingAs($user)->postJson($this->link($schedule, '/tasks'), [
@@ -84,7 +84,7 @@ public function testValidationErrorsAreReturned()
8484
'sequence_id' => 'hodor',
8585
])
8686
->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY)
87-
->assertJsonPath('errors.0.code', 'numeric')
87+
->assertJsonPath('errors.0.meta.rule', 'numeric')
8888
->assertJsonPath('errors.0.source.field', 'sequence_id');
8989
}
9090

tests/Integration/Api/Client/Server/SettingsControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function testServerNameCanBeChanged($permissions)
2828
]);
2929

3030
$response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY);
31-
$response->assertJsonPath('errors.0.code', 'required');
31+
$response->assertJsonPath('errors.0.meta.rule', 'required');
3232

3333
$server = $server->refresh();
3434
$this->assertSame($originalName, $server->name);

tests/Integration/Api/Client/TwoFactorControllerTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ public function testValidationErrorIsReturnedIfInvalidDataIsPassedToEnabled2FA()
6464
]);
6565

6666
$response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY);
67-
$response->assertJsonPath('errors.0.code', 'required');
67+
$response->assertJsonPath('errors.0.code', 'ValidationException');
68+
$response->assertJsonPath('errors.0.meta.rule', 'required');
6869
}
6970

7071
/**

0 commit comments

Comments
 (0)