Skip to content

Commit 5466ddc

Browse files
Remove unused /api/v1/manageMeasurements.php endpoint (Kitware#3658)
GraphQL mutations should be used to manipulate pinned test measurements instead.
1 parent 839378e commit 5466ddc

5 files changed

Lines changed: 9 additions & 273 deletions

File tree

app/Http/Controllers/ManageMeasurementsController.php

Lines changed: 0 additions & 119 deletions
This file was deleted.

app/cdash/tests/test_managemeasurements.php

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use App\Models\PinnedTestMeasurement;
1111
use App\Utils\DatabaseCleanupUtils;
1212
use CDash\Database;
13-
use GuzzleHttp\Exception\ClientException;
1413

1514
class ManageMeasurementsTestCase extends KWWebTestCase
1615
{
@@ -154,46 +153,18 @@ public function testManageMeasurements()
154153
$this->PDO->execute($stmt, [':buildid' => $this->BuildId]);
155154
$this->assertEqual(12.13, $stmt->fetchColumn());
156155

157-
// Login as admin.
158-
$client = $this->getGuzzleClient();
159-
160-
// POST to manageMeasurements.php to add 'Processors', 'I/O Wait Time',
161-
// and 'Peak Memory' as test measurements for these projects.
156+
// Add 'Processors', 'I/O Wait Time', and 'Peak Memory' as test measurements for these projects.
162157
$this->ProjectId = get_project_id('InsightExample');
163158
$this->SubProjectId = get_project_id('SubProjectExample');
164159
$new_measurements = ['Processors', 'I/O Wait Time', 'Peak Memory'];
165160
$idx = 1;
166161
foreach ($new_measurements as $new_measurement) {
167162
foreach ([$this->ProjectId, $this->SubProjectId] as $projectid) {
168-
$measurements = [];
169-
$measurements[] = [
170-
'id' => -1,
163+
PinnedTestMeasurement::create([
164+
'projectid' => $projectid,
171165
'name' => $new_measurement,
172166
'position' => $idx,
173-
];
174-
try {
175-
$response = $client->request('POST',
176-
$this->url . '/api/v1/manageMeasurements.php',
177-
['json' => ['projectid' => $projectid, 'measurements' => $measurements]]);
178-
} catch (ClientException $e) {
179-
$this->fail($e->getMessage());
180-
return false;
181-
}
182-
183-
// Response should have the ID of the newly created measurement.
184-
$response_array = json_decode($response->getBody(), true);
185-
$measurement_id = $response_array['id'];
186-
if (!$measurement_id > 0) {
187-
$this->fail("Expected positive integer for measurement ID, found $measurement_id");
188-
}
189-
$this->MeasurementIds[] = $measurement_id;
190-
// Check that the measurement actually got added to the database.
191-
$stmt = $this->PDO->query(
192-
"SELECT id FROM measurement WHERE id = $measurement_id");
193-
$found = $stmt->fetchColumn();
194-
if ($found != $measurement_id) {
195-
$this->fail("Expected $measurement_id but found $found for DB measurement ID");
196-
}
167+
]);
197168
}
198169
$idx++;
199170
}

app/cdash/tests/test_redundanttests.php

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
require_once __DIR__ . '/cdash_test_case.php';
44

5+
use App\Models\PinnedTestMeasurement;
56
use CDash\Model\Project;
6-
use GuzzleHttp\Exception\ClientException;
77
use Illuminate\Support\Facades\DB;
88

99
class RedundantTestsTestCase extends KWWebTestCase
@@ -26,7 +26,7 @@ public function __destruct()
2626
}
2727
}
2828

29-
public function testRedundantTests()
29+
public function testRedundantTests(): void
3030
{
3131
// Create test project.
3232
$this->login();
@@ -38,21 +38,11 @@ public function testRedundantTests()
3838
$this->project->Fill();
3939

4040
// Add 'color' as a custom test measurement for this project.
41-
$client = $this->getGuzzleClient();
42-
$measurements = [];
43-
$measurements[] = [
44-
'id' => -1,
41+
PinnedTestMeasurement::create([
42+
'projectid' => $this->project->Id,
4543
'name' => 'color',
4644
'position' => 1,
47-
];
48-
try {
49-
$client->request('POST',
50-
$this->url . '/api/v1/manageMeasurements.php',
51-
['json' => ['projectid' => $this->project->Id, 'measurements' => $measurements]]);
52-
} catch (ClientException $e) {
53-
$this->fail($e->getMessage());
54-
return false;
55-
}
45+
]);
5646

5747
// Submit our testing data.
5848
if (!$this->submission('RedundantTests', __DIR__ . '/data/RedundantTests/Test.xml')) {

phpstan-baseline.neon

Lines changed: 0 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -843,78 +843,6 @@ parameters:
843843
count: 1
844844
path: app/Http/Controllers/IndexController.php
845845

846-
-
847-
rawMessage: 'Call to an undefined method App\Models\Project|Illuminate\Database\Eloquent\Collection<int, App\Models\Project>::pinnedTestMeasurements().'
848-
identifier: method.notFound
849-
count: 2
850-
path: app/Http/Controllers/ManageMeasurementsController.php
851-
852-
-
853-
rawMessage: Cannot access offset 'id' on mixed.
854-
identifier: offsetAccess.nonOffsetAccessible
855-
count: 1
856-
path: app/Http/Controllers/ManageMeasurementsController.php
857-
858-
-
859-
rawMessage: Cannot access offset 'name' on mixed.
860-
identifier: offsetAccess.nonOffsetAccessible
861-
count: 1
862-
path: app/Http/Controllers/ManageMeasurementsController.php
863-
864-
-
865-
rawMessage: Cannot access offset 'position' on mixed.
866-
identifier: offsetAccess.nonOffsetAccessible
867-
count: 1
868-
path: app/Http/Controllers/ManageMeasurementsController.php
869-
870-
-
871-
rawMessage: Cannot access property $id on App\Models\PinnedTestMeasurement|null.
872-
identifier: property.nonObject
873-
count: 1
874-
path: app/Http/Controllers/ManageMeasurementsController.php
875-
876-
-
877-
rawMessage: Cannot access property $name on App\Models\PinnedTestMeasurement|null.
878-
identifier: property.nonObject
879-
count: 1
880-
path: app/Http/Controllers/ManageMeasurementsController.php
881-
882-
-
883-
rawMessage: Cannot access property $position on App\Models\PinnedTestMeasurement|null.
884-
identifier: property.nonObject
885-
count: 1
886-
path: app/Http/Controllers/ManageMeasurementsController.php
887-
888-
-
889-
rawMessage: Cannot access property $projectid on App\Models\PinnedTestMeasurement|null.
890-
identifier: property.nonObject
891-
count: 1
892-
path: app/Http/Controllers/ManageMeasurementsController.php
893-
894-
-
895-
rawMessage: 'Cannot call method save() on App\Models\PinnedTestMeasurement|null.'
896-
identifier: method.nonObject
897-
count: 1
898-
path: app/Http/Controllers/ManageMeasurementsController.php
899-
900-
-
901-
rawMessage: Cannot cast mixed to int.
902-
identifier: cast.int
903-
count: 4
904-
path: app/Http/Controllers/ManageMeasurementsController.php
905-
906-
-
907-
rawMessage: 'Only booleans are allowed in an if condition, int|null given.'
908-
identifier: if.condNotBoolean
909-
count: 1
910-
path: app/Http/Controllers/ManageMeasurementsController.php
911-
912-
-
913-
rawMessage: 'Only booleans are allowed in an if condition, mixed given.'
914-
identifier: if.condNotBoolean
915-
count: 1
916-
path: app/Http/Controllers/ManageMeasurementsController.php
917-
918846
-
919847
rawMessage: 'Binary operation "-" between int<1, max> and mixed results in an error.'
920848
identifier: binaryOp.invalid
@@ -19941,12 +19869,6 @@ parameters:
1994119869
count: 2
1994219870
path: app/cdash/tests/test_managemeasurements.php
1994319871

19944-
-
19945-
rawMessage: Cannot access offset 'id' on mixed.
19946-
identifier: offsetAccess.nonOffsetAccessible
19947-
count: 1
19948-
path: app/cdash/tests/test_managemeasurements.php
19949-
1995019872
-
1995119873
rawMessage: Cannot access offset 'label' on mixed.
1995219874
identifier: offsetAccess.nonOffsetAccessible
@@ -20037,12 +19959,6 @@ parameters:
2003719959
count: 5
2003819960
path: app/cdash/tests/test_managemeasurements.php
2003919961

20040-
-
20041-
rawMessage: 'Loose comparison via "!=" between mixed and mixed is not allowed.'
20042-
identifier: notEqual.notAllowed
20043-
count: 1
20044-
path: app/cdash/tests/test_managemeasurements.php
20045-
2004619962
-
2004719963
rawMessage: 'Loose comparison via "!=" between string and float is not allowed.'
2004819964
identifier: notEqual.notAllowed
@@ -20121,12 +20037,6 @@ parameters:
2012120037
count: 1
2012220038
path: app/cdash/tests/test_managemeasurements.php
2012320039

20124-
-
20125-
rawMessage: 'Only booleans are allowed in a negated boolean, mixed given.'
20126-
identifier: booleanNot.exprNotBoolean
20127-
count: 1
20128-
path: app/cdash/tests/test_managemeasurements.php
20129-
2013020040
-
2013120041
rawMessage: 'Parameter #1 $array of function array_pop expects array, mixed given.'
2013220042
identifier: argument.type
@@ -20151,12 +20061,6 @@ parameters:
2015120061
count: 2
2015220062
path: app/cdash/tests/test_managemeasurements.php
2015320063

20154-
-
20155-
rawMessage: 'Part $measurement_id (mixed) of encapsed string cannot be cast to string.'
20156-
identifier: encapsedStringPart.nonString
20157-
count: 3
20158-
path: app/cdash/tests/test_managemeasurements.php
20159-
2016020064
-
2016120065
rawMessage: 'Part $selected_test_name (mixed) of encapsed string cannot be cast to string.'
2016220066
identifier: encapsedStringPart.nonString
@@ -21888,12 +21792,6 @@ parameters:
2188821792
count: 1
2188921793
path: app/cdash/tests/test_redundanttests.php
2189021794

21891-
-
21892-
rawMessage: 'Method RedundantTestsTestCase::testRedundantTests() has no return type specified.'
21893-
identifier: missingType.return
21894-
count: 1
21895-
path: app/cdash/tests/test_redundanttests.php
21896-
2189721795
-
2189821796
rawMessage: 'Parameter #1 $value of function count expects array|Countable, mixed given.'
2189921797
identifier: argument.type

routes/api.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@
5252
Route::middleware(['auth'])->group(function (): void {
5353
Route::get('/v1/manageSubProject.php', 'SubProjectController@apiManageSubProject');
5454

55-
Route::get('/v1/manageMeasurements.php', 'ManageMeasurementsController@apiGet');
56-
Route::post('/v1/manageMeasurements.php', 'ManageMeasurementsController@apiPost');
57-
Route::delete('/v1/manageMeasurements.php', 'ManageMeasurementsController@apiDelete');
58-
5955
Route::match(['get', 'post'], '/v1/manageOverview.php', 'ProjectOverviewController@apiManageOverview');
6056

6157
Route::middleware(['admin'])->group(function (): void {

0 commit comments

Comments
 (0)