public function WishlistCacheContextTest::testWishlistCacheContext in Commerce Wishlist 8.3
Tests commerce 'wishlist' cache context.
File
- tests/
src/ Unit/ WishlistCacheContextTest.php, line 20
Class
- WishlistCacheContextTest
- @coversDefaultClass \Drupal\commerce_wishlist\Cache\Context\WishlistCacheContext @group commerce
Namespace
Drupal\Tests\commerce_wishlist\UnitCode
public function testWishlistCacheContext() {
$account = $this
->createMock(AccountInterface::class);
$wishlistProvider = $this
->createMock(WishlistProviderInterface::class);
$wishlistProvider
->expects($this
->once())
->method('getWishlistIds')
->willReturn([
'19',
'12',
]);
$wishlistProvider
->expects($this
->once())
->method('getWishlists')
->willReturn([
new TestCacheableDependency([], [
'commerce_wishlist:19',
], 0),
new TestCacheableDependency([], [
'commerce_wishlist:24',
], 0),
]);
$wishlistCache = new WishlistCacheContext($account, $wishlistProvider);
$this
->assertEquals('19:12', $wishlistCache
->getContext());
$this
->assertEquals([
'commerce_wishlist:19',
'commerce_wishlist:24',
], $wishlistCache
->getCacheableMetadata()
->getCacheTags());
}