Skip to content

Commit

Permalink
Make the entity cache tags test compatible with PHPUnit 10 (see #7150)
Browse files Browse the repository at this point in the history
Description
-----------

see #7117

Commits
-------

d00665c Make EntityCacheTagsTest compatible with PHPUnit 10
  • Loading branch information
aschempp committed May 10, 2024
1 parent ba73769 commit 276e040
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions core-bundle/tests/Cache/EntityCacheTagsTest.php
Expand Up @@ -109,7 +109,7 @@ public function testGetTags(mixed $argument, array $expectedTags): void
$this->assertSame($expectedTags, $entityCacheTags->getTagsFor($argument));
}

public function getArguments(): iterable
public static function getArguments(): iterable
{
yield 'single tag' => [
'foo',
Expand Down 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,21 @@ 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 276e040

Please sign in to comment.