Example #1
0
 /**
  * @throws LocalizedException
  */
 public function update()
 {
     $dbCodes = $this->config->getAvailableDatabases();
     foreach ($dbCodes as $dbCode) {
         $this->updater->update($dbCode);
     }
 }
 public function testUpdateDbWithException()
 {
     $this->databaseConfig->expects($this->once())->method('isAutoUpdate')->willReturn(true);
     $e = new \Exception();
     $this->updaterSelected->expects($this->once())->method('update')->willThrowException($e);
     $this->logger->expects($this->once())->method('critical')->with($e);
     $this->assertSame($this->cronUpdateDb, $this->cronUpdateDb->execute());
 }
 public function testUpdate()
 {
     $availableDatabases = ['db_code_1', 'db_code_2', 'db_cod_3'];
     $countAvailableDatabases = count($availableDatabases);
     $this->config->expects($this->once())->method('getAvailableDatabases')->willReturn($availableDatabases);
     $this->updater->expects($this->exactly($countAvailableDatabases))->method('update')->withConsecutive(['db_code_1'], ['db_code_2'], ['db_cod_3']);
     $this->updaterSelected->update();
 }
Example #4
0
 /**
  * @return string
  */
 public function getDbStatus()
 {
     $dbCodes = $this->config->getAvailableDatabases();
     $html = '<ul style="list-style: none; margin: 0;">';
     foreach ($dbCodes as $dbCode) {
         $html .= "<li>{$this->availableDb->getOptionTitle($dbCode)}: {$this->getDbCreateDate($dbCode)}</li>";
     }
     $html .= '</ul>';
     return $html;
 }
Example #5
0
 /**
  * @return $this
  */
 public function execute()
 {
     if (!$this->databaseConfig->isAutoUpdate()) {
         return $this;
     }
     try {
         $this->updaterSelected->update();
     } catch (\Exception $e) {
         $this->logger->critical($e);
     }
     return $this;
 }
Example #6
0
 public function testIsAutoUpdate()
 {
     $isAutoUpdate = true;
     $this->scopeConfig->expects($this->once())->method('isSetFlag')->with('tobai_geoip2/database/auto_update')->willReturn($isAutoUpdate);
     $this->assertEquals($isAutoUpdate, $this->config->isAutoUpdate());
 }