summaryrefslogtreecommitdiff
blob: de375715f96b564d0a0a47074082c0f10c3382fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php

/**
 * @group Database
 */
class AggregateMessageGroupLoaderTest extends PHPUnit\Framework\TestCase {
	/**
	 * @var AggregateMessageGroup
	 */
	protected $mgAggregateLoader;

	public function testCacheCalls() {
		/** @var MessageGroupWANCache $mockMgWANCache */
		$mockMgWANCache = $this->getMockBuilder( MessageGroupWANCache::class )
			->disableOriginalConstructor()
			->getMock();

		$aggregateLoader = new AggregateMessageGroupLoader(
			TranslateUtils::getSafeReadDB(),
			$mockMgWANCache
		);

		$mockMgWANCache->expects( $this->once() )
			->method( 'getValue' )
			->with( 'recache' )
			->willReturn( [] );

		// should trigger a get call on cache
		$aggregateLoader->recache();

		// should return the cached groups from process cache
		$this->assertEquals( [], $aggregateLoader->getGroups() );

		$mockMgWANCache->expects( $this->once() )
			->method( 'delete' );

		// should trigger the delete method on cache
		$aggregateLoader->clearCache();
	}
}