From d00665c07d4814796f58d3ec354187d5156e3f2a Mon Sep 17 00:00:00 2001 From: Andreas Schempp Date: Wed, 24 Apr 2024 08:14:03 +0200 Subject: [PATCH] Make EntityCacheTagsTest compatible with PHPUnit 10 --- .../tests/Cache/EntityCacheTagsTest.php | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/core-bundle/tests/Cache/EntityCacheTagsTest.php b/core-bundle/tests/Cache/EntityCacheTagsTest.php index cf2c983313b..daf83109963 100644 --- a/core-bundle/tests/Cache/EntityCacheTagsTest.php +++ b/core-bundle/tests/Cache/EntityCacheTagsTest.php @@ -143,34 +143,19 @@ public function getArguments(): iterable ->setTags(new ArrayCollection([$tag])) ; - $page1 = $this->mockClassWithProperties(PageModel::class, except: ['getTable']); - $page1->id = 5; - - $page2 = $this->mockClassWithProperties(PageModel::class, except: ['getTable']); - $page2->id = 6; - - $modelCollection = new Collection([$page1, $page2], 'tl_page'); - yield 'specific tag for entity instance' => [ $post, ['contao.db.tl_blog_post.5'], ]; - yield 'specific tag for model instance' => [ - $page1, - ['contao.db.tl_page.5'], - ]; - yield 'mixed' => [ - [$post, $post->getAuthor(), $post->getComments(), $post->getTags(), $modelCollection, ArticleModel::class, 'foo'], + [$post, $post->getAuthor(), $post->getComments(), $post->getTags(), ArticleModel::class, 'foo'], [ 'contao.db.tl_blog_post.5', 'contao.db.tl_author.100', 'contao.db.tl_comment.11', 'contao.db.tl_comment.12', 'contao.db.tl_tag.42', - 'contao.db.tl_page.5', - 'contao.db.tl_page.6', 'contao.db.tl_article', 'foo', ], @@ -187,6 +172,22 @@ public function getArguments(): iterable ]; } + public function testGetPageTags(): void + { + $page1 = $this->mockClassWithProperties(PageModel::class, except: ['getTable']); + $page1->id = 5; + + $page2 = $this->mockClassWithProperties(PageModel::class, except: ['getTable']); + $page2->id = 6; + + $modelCollection = new Collection([$page1, $page2], 'tl_page'); + + $entityCacheTags = $this->getEntityCacheTags(); + + $this->assertSame(['contao.db.tl_page.5'], $entityCacheTags->getTagsFor($page1)); + $this->assertSame(['contao.db.tl_page.5', 'contao.db.tl_page.6'], $entityCacheTags->getTagsFor($modelCollection)); + } + public function testDelegatesToResponseTagger(): void { $responseTagger = $this->createMock(ResponseTagger::class);