Ejemplo n.º 1
0
 public function testRead()
 {
     $configFiles = [file_get_contents(realpath(__DIR__ . '/_files/integrationA.xml')), file_get_contents(realpath(__DIR__ . '/_files/integrationB.xml'))];
     $this->fileResolverMock->expects($this->any())->method('get')->will($this->returnValue($configFiles));
     $expectedResult = (require __DIR__ . '/_files/integration.php');
     $this->assertEquals($expectedResult, $this->configReader->read(), 'Error happened during config reading.');
 }
 public function testGetIntegrationsFromConfigReader()
 {
     $integrations = ['foo', 'bar', 'baz'];
     $this->configCacheTypeMock->expects($this->once())->method('load')->with(Config::CACHE_ID)->will($this->returnValue(null));
     $this->configCacheTypeMock->expects($this->once())->method('save')->with(serialize($integrations), Config::CACHE_ID, [Type::CACHE_TAG])->will($this->returnValue(null));
     $this->configReaderMock->expects($this->once())->method('read')->will($this->returnValue($integrations));
     $this->assertEquals($integrations, $this->configModel->getIntegrations());
 }
 /**
  * Return integrations loaded from cache if enabled or from files merged previously
  *
  * @return array
  */
 public function getIntegrations()
 {
     if (null === $this->integrations) {
         $integrations = $this->configCacheType->load(self::CACHE_ID);
         if ($integrations && is_string($integrations)) {
             $this->integrations = unserialize($integrations);
         } else {
             $this->integrations = $this->configReader->read();
             $this->configCacheType->save(serialize($this->integrations), self::CACHE_ID, [TypeConsolidated::CACHE_TAG]);
         }
     }
     return $this->integrations;
 }