From ced6075514b9819599a827f5391ce848c84dadba Mon Sep 17 00:00:00 2001 From: Pirmin Mattmann Date: Tue, 27 Jun 2023 21:23:23 +0200 Subject: [PATCH] testSqlQueryCount Get Entity and Get Collection --- api/tests/Api/Activities/ListActivitiesTest.php | 8 ++++++++ api/tests/Api/Activities/ReadActivityTest.php | 11 +++++++++++ .../ListActivityProgressLabelTest.php | 8 ++++++++ .../ReadActivityProgressLabelTest.php | 11 +++++++++++ .../ListActivityResponsiblesTest.php | 8 ++++++++ .../ReadActivityResponsibleTest.php | 11 +++++++++++ .../ListCampCollaborationsTest.php | 8 ++++++++ .../CampCollaborations/ReadCampCollaborationTest.php | 11 +++++++++++ api/tests/Api/Camps/ListCampsTest.php | 8 ++++++++ api/tests/Api/Camps/ReadCampTest.php | 11 +++++++++++ api/tests/Api/Categories/ListCategoriesTest.php | 8 ++++++++ api/tests/Api/Categories/ReadCategoryTest.php | 11 +++++++++++ api/tests/Api/ContentTypes/ListContentTypesTest.php | 8 ++++++++ api/tests/Api/ContentTypes/ReadContentTypeTest.php | 11 +++++++++++ .../Api/DayResponsibles/ListDayResponsiblesTest.php | 8 ++++++++ .../Api/DayResponsibles/ReadDayResponsibleTest.php | 11 +++++++++++ api/tests/Api/Days/ListDaysTest.php | 8 ++++++++ api/tests/Api/Days/ReadDayTest.php | 11 +++++++++++ api/tests/Api/ECampApiTestCase.php | 12 ++++++++++++ .../Api/MaterialItems/ListMaterialItemsTest.php | 8 ++++++++ api/tests/Api/MaterialItems/ReadMaterialItemTest.php | 11 +++++++++++ .../Api/MaterialLists/ListMaterialListsTest.php | 8 ++++++++ api/tests/Api/MaterialLists/ReadMaterialListTest.php | 11 +++++++++++ api/tests/Api/Periods/ListPeriodsTest.php | 8 ++++++++ api/tests/Api/Periods/ReadPeriodTest.php | 11 +++++++++++ api/tests/Api/Profiles/ListProfilesTest.php | 8 ++++++++ api/tests/Api/Profiles/ReadProfileTest.php | 11 +++++++++++ .../Api/ScheduleEntries/ListScheduleEntriesTest.php | 8 ++++++++ .../Api/ScheduleEntries/ReadScheduleEntryTest.php | 11 +++++++++++ api/tests/Api/Users/ListUsersTest.php | 8 ++++++++ api/tests/Api/Users/ReadUserTest.php | 11 +++++++++++ 31 files changed, 297 insertions(+) diff --git a/api/tests/Api/Activities/ListActivitiesTest.php b/api/tests/Api/Activities/ListActivitiesTest.php index 0d4a4b7d80..3640feb712 100644 --- a/api/tests/Api/Activities/ListActivitiesTest.php +++ b/api/tests/Api/Activities/ListActivitiesTest.php @@ -88,4 +88,12 @@ public function testListActivitiesFilteredByCampPrototypeIsAllowedForUnrelatedUs ['href' => $this->getIriFor('activity1campPrototype')], ], $response->toArray()['_links']['items']); } + + public function testSqlQueryCount() { + $client = static::createClientWithCredentials(); + $client->enableProfiler(); + $client->request('GET', '/activities'); + + $this->assertSqlQueryCount($client, 19); + } } diff --git a/api/tests/Api/Activities/ReadActivityTest.php b/api/tests/Api/Activities/ReadActivityTest.php index de37c967de..2a97014ecf 100644 --- a/api/tests/Api/Activities/ReadActivityTest.php +++ b/api/tests/Api/Activities/ReadActivityTest.php @@ -132,4 +132,15 @@ public function testGetSingleActivityFromCampPrototypeIsAllowedForUnrelatedUser( ], ]); } + + public function testSqlQueryCount() { + /** @var Activity $activity */ + $activity = static::$fixtures['activity1']; + + $client = static::createClientWithCredentials(); + $client->enableProfiler(); + $client->request('GET', '/activities/'.$activity->getId()); + + $this->assertSqlQueryCount($client, 29); + } } diff --git a/api/tests/Api/ActivityProgressLabel/ListActivityProgressLabelTest.php b/api/tests/Api/ActivityProgressLabel/ListActivityProgressLabelTest.php index 56d7b35336..9cddad816c 100644 --- a/api/tests/Api/ActivityProgressLabel/ListActivityProgressLabelTest.php +++ b/api/tests/Api/ActivityProgressLabel/ListActivityProgressLabelTest.php @@ -76,4 +76,12 @@ public function testListActivityProgressLabelsFilteredByCampIsDeniedForUnrelated $this->assertJsonContains(['totalItems' => 0]); $this->assertArrayNotHasKey('items', $response->toArray()['_links']); } + + public function testSqlQueryCount() { + $client = static::createClientWithCredentials(); + $client->enableProfiler(); + $client->request('GET', '/activity_progress_labels'); + + $this->assertSqlQueryCount($client, 4); + } } diff --git a/api/tests/Api/ActivityProgressLabel/ReadActivityProgressLabelTest.php b/api/tests/Api/ActivityProgressLabel/ReadActivityProgressLabelTest.php index 5bbed70623..ceb1228855 100644 --- a/api/tests/Api/ActivityProgressLabel/ReadActivityProgressLabelTest.php +++ b/api/tests/Api/ActivityProgressLabel/ReadActivityProgressLabelTest.php @@ -92,4 +92,15 @@ public function testGetSingleActivityProgressLabelIsAllowedForManager() { ], ]); } + + public function testSqlQueryCount() { + /** @var ActivityProgressLabel $activityProgressLabel */ + $activityProgressLabel = static::$fixtures['activityProgressLabel1']; + + $client = static::createClientWithCredentials(); + $client->enableProfiler(); + $client->request('GET', '/activity_progress_labels/'.$activityProgressLabel->getId()); + + $this->assertSqlQueryCount($client, 5); + } } diff --git a/api/tests/Api/ActivityResponsibles/ListActivityResponsiblesTest.php b/api/tests/Api/ActivityResponsibles/ListActivityResponsiblesTest.php index 70b8bd593e..4479a3ce11 100644 --- a/api/tests/Api/ActivityResponsibles/ListActivityResponsiblesTest.php +++ b/api/tests/Api/ActivityResponsibles/ListActivityResponsiblesTest.php @@ -135,4 +135,12 @@ public function testListActivityResponsiblesFilteredByCampPrototypeIsAllowedForU ['href' => $this->getIriFor('activityResponsible1campPrototype')], ], $response->toArray()['_links']['items']); } + + public function testSqlQueryCount() { + $client = static::createClientWithCredentials(); + $client->enableProfiler(); + $client->request('GET', '/activity_responsibles'); + + $this->assertSqlQueryCount($client, 4); + } } diff --git a/api/tests/Api/ActivityResponsibles/ReadActivityResponsibleTest.php b/api/tests/Api/ActivityResponsibles/ReadActivityResponsibleTest.php index 9fbc76d6ca..40e025ad47 100644 --- a/api/tests/Api/ActivityResponsibles/ReadActivityResponsibleTest.php +++ b/api/tests/Api/ActivityResponsibles/ReadActivityResponsibleTest.php @@ -105,4 +105,15 @@ public function testGetSingleActivityResponsibleFromCampPrototypeIsAllowedForUnr ], ]); } + + public function testSqlQueryCount() { + /** @var ActivityResponsible $activityResponsible */ + $activityResponsible = static::$fixtures['activityResponsible1campPrototype']; + + $client = static::createClientWithCredentials(); + $client->enableProfiler(); + $client->request('GET', '/activity_responsibles/'.$activityResponsible->getId()); + + $this->assertSqlQueryCount($client, 6); + } } diff --git a/api/tests/Api/CampCollaborations/ListCampCollaborationsTest.php b/api/tests/Api/CampCollaborations/ListCampCollaborationsTest.php index 7e215054a7..bf18c8d45e 100644 --- a/api/tests/Api/CampCollaborations/ListCampCollaborationsTest.php +++ b/api/tests/Api/CampCollaborations/ListCampCollaborationsTest.php @@ -108,4 +108,12 @@ public function testListCampCollaborationsFilteredByCampPrototypeIsAllowedForUnr ['href' => $this->getIriFor('campCollaboration1campPrototype')], ], $response->toArray()['_links']['items']); } + + public function testSqlQueryCount() { + $client = static::createClientWithCredentials(); + $client->enableProfiler(); + $client->request('GET', '/camp_collaborations'); + + $this->assertSqlQueryCount($client, 23); + } } diff --git a/api/tests/Api/CampCollaborations/ReadCampCollaborationTest.php b/api/tests/Api/CampCollaborations/ReadCampCollaborationTest.php index f3c8f1e040..269b36f332 100644 --- a/api/tests/Api/CampCollaborations/ReadCampCollaborationTest.php +++ b/api/tests/Api/CampCollaborations/ReadCampCollaborationTest.php @@ -117,4 +117,15 @@ public function testGetSingleCampCollaborationFromCampPrototypeIsAllowedForUnrel ], ]); } + + public function testSqlQueryCount() { + /** @var CampCollaboration $campCollaboration */ + $campCollaboration = static::$fixtures['campCollaboration1manager']; + + $client = static::createClientWithCredentials(); + $client->enableProfiler(); + $client->request('GET', '/camp_collaborations/'.$campCollaboration->getId()); + + $this->assertSqlQueryCount($client, 13); + } } diff --git a/api/tests/Api/Camps/ListCampsTest.php b/api/tests/Api/Camps/ListCampsTest.php index 2b2e4dda79..8af8194319 100644 --- a/api/tests/Api/Camps/ListCampsTest.php +++ b/api/tests/Api/Camps/ListCampsTest.php @@ -71,4 +71,12 @@ public function testListCampsDoesNotShowCampToInactiveCollaborator() { ['href' => $this->getIriFor('campPrototype')], ], $response->toArray()['_links']['items']); } + + public function testSqlQueryCount() { + $client = static::createClientWithCredentials(); + $client->enableProfiler(); + $client->request('GET', '/camps'); + + $this->assertSqlQueryCount($client, 27); + } } diff --git a/api/tests/Api/Camps/ReadCampTest.php b/api/tests/Api/Camps/ReadCampTest.php index bf21263ff0..c730b11bf0 100644 --- a/api/tests/Api/Camps/ReadCampTest.php +++ b/api/tests/Api/Camps/ReadCampTest.php @@ -211,4 +211,15 @@ public function testGetSingleCampEmbedsCampCollaborationsAndItsUser() { ], ]); } + + public function testSqlQueryCount() { + /** @var Camp $camp */ + $camp = static::$fixtures['camp1']; + + $client = static::createClientWithCredentials(); + $client->enableProfiler(); + $client->request('GET', '/camps/'.$camp->getId()); + + $this->assertSqlQueryCount($client, 26); + } } diff --git a/api/tests/Api/Categories/ListCategoriesTest.php b/api/tests/Api/Categories/ListCategoriesTest.php index b22bdb27a2..917d5e49ec 100644 --- a/api/tests/Api/Categories/ListCategoriesTest.php +++ b/api/tests/Api/Categories/ListCategoriesTest.php @@ -96,4 +96,12 @@ public function testListCategoriesFilteredByCampPrototypeIsAllowedForUnrelatedUs ['href' => $this->getIriFor('category1campPrototype')], ], $response->toArray()['_links']['items']); } + + public function testSqlQueryCount() { + $client = static::createClientWithCredentials(); + $client->enableProfiler(); + $client->request('GET', '/categories'); + + $this->assertSqlQueryCount($client, 9); + } } diff --git a/api/tests/Api/Categories/ReadCategoryTest.php b/api/tests/Api/Categories/ReadCategoryTest.php index 8a5f154658..c37b5cbfa6 100644 --- a/api/tests/Api/Categories/ReadCategoryTest.php +++ b/api/tests/Api/Categories/ReadCategoryTest.php @@ -128,4 +128,15 @@ public function testGetSingleCategoryFromCampPrototypeIsAllowedForUnrelatedUser( ], ]); } + + public function testSqlQueryCount() { + /** @var Category $category */ + $category = static::$fixtures['category1']; + + $client = static::createClientWithCredentials(); + $client->enableProfiler(); + $client->request('GET', '/categories/'.$category->getId()); + + $this->assertSqlQueryCount($client, 7); + } } diff --git a/api/tests/Api/ContentTypes/ListContentTypesTest.php b/api/tests/Api/ContentTypes/ListContentTypesTest.php index d59d8d0b2d..98c0fa7d47 100644 --- a/api/tests/Api/ContentTypes/ListContentTypesTest.php +++ b/api/tests/Api/ContentTypes/ListContentTypesTest.php @@ -38,4 +38,12 @@ public function testListContentTypesIsAllowedForLoggedInUser() { ]); $this->assertCount(7, $response->toArray()['_links']['items']); } + + public function testSqlQueryCount() { + $client = static::createClientWithCredentials(); + $client->enableProfiler(); + $client->request('GET', '/content_types'); + + $this->assertSqlQueryCount($client, 4); + } } diff --git a/api/tests/Api/ContentTypes/ReadContentTypeTest.php b/api/tests/Api/ContentTypes/ReadContentTypeTest.php index 943c06e9a6..27a2f1642a 100644 --- a/api/tests/Api/ContentTypes/ReadContentTypeTest.php +++ b/api/tests/Api/ContentTypes/ReadContentTypeTest.php @@ -42,4 +42,15 @@ public function testGetSingleContentTypeIsAllowedForLoggedInUser() { ], ]); } + + public function testSqlQueryCount() { + /** @var ContentType $contentType */ + $contentType = static::$fixtures['contentTypeSafetyConcept']; + + $client = static::createClientWithCredentials(); + $client->enableProfiler(); + $client->request('GET', '/content_types/'.$contentType->getId()); + + $this->assertSqlQueryCount($client, 4); + } } diff --git a/api/tests/Api/DayResponsibles/ListDayResponsiblesTest.php b/api/tests/Api/DayResponsibles/ListDayResponsiblesTest.php index 36eebdfbd1..2d88705381 100644 --- a/api/tests/Api/DayResponsibles/ListDayResponsiblesTest.php +++ b/api/tests/Api/DayResponsibles/ListDayResponsiblesTest.php @@ -101,4 +101,12 @@ public function testListDayResponsiblesFilteredByDayInCampPrototypeIsAllowedForU ['href' => $this->getIriFor('dayResponsible1day1period1campPrototype')], ], $response->toArray()['_links']['items']); } + + public function testSqlQueryCount() { + $client = static::createClientWithCredentials(); + $client->enableProfiler(); + $client->request('GET', '/day_responsibles'); + + $this->assertSqlQueryCount($client, 4); + } } diff --git a/api/tests/Api/DayResponsibles/ReadDayResponsibleTest.php b/api/tests/Api/DayResponsibles/ReadDayResponsibleTest.php index a75a176330..5300da58c4 100644 --- a/api/tests/Api/DayResponsibles/ReadDayResponsibleTest.php +++ b/api/tests/Api/DayResponsibles/ReadDayResponsibleTest.php @@ -105,4 +105,15 @@ public function testGetSingleDayResponsibleInCampPrototypeIsAllowedForUnrelatedU ], ]); } + + public function testSqlQueryCount() { + /** @var DayResponsible $dayResponsible */ + $dayResponsible = static::$fixtures['dayResponsible1']; + + $client = static::createClientWithCredentials(); + $client->enableProfiler(); + $client->request('GET', '/day_responsibles/'.$dayResponsible->getId()); + + $this->assertSqlQueryCount($client, 7); + } } diff --git a/api/tests/Api/Days/ListDaysTest.php b/api/tests/Api/Days/ListDaysTest.php index c2afd082e7..87287bb3fb 100644 --- a/api/tests/Api/Days/ListDaysTest.php +++ b/api/tests/Api/Days/ListDaysTest.php @@ -122,4 +122,12 @@ public function testListDaysFilteredByPeriodInCampPrototypeIsAllowedForCollabora ['href' => $this->getIriFor('day1period1campPrototype')], ], $response->toArray()['_links']['items']); } + + public function testSqlQueryCount() { + $client = static::createClientWithCredentials(); + $client->enableProfiler(); + $client->request('GET', '/days'); + + $this->assertSqlQueryCount($client, 15); + } } diff --git a/api/tests/Api/Days/ReadDayTest.php b/api/tests/Api/Days/ReadDayTest.php index f737aeab36..d8934df178 100644 --- a/api/tests/Api/Days/ReadDayTest.php +++ b/api/tests/Api/Days/ReadDayTest.php @@ -165,4 +165,15 @@ public function testDatesFormatProperlyInTimezoneBehindUTC() { 'end' => '2023-05-02T00:00:00+00:00', ]); } + + public function testSqlQueryCount() { + /** @var Day $day */ + $day = static::$fixtures['day1period1']; + + $client = static::createClientWithCredentials(); + $client->enableProfiler(); + $client->request('GET', '/days/'.$day->getId()); + + $this->assertSqlQueryCount($client, 9); + } } diff --git a/api/tests/Api/ECampApiTestCase.php b/api/tests/Api/ECampApiTestCase.php index ad33155591..d8c2b31272 100644 --- a/api/tests/Api/ECampApiTestCase.php +++ b/api/tests/Api/ECampApiTestCase.php @@ -16,6 +16,7 @@ use App\Entity\User; use App\Metadata\Resource\OperationHelper; use App\Repository\ProfileRepository; +use Doctrine\Bundle\DoctrineBundle\DataCollector\DoctrineDataCollector; use Doctrine\ORM\EntityManagerInterface; use Hautelook\AliceBundle\PhpUnit\RefreshDatabaseTrait; use Symfony\Component\BrowserKit\Cookie; @@ -297,4 +298,15 @@ protected function assertJsonSchemaError(ResponseInterface $response, string $pr $this->assertEquals($propertyName, $responseArray['violations'][0]['propertyPath']); $this->assertStringStartsWith('Provided JSON doesn\'t match required schema', $responseArray['violations'][0]['message']); } + + /** + * Validates the number of executed SqlQueries. + * requieres $client->enableProfiler(). + */ + protected function assertSqlQueryCount(Client $client, int $expected) { + /** @var DoctrineDataCollector $collector */ + $collector = $client->getProfile()->getCollector('db'); + + $this->assertEquals($expected, $collector->getQueryCount()); + } } diff --git a/api/tests/Api/MaterialItems/ListMaterialItemsTest.php b/api/tests/Api/MaterialItems/ListMaterialItemsTest.php index bd7f08f043..0668610fc2 100644 --- a/api/tests/Api/MaterialItems/ListMaterialItemsTest.php +++ b/api/tests/Api/MaterialItems/ListMaterialItemsTest.php @@ -164,4 +164,12 @@ public function testListMaterialItemsFilteredByPeriodInCampPrototypeIsAllowedFor ['href' => $this->getIriFor('materialItem1period1campPrototype')], ], $response->toArray()['_links']['items']); } + + public function testSqlQueryCount() { + $client = static::createClientWithCredentials(); + $client->enableProfiler(); + $client->request('GET', '/material_items'); + + $this->assertSqlQueryCount($client, 4); + } } diff --git a/api/tests/Api/MaterialItems/ReadMaterialItemTest.php b/api/tests/Api/MaterialItems/ReadMaterialItemTest.php index 9cc0fd2464..8395d23501 100644 --- a/api/tests/Api/MaterialItems/ReadMaterialItemTest.php +++ b/api/tests/Api/MaterialItems/ReadMaterialItemTest.php @@ -121,4 +121,15 @@ public function testGetSingleMaterialItemInCampPrototypeIsAllowedForUnrelatedUse ], ]); } + + public function testSqlQueryCount() { + /** @var MaterialItem $materialItem */ + $materialItem = static::$fixtures['materialItem1']; + + $client = static::createClientWithCredentials(); + $client->enableProfiler(); + $client->request('GET', '/material_items/'.$materialItem->getId()); + + $this->assertSqlQueryCount($client, 6); + } } diff --git a/api/tests/Api/MaterialLists/ListMaterialListsTest.php b/api/tests/Api/MaterialLists/ListMaterialListsTest.php index 56c0ff63b8..b12cbc3780 100644 --- a/api/tests/Api/MaterialLists/ListMaterialListsTest.php +++ b/api/tests/Api/MaterialLists/ListMaterialListsTest.php @@ -102,4 +102,12 @@ public function testListMaterialListsFilteredByCampPrototypeIsAllowedForUnrelate ['href' => $this->getIriFor('materialList1campPrototype')], ], $response->toArray()['_links']['items']); } + + public function testSqlQueryCount() { + $client = static::createClientWithCredentials(); + $client->enableProfiler(); + $client->request('GET', '/material_lists'); + + $this->assertSqlQueryCount($client, 4); + } } diff --git a/api/tests/Api/MaterialLists/ReadMaterialListTest.php b/api/tests/Api/MaterialLists/ReadMaterialListTest.php index afab246748..10394b792f 100644 --- a/api/tests/Api/MaterialLists/ReadMaterialListTest.php +++ b/api/tests/Api/MaterialLists/ReadMaterialListTest.php @@ -109,4 +109,15 @@ public function testGetSingleMaterialListFromCampPrototypeIsAllowedForUnrelatedU ], ]); } + + public function testSqlQueryCount() { + /** @var MaterialList $materialList */ + $materialList = static::$fixtures['materialList1']; + + $client = static::createClientWithCredentials(); + $client->enableProfiler(); + $client->request('GET', '/material_lists/'.$materialList->getId()); + + $this->assertSqlQueryCount($client, 5); + } } diff --git a/api/tests/Api/Periods/ListPeriodsTest.php b/api/tests/Api/Periods/ListPeriodsTest.php index 66feaf4554..2a43ed9c13 100644 --- a/api/tests/Api/Periods/ListPeriodsTest.php +++ b/api/tests/Api/Periods/ListPeriodsTest.php @@ -94,4 +94,12 @@ public function testListPeriodsFilteredByCampPrototypeIsAllowedForUnrelatedUser( ['href' => $this->getIriFor('period1campPrototype')], ], $response->toArray()['_links']['items']); } + + public function testSqlQueryCount() { + $client = static::createClientWithCredentials(); + $client->enableProfiler(); + $client->request('GET', '/periods'); + + $this->assertSqlQueryCount($client, 4); + } } diff --git a/api/tests/Api/Periods/ReadPeriodTest.php b/api/tests/Api/Periods/ReadPeriodTest.php index 60835247e9..20f8fc0381 100644 --- a/api/tests/Api/Periods/ReadPeriodTest.php +++ b/api/tests/Api/Periods/ReadPeriodTest.php @@ -131,4 +131,15 @@ public function testGetSinglePeriodFromCampPrototypeIsAllowedForUnrelatedUser() ], ]); } + + public function testSqlQueryCount() { + /** @var Period $period */ + $period = static::$fixtures['period1']; + + $client = static::createClientWithCredentials(); + $client->enableProfiler(); + $client->request('GET', '/periods/'.$period->getId()); + + $this->assertSqlQueryCount($client, 17); + } } diff --git a/api/tests/Api/Profiles/ListProfilesTest.php b/api/tests/Api/Profiles/ListProfilesTest.php index 4bc120014c..4ea6de57aa 100644 --- a/api/tests/Api/Profiles/ListProfilesTest.php +++ b/api/tests/Api/Profiles/ListProfilesTest.php @@ -111,4 +111,12 @@ public function testListProfilesFilteredByCampPrototypeIsDeniedForUnrelatedUser( $this->assertJsonContains(['totalItems' => 0]); $this->assertArrayNotHasKey('items', $response->toArray()['_links']); } + + public function testSqlQueryCount() { + $client = static::createClientWithCredentials(); + $client->enableProfiler(); + $client->request('GET', '/profiles'); + + $this->assertSqlQueryCount($client, 4); + } } diff --git a/api/tests/Api/Profiles/ReadProfileTest.php b/api/tests/Api/Profiles/ReadProfileTest.php index a8db3bd506..b141b77270 100644 --- a/api/tests/Api/Profiles/ReadProfileTest.php +++ b/api/tests/Api/Profiles/ReadProfileTest.php @@ -94,4 +94,15 @@ public function testGetSingleProfileIsAllowedForSelfIfSelfHasNoCampCollaboration ], ]); } + + public function testSqlQueryCount() { + /** @var Profile $profile */ + $profile = static::$fixtures['profile2member']; + + $client = static::createClientWithCredentials(); + $client->enableProfiler(); + $client->request('GET', '/profiles/'.$profile->getId()); + + $this->assertSqlQueryCount($client, 4); + } } diff --git a/api/tests/Api/ScheduleEntries/ListScheduleEntriesTest.php b/api/tests/Api/ScheduleEntries/ListScheduleEntriesTest.php index f9bfe3736d..fcf8734c02 100644 --- a/api/tests/Api/ScheduleEntries/ListScheduleEntriesTest.php +++ b/api/tests/Api/ScheduleEntries/ListScheduleEntriesTest.php @@ -375,4 +375,12 @@ public function testListScheduleEntriesFilteredByInvalidEndDoesntFilter() { ['href' => $this->getIriFor('scheduleEntry2period1campPrototype')], ], $response->toArray()['_links']['items']); } + + public function testSqlQueryCount() { + $client = static::createClientWithCredentials(); + $client->enableProfiler(); + $client->request('GET', '/schedule_entries'); + + $this->assertSqlQueryCount($client, 21); + } } diff --git a/api/tests/Api/ScheduleEntries/ReadScheduleEntryTest.php b/api/tests/Api/ScheduleEntries/ReadScheduleEntryTest.php index c899a4883a..48153c7dbe 100644 --- a/api/tests/Api/ScheduleEntries/ReadScheduleEntryTest.php +++ b/api/tests/Api/ScheduleEntries/ReadScheduleEntryTest.php @@ -142,4 +142,15 @@ public function testGetSingleScheduleEntryInCampPrototypeIsAllowedForUnrelatedUs ], ]); } + + public function testSqlQueryCount() { + /** @var ScheduleEntry $scheduleEntry */ + $scheduleEntry = static::$fixtures['scheduleEntry1']; + + $client = static::createClientWithCredentials(); + $client->enableProfiler(); + $client->request('GET', '/schedule_entries/'.$scheduleEntry->getId()); + + $this->assertSqlQueryCount($client, 17); + } } diff --git a/api/tests/Api/Users/ListUsersTest.php b/api/tests/Api/Users/ListUsersTest.php index bc7535e940..c289a46fcd 100644 --- a/api/tests/Api/Users/ListUsersTest.php +++ b/api/tests/Api/Users/ListUsersTest.php @@ -21,4 +21,12 @@ public function testListUsersIsDeniedForLoggedInUser() { static::createClientWithCredentials()->request('GET', '/users'); $this->assertResponseStatusCodeSame(403); } + + public function testSqlQueryCount() { + $client = static::createClientWithCredentials(); + $client->enableProfiler(); + $client->request('GET', '/users'); + + $this->assertSqlQueryCount($client, 20); + } } diff --git a/api/tests/Api/Users/ReadUserTest.php b/api/tests/Api/Users/ReadUserTest.php index f83e477bd0..6e75420268 100644 --- a/api/tests/Api/Users/ReadUserTest.php +++ b/api/tests/Api/Users/ReadUserTest.php @@ -86,4 +86,15 @@ public function testGetSingleUserIsAllowedForRelatedUser() { ], ]); } + + public function testSqlQueryCount() { + /** @var User $user */ + $user = static::$fixtures['user2member']; + + $client = static::createClientWithCredentials(); + $client->enableProfiler(); + $client->request('GET', '/users/'.$user->getId()); + + $this->assertSqlQueryCount($client, 4); + } }