public function testSetTransport()
 {
     $transport = 'file';
     $this->assertSame($this->mailOptions, $this->mailOptions->setTransport($transport));
     $this->assertEquals('\\Zend\\Mail\\Transport\\File', $this->mailOptions->getTransport());
     $this->assertEquals('\\Zend\\Mail\\Transport\\File', $this->mailOptions->getMailAdapter());
 }
 public function testMailAdapterNameConversion()
 {
     $this->mailOptions->setMailAdapter('Sendmail');
     $this->assertTrue($this->mailOptions->getMailAdapter() instanceof Sendmail);
     $this->mailOptions->setMailAdapter('smtp');
     $this->assertTrue($this->mailOptions->getMailAdapter() instanceof Smtp);
     $this->mailOptions->setMailAdapter('FILE');
     $this->assertTrue($this->mailOptions->getMailAdapter() instanceof File);
     $this->mailOptions->setMailAdapter('null');
     $this->assertTrue($this->mailOptions->getMailAdapter() instanceof \Zend\Mail\Transport\Null);
 }
 /**
  * @param ServiceLocatorInterface $sm
  * @return TransportInterface
  */
 protected function createTransport(ServiceLocatorInterface $sm)
 {
     $adapter = $this->mailOptions->getMailAdapter();
     // A transport instance can be returned as is
     if ($adapter instanceof TransportInterface) {
         return $this->setupTransportConfig($adapter);
     }
     // Check if the adapter is a service
     if (is_string($adapter) && $sm->has($adapter)) {
         /** @var TransportInterface $transport */
         $transport = $sm->get($adapter);
         if ($transport instanceof TransportInterface) {
             return $this->setupTransportConfig($transport);
         } else {
             throw new InvalidArgumentException('Provided mail_adapter service does not return a "Zend\\Mail\\Transport\\TransportInterface" instance');
         }
     }
     // Check if the adapter is one of Zend's default adapters
     if (is_string($adapter) && is_subclass_of($adapter, 'Zend\\Mail\\Transport\\TransportInterface')) {
         return $this->setupTransportConfig(new $adapter());
     }
     // The adapter is not valid. Throw an exception
     throw new InvalidArgumentException(sprintf('mail_adapter must be an instance of "Zend\\Mail\\Transport\\TransportInterface" or string, "%s" provided', is_object($adapter) ? get_class($adapter) : gettype($adapter)));
 }