/**
  * Check whenever given language package up to date
  *
  * @param string $languageCode
  *
  * @return bool
  */
 public function isFresh($languageCode)
 {
     if (!isset($this->processedLanguages[$languageCode])) {
         $configData = $this->cm->get(TranslationStatusInterface::META_CONFIG_KEY);
         $stats = $this->statisticProvider->get();
         if (isset($configData[$languageCode])) {
             $stats = array_filter($stats, function ($langInfo) use($languageCode) {
                 return $langInfo['code'] === $languageCode;
             });
             $lang = array_pop($stats);
             if ($lang) {
                 $installationDate = $this->getDateTimeFromString($configData[$languageCode]['lastBuildDate']);
                 $currentBuildDate = $this->getDateTimeFromString($lang['lastBuildDate']);
                 $this->processedLanguages[$languageCode] = $installationDate >= $currentBuildDate;
             } else {
                 // could not retrieve current language stats, so assume that it's fresh
                 $this->processedLanguages[$languageCode] = true;
             }
         } else {
             // if we do not have information about installed time then assume that needs update
             $this->processedLanguages[$languageCode] = false;
         }
     }
     return $this->processedLanguages[$languageCode];
 }
 /**
  * @dataProvider getProvider
  *
  * @param mixed $cachedData
  * @param array $resultExpected
  * @param bool  $fetchExpected
  * @param array $fetchedResult
  * @param bool  $isException
  */
 public function testGet($cachedData, $resultExpected, $fetchExpected, $fetchedResult = [], $isException = false)
 {
     $this->cache->expects($this->once())->method('fetch')->with($this->equalTo(TranslationStatisticProvider::CACHE_KEY))->will($this->returnValue($cachedData));
     if ($fetchExpected) {
         if ($isException) {
             $this->adapter->expects($this->once())->method('fetchStatistic')->will($this->throwException($fetchedResult));
         } else {
             $this->adapter->expects($this->once())->method('fetchStatistic')->will($this->returnValue($fetchedResult));
         }
         $this->cache->expects($this->once())->method('save')->with($this->equalTo(TranslationStatisticProvider::CACHE_KEY));
     } else {
         $this->adapter->expects($this->never())->method('fetchStatistic');
     }
     $result = $this->provider->get();
     $this->assertSame($resultExpected, $result);
 }