public function testCanModifyDoesNotAcceptAFormatThatCanNotBeParsed() { $file = m::mock(FileNodeInterface::class, FormatAwareInterface::class); $file->shouldReceive('exists')->andReturn(true); $format = m::mock(FormatInterface::class); $this->parserFactory->shouldReceive('getParser')->with($format)->andReturn(null); $file->shouldReceive('getFormat')->andReturn($format); static::assertFalse($this->reFormatter->canModify($file)); }
/** * Can this file be modified by this modifier * * @param FileNodeInterface $file * * @return bool */ public function canModify(FileNodeInterface $file) { return $file->exists() && $file instanceof FormatAwareInterface && $file->getFormat() !== null && $this->parserFactory->getParser($file->getFormat()) !== null; }