checks if an update on a remote location for the local file or the cache
public checkUpdate ( ) : integer | null | ||
return | integer | null | The actual cached version if a newer version is available, null otherwise |
/** * */ public function testCheckUpdateWithNewerVersion() { $logger = $this->getMockBuilder(\Monolog\Logger::class)->disableOriginalConstructor()->getMock(); $this->object->setLogger($logger); $body = $this->getMockBuilder(\GuzzleHttp\Psr7\Stream::class)->disableOriginalConstructor()->setMethods(['getContents'])->getMock(); $body->expects(self::once())->method('getContents')->will(self::returnValue(6001)); $response = $this->getMockBuilder(\GuzzleHttp\Psr7\Response::class)->disableOriginalConstructor()->setMethods(['getStatusCode', 'getBody'])->getMock(); $response->expects(self::once())->method('getStatusCode')->will(self::returnValue(200)); $response->expects(self::once())->method('getBody')->will(self::returnValue($body)); $client = $this->getMockBuilder(\GuzzleHttp\Client::class)->disableOriginalConstructor()->setMethods(['get'])->getMock(); $client->expects(self::once())->method('get')->will(self::returnValue($response)); $this->object->setClient($client); $map = [['browscap.time', false, null, null], ['browscap.version', false, null, 6000]]; $cache = $this->getMockBuilder(\BrowscapPHP\Cache\BrowscapCache::class)->disableOriginalConstructor()->setMethods(['getItem', 'hasItem', 'setItem'])->getMock(); $cache->expects(self::any())->method('getItem')->will(self::returnValueMap($map)); $cache->expects(self::any())->method('hasItem')->will(self::returnValue(true)); $cache->expects(self::never())->method('setItem')->will(self::returnValue(false)); $this->object->setCache($cache); self::assertSame(6000, $this->object->checkUpdate()); }