Ejemplo n.º 1
0
 public function testFileParameter()
 {
     try {
         new FileParameter(null);
     } catch (\Exception $E) {
         $this->assertInstanceOf('MOC\\V\\Component\\Mail\\Component\\Exception\\Repository\\EmptyFileException', $E);
     }
     $Parameter = new FileParameter(__FILE__);
     $this->assertEquals(__FILE__, $Parameter->getFile());
     $this->assertInstanceOf('\\SplFileInfo', $Parameter->getFileInfo());
     $this->assertEquals(__FILE__, $Parameter->__toString());
     try {
         $Parameter->setFile(__DIR__);
     } catch (\Exception $E) {
         $this->assertInstanceOf('MOC\\V\\Component\\Mail\\Component\\Exception\\Repository\\TypeFileException', $E);
     }
 }
Ejemplo n.º 2
0
 /**
  * @param FileParameter $File
  *
  * @return EdenPhpSmtp
  * @throws MailException
  */
 public function addAttachment(FileParameter $File)
 {
     try {
         $this->Instance->addAttachment($File->getFileInfo()->getFilename(), file_get_contents($File->getFileInfo()->getRealPath()));
     } catch (\Exception $Exception) {
         throw new MailException($Exception->getMessage(), $Exception->getCode(), $Exception);
     }
     return $this;
 }