protected function setUp() { parent::setUp(); $this->dir = vfsStream::setup('root'); $this->serializer = $this->getMockForAbstractClass(ParameterSerializerInterface::class); $this->reader = $this->getMockForAbstractClass(ParameterReaderInterface::class); $this->readerRegistry = $this->getMock(ReaderRegistry::class, array('getInstanceForFormat')); $this->readerRegistry->method('getInstanceForFormat')->willReturn($this->reader); $this->serializerRegistry = $this->getMock(SerializerRegistry::class, array('getInstanceForFormat')); $this->serializerRegistry->method('getInstanceForFormat')->willReturn($this->serializer); $this->task = new Parameters(vfsStream::url('root/' . self::PARAMETERS_FILE)); $this->task->setSerializerRegistry($this->serializerRegistry)->setReaderRegistry($this->readerRegistry); }
/** * @return ReaderRegistry */ public function getReaderRegistry() { if (!$this->readerRegistry) { $this->readerRegistry = ReaderRegistry::getDefaultInstance(); } return $this->readerRegistry; }
/** * @param string $path * @param int|null $format * @return $this */ protected function loadConfiguration($path, $format = null) { $readerRegistry = ReaderRegistry::getDefaultInstance(); $reader = $readerRegistry->getInstanceForFormat($format ?: Format::guessFormatFromPath($path)); $this->configuration = $reader->readFromFile($path); return $this; }