Skip to content

Commit

Permalink
Make EntityCacheTagsTest compatible with PHPUnit 10
Browse files Browse the repository at this point in the history
  • Loading branch information
aschempp committed Apr 24, 2024
1 parent c393ddf commit d00665c
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions core-bundle/tests/Cache/EntityCacheTagsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
],
Expand All @@ -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);
Expand Down

0 comments on commit d00665c

Please sign in to comment.