From a5cde6a28eff14b39cd087cd44360c8ba1a812f3 Mon Sep 17 00:00:00 2001 From: bencroker Date: Mon, 12 Feb 2024 10:06:19 -0600 Subject: [PATCH] =?UTF-8?q?Stop=20tracking=20entry=20queries=20for=20?= =?UTF-8?q?=E2=80=9Csingle=E2=80=9D=20sections?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + src/helpers/ElementQueryHelper.php | 30 ++++ src/services/GenerateCacheService.php | 5 + tests/TESTS.md | 203 +---------------------- tests/pest/Feature/GenerateCacheTest.php | 8 + 5 files changed, 45 insertions(+), 202 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d1a019c..f0654483 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ ### Changed - The Cache Folder Path column now displays aliases in the cached file table in the File Storage utility. +- Entry queries for “single” sections are no longer tracked. - Improved error handling in a previous migration. - Made minor optimisations to the file storage driver. - Expired URIs are now deleted from the database immediately when refreshing expired cache. diff --git a/src/helpers/ElementQueryHelper.php b/src/helpers/ElementQueryHelper.php index a237ac80..6de705d2 100644 --- a/src/helpers/ElementQueryHelper.php +++ b/src/helpers/ElementQueryHelper.php @@ -5,13 +5,16 @@ namespace putyourlightson\blitz\helpers; +use Craft; use craft\base\ElementInterface; use craft\behaviors\CustomFieldBehavior; use craft\elements\db\ElementQuery; use craft\elements\db\ElementQueryInterface; +use craft\elements\db\EntryQuery; use craft\fields\data\MultiOptionsFieldData; use craft\fields\data\OptionData; use craft\helpers\ArrayHelper; +use craft\models\Section; use DateTime; use ReflectionClass; use ReflectionProperty; @@ -321,6 +324,33 @@ public static function isDraftOrRevisionQuery(ElementQuery $elementQuery): bool return false; } + /** + * Returns whether the element query is an entry query for “single” sections. + */ + public static function isEntryQueryForSingleSections(ElementQuery $elementQuery): bool + { + if (!($elementQuery instanceof EntryQuery)) { + return false; + } + + $sectionIds = $elementQuery->sectionId; + + if (!is_array($sectionIds)) { + $sectionIds = [$sectionIds]; + } + + $singles = Craft::$app->getSections()->getSectionsByType(Section::TYPE_SINGLE); + $singlesIds = ArrayHelper::getColumn($singles, 'id'); + + foreach ($sectionIds as $sectionId) { + if (!is_numeric($sectionId) || !in_array($sectionId, $singlesIds)) { + return false; + } + } + + return true; + } + /** * Returns whether the element query is a relation field query. * For example: diff --git a/src/services/GenerateCacheService.php b/src/services/GenerateCacheService.php index 505f5528..62cfc034 100755 --- a/src/services/GenerateCacheService.php +++ b/src/services/GenerateCacheService.php @@ -255,6 +255,11 @@ public function addElementQuery(ElementQuery $elementQuery): void return; } + // Don’t proceed if this is an entry query for “single” sections + if (ElementQueryHelper::isEntryQueryForSingleSections($elementQuery)) { + return; + } + // Don’t proceed if this is a relation field query if (ElementQueryHelper::isRelationFieldQuery($elementQuery)) { $this->_addRelatedElementIds($elementQuery); diff --git a/tests/TESTS.md b/tests/TESTS.md index cf52aca0..dd432f62 100644 --- a/tests/TESTS.md +++ b/tests/TESTS.md @@ -4,211 +4,10 @@ This document outlines the test specification for the Blitz plugin. --- -## Architecture Tests - -### [Architecture](pest/Architecture/ArchitectureTest.php) - -_Tests the architecture of the plugin._ - -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Source code does not contain any `var_dump` or `die` statements. - -## Drivers Tests - -### [FileStorage](pest/Drivers/FileStorageTest.php) - -_Tests functionality specific to the file storage driver._ - -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Getting a site path works for a disabled or non-existent site. - ## Feature Tests -### [BlitzVariable](pest/Feature/BlitzVariableTest.php) - -_Tests the markup generated by the Blitz variable._ - -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Include cached tag does not contain unencoded slashes in params. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Include cached tag does not contain path param. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Fetch URI tag does not contain unencoded slashes in params. - -### [CacheRequest](pest/Feature/CacheRequestTest.php) - -_Tests whether requests are cacheable and under what circumstances._ - -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Request matching included URI pattern is cacheable. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Request with generate token is cacheable. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Request with `no-cache` param is not cacheable. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Request with token is not cacheable. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Request starting with `_includes` is a cached include. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Request with cached include action is a cached include. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Request starting with `_dynamic` is a dynamic include. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Request with dynamic include action is a dynamic include. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Requested cacheable site URI includes allowed query strings when urls cached as unique pages. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Requested cacheable site URI does not include query strings when urls cached as same page. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Requested cacheable site URI includes page trigger. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Requested cacheable site URI works with regular expressions. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Site URI with included URI pattern is cacheable. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Site URI with excluded URI pattern is not cacheable. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Site URI with `admin` in URI is cacheable. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Site URI with `index.php` in URI is not cacheable. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Site URI with max URI length is cacheable. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Site URI with max URI length exceeded is not cacheable. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) URI patterns with matching regular expressions are matched. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) URI patterns without matching regular expressions are not matched. - -### [CacheStorage](pest/Feature/CacheStorageTest.php) - -_Tests the storing of cached values using the cache storage drivers._ - -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) 255 character site URI can be saved with data set `FileStorage`. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) 255 character site URI can be saved with data set `YiiCacheStorage`. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) 255 character site URI can be saved with data set `RedisStorage`. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Long site URI can be saved except for by file storage driver with data set `FileStorage`. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Long site URI can be saved except for by file storage driver with data set `YiiCacheStorage`. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Long site URI can be saved except for by file storage driver with data set `RedisStorage`. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Site URI is decoded before being saved with data set `FileStorage`. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Site URI is decoded before being saved with data set `YiiCacheStorage`. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Site URI is decoded before being saved with data set `RedisStorage`. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Compressed cached value can be fetched compressed and uncompressed with data set `FileStorage`. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Compressed cached value can be fetched compressed and uncompressed with data set `YiiCacheStorage`. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Compressed cached value can be fetched compressed and uncompressed with data set `RedisStorage`. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Cached value of site URI is deleted with data set `FileStorage`. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Cached value of site URI is deleted with data set `YiiCacheStorage`. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Cached value of site URI is deleted with data set `RedisStorage`. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Compressed cached value of site URI is deleted with data set `FileStorage`. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Compressed cached value of site URI is deleted with data set `YiiCacheStorage`. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Compressed cached value of site URI is deleted with data set `RedisStorage`. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Cached value of decoded site URI is deleted with data set `FileStorage`. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Cached value of decoded site URI is deleted with data set `YiiCacheStorage`. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Cached value of decoded site URI is deleted with data set `RedisStorage`. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) All cached values are deleted with data set `FileStorage`. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) All cached values are deleted with data set `YiiCacheStorage`. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) All cached values are deleted with data set `RedisStorage`. - -### [ExpireCache](pest/Feature/ExpireCacheTest.php) - -_Tests marking cached values as expired when `REFRESH_MODE_EXPIRE` is selected._ - -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Refreshing the entire cache marks the cache as expired. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Refreshing a site marks the cache as expired. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Refreshing a site URI marks the cache as expired. - ### [GenerateCache](pest/Feature/GenerateCacheTest.php) _Tests the saving of cached values, element cache records and element query records._ -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Cached value is saved with output comments. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Cached value is saved without output comments. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Cached value is saved with output comments when file extension is ".html". -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Cached value is saved without output comments when file extension is not `.html`. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Cache record with max URI length is saved. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Cache record with max URI length exceeded throws exception. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element cache record is saved without custom fields. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element cache record is saved with custom fields. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element cache record is saved with eager loaded custom fields. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element cache record is saved with eager loaded custom fields in variable. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element cache record is saved for preloaded single. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element cache record is saved with eager loaded custom fields for preloaded single. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element cache records are saved with all statuses for relation field queries. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element cache records are saved with all statuses for eager loaded relation field queries. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element query records without specific identifiers are saved. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element query records with specific identifiers are not saved. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element query record with join is saved. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element query record with relation field is not saved. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element query record with related to param is saved. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element query record with query param is saved without the param. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element query record with expression is not saved. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element query record with option field data is converted to value. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element query record with multi options field data is converted to array of values. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element query cache records are saved. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element query source records with specific source identifiers are saved. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element query source records without specific source identifiers are not saved. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element query attribute records are saved. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element query attribute records are saved with order by. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element query attribute records are saved with order by parts array. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element query attribute records are saved with before. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element query field records are saved with order by. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element query field records are saved with order by array. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Cache tags are saved. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Include record is saved. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) SSI include cache record is saved. - -### [RefreshCache](pest/Feature/RefreshCacheTest.php) - -_Tests the tracking of changes to elements and the resulting element cache IDs and element query type records._ - -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element is not tracked when it is unchanged. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element is tracked when `refreshCacheWhenElementSavedUnchanged` is `true` and it is unchanged. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element is not tracked when disabled and its attribute is changed. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element is tracked when disabled and `refreshCacheWhenElementSavedNotLive` is `true` and its attribute is changed. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element is tracked when its status is changed. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element is tracked when it expires. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element is tracked when it is deleted. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element is tracked when its attribute is changed. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element is tracked when its field is changed. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element is tracked when its attribute and field are changed. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element is tracked when its status and attribute and field are changed. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Asset is tracked when its file is replaced. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Asset is tracked when its filename is changed. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Asset is tracked when its focal point is changed. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element expiry date record is saved when an entry has a future post date. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element expiry date record is saved when an entry has a future expiry date. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element cache IDs are returned when an entry is changed. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element cache IDs are returned when an entry is changed by attributes. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element cache IDs are not returned when an entry is changed by custom fields. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element query cache IDs are returned when a disabled entry is changed. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element query type records are returned when an entry is changed. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element query type records without a cache ID are not returned when an entry is changed. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element query type records are returned when an entry is changed by attributes used in the query. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element query type records are not returned when an entry is changed by attributes not used in the query. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element query type records are returned when an entry is changed by custom fields used in the query. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element query type records are not returned when an entry is changed by custom fields not used in the query. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element query type records are returned when an entry is changed with the date updated used in the query. - -### [SiteUri](pest/Feature/SiteUriTest.php) - -_Tests the site URI helper methods._ - -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Site URIs are returned from assets with transforms. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) HTML mime type is returned when site URI is HTML. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) JSON mime type is returned when site URI is JSON. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Site URIs with page triggers are paginated. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Site URIs without page triggers are not paginated. - -## Integration Tests - -### [Commerce](pest/Integration/CommerceTest.php) - -_Tests that Commerce variants are refreshed on order completion so that their stock is updated._ - -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Variants are refreshed on order completion. - -### [FeedMe](pest/Integration/FeedMeTest.php) - -_Tests that Feed Me imports refresh the cache with batch mode enabled._ - -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Cache is refreshed with batch mode enabled. - -### [Seomatic](pest/Integration/SeomaticTest.php) - -_Tests that cached pages are refreshed when SEOmatic meta containers are invalidated._ - -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Invalidate container caches event without a URL or source triggers a refresh all. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Invalidate container caches event with a specific source triggers a refresh. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Invalidate container caches event for a specific element does not trigger a refresh. - -## Interface Tests - -### [WebResponse](pest/Interface/WebResponseTest.php) - -_Tests that cached web responses contain the correct headers and comments._ - -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Response contains the default cache control header when the page is not cacheable. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Response contains the cache control header when the page is cacheable. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Response contains the expired cache control header and the cache is refreshed when the page is expired. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Response adds the `X-Powered-By` header once. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Response overwrites the `X-Powered-By` header. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Response contains output comments when enabled. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Response does not contain output comments when disabled. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Response with mime type has headers and does not contain output comments. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Response is encoded when compression is enabled. -![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Response is not encoded when compression is disabled. +![Pass](https://raw.githubusercontent.com/putyourlightson/craft-generate-test-spec/main/icons/pass.svg) Element query record for entry in single sections is not saved. diff --git a/tests/pest/Feature/GenerateCacheTest.php b/tests/pest/Feature/GenerateCacheTest.php index 42c3ef35..b0f7510b 100644 --- a/tests/pest/Feature/GenerateCacheTest.php +++ b/tests/pest/Feature/GenerateCacheTest.php @@ -303,6 +303,14 @@ ->toHaveRecordCount(0); }); +test('Element query record for entry in single sections is not saved', function() { + $elementQuery = Entry::find()->section([App::env('TEST_SINGLE_SECTION_HANDLE')]); + Blitz::$plugin->generateCache->addElementQuery($elementQuery); + + expect(ElementQueryRecord::class) + ->toHaveRecordCount(0); +}); + test('Element query record with option field data is converted to value', function() { $optionFieldData = new OptionData('One', 1, true); $elementQuery = Entry::find()->dropdown($optionFieldData);