public function testGetContent() { $fileContent = 'test data'; $file = $this->getMockBuilder('Gaufrette\\File')->disableOriginalConstructor()->getMock(); $this->filesystem->expects($this->once())->method('get')->with('testFile.txt')->will($this->returnValue($file)); $file->expects($this->once())->method('getContent')->will($this->returnValue($fileContent)); $this->assertEquals($fileContent, $this->attachmentManager->getContent($this->attachment)); }
/** * {@inheritdoc} */ public function format($parameter, array $formatterArguments = []) { $altValue = $parameter->getOriginalFilename(); if (array_key_exists(self::ALT_ATTRIBUTE, $formatterArguments)) { $altValue = $formatterArguments[self::ALT_ATTRIBUTE]; } $parameters = sprintf('alt = "%s"', $altValue); if (array_key_exists(self::HEIGHT_ATTRIBUTE, $formatterArguments)) { $parameters .= sprintf(' height = %s', $formatterArguments[self::HEIGHT_ATTRIBUTE]); } if (array_key_exists(self::WIDTH_ATTRIBUTE, $formatterArguments)) { $parameters .= sprintf(' width = %s', $formatterArguments[self::WIDTH_ATTRIBUTE]); } return $this->getData($parameter->getMimeType(), $this->manager->getContent($parameter), $parameters); }
/** * {@inheritdoc} */ public function getData() { return $this->attachmentManager->getContent($this->fileName); }