getMockedConfig($retentionObligation); $mockedTimeFactory = $this->getMockedTimeFactory($timeNow); $expiration = new Expiration($mockedConfig, $mockedTimeFactory); $actualResult = $expiration->isExpired($timestamp, $quotaExceeded); $this->assertEquals($expectedResult, $actualResult); } public function timestampTestData(): array { return [ [ 'disabled', false], [ 'auto', false ], [ 'auto,auto', false ], [ 'auto, auto', false ], [ 'auto, 3', self::FAKE_TIME_NOW - (3 * self::SECONDS_PER_DAY) ], [ '5, auto', false ], [ '3, 5', self::FAKE_TIME_NOW - (5 * self::SECONDS_PER_DAY) ], [ '10, 3', self::FAKE_TIME_NOW - (10 * self::SECONDS_PER_DAY) ], ]; } /** * @dataProvider timestampTestData * * @param string $configValue * @param int $expectedMaxAgeTimestamp */ public function testGetMaxAgeAsTimestamp($configValue, $expectedMaxAgeTimestamp): void { $mockedConfig = $this->getMockedConfig($configValue); $mockedTimeFactory = $this->getMockedTimeFactory( self::FAKE_TIME_NOW ); $expiration = new Expiration($mockedConfig, $mockedTimeFactory); $actualTimestamp = $expiration->getMaxAgeAsTimestamp(); $this->assertEquals($expectedMaxAgeTimestamp, $actualTimestamp); } /** * @param int $time * @return ITimeFactory|MockObject */ private function getMockedTimeFactory($time) { $mockedTimeFactory = $this->createMock(ITimeFactory::class); $mockedTimeFactory->expects($this->any()) ->method('getTime') ->willReturn($time); return $mockedTimeFactory; } /** * @param string $returnValue * @return IConfig|MockObject */ private function getMockedConfig($returnValue) { $mockedConfig = $this->createMock(IConfig::class); $mockedConfig->expects($this->any()) ->method('getSystemValue') ->willReturn($returnValue); return $mockedConfig; } }