/** * * @covers Vatsimphp\VatsimData::prepareSync */ public function testPrepareSync() { $statusSync = $this->getSyncMock('status'); $statusSync->expects($this->once())->method('setDefaults'); $statusSync->expects($this->once())->method('registerUrl')->with($this->equalTo('custom_url'), $this->equalTo(true)); LoggerFactory::$level = Logger::DEBUG; LoggerFactory::$file = null; $data = $this->getDataMock(array('getStatusSync')); $data->setConfig('statusUrl', 'custom_url'); $data->setConfig('logLevel', Logger::CRITICAL); $data->setConfig('logFile', 'test.log'); $data->expects($this->once())->method('getStatusSync')->will($this->returnValue($statusSync)); $prepare = new \ReflectionMethod($data, 'prepareSync'); $prepare->setAccessible(true); $this->assertInstanceOf('Vatsimphp\\Sync\\StatusSync', $prepare->invoke($data)); $this->assertEquals(Logger::CRITICAL, LoggerFactory::$level); $this->assertEquals('test.log', LoggerFactory::$file); }
/** * * Prepare MetarSync object for reusage * @return MetarSync */ protected function prepareMetarSync() { if (!empty($this->metarSync)) { return $this->metarSync; } LoggerFactory::$file = $this->config['logFile']; LoggerFactory::$level = $this->config['logLevel']; $this->metarSync = $this->getMetarSync(); $this->metarSync->setDefaults(); $this->metarSync->cacheDir = $this->config['cacheDir']; $this->metarSync->cacheOnly = false; $this->metarSync->refreshInterval = $this->config['metarRefresh']; $this->metarSync->forceRefresh = $this->config['forceMetarRefresh']; $this->metarSync->registerUrlFromStatus($this->prepareSync(), 'metarUrls'); return $this->metarSync; }