Bladeren bron

ZF-8981 @##$%#$% ini files are now supported as well when explicitely setting 'register' directive. Also bugfix in case no explicit transport type is defined.

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@20812 44c647ce-9c0f-0410-b52a-842ac1e357ba
freak 16 jaren geleden
bovenliggende
commit
8a69ea49ff
2 gewijzigde bestanden met toevoegingen van 32 en 0 verwijderingen
  1. 5 0
      library/Zend/Application/Resource/Mail.php
  2. 27 0
      tests/Zend/Application/Resource/MailTest.php

+ 5 - 0
library/Zend/Application/Resource/Mail.php

@@ -65,6 +65,7 @@ class Zend_Application_Resource_Mail extends Zend_Application_Resource_ResourceA
             {
                 $this->_transport = $this->_setupTransport($options['transport']);
                 if(!isset($options['transport']['register']) ||
+                   $options['transport']['register'] == '1' ||
                    (isset($options['transport']['register']) &&
                         !is_numeric($options['transport']['register']) &&
                         (bool) $options['transport']['register'] == true))
@@ -101,6 +102,10 @@ class Zend_Application_Resource_Mail extends Zend_Application_Resource_ResourceA
 
     protected function _setupTransport($options)
     {
+    	if(!isset($options['type'])) {
+    		$options['type'] = 'sendmail';
+    	}
+    	
         $transportName = ucfirst(strtolower($options['type']));
         unset($options['type']);
 

+ 27 - 0
tests/Zend/Application/Resource/MailTest.php

@@ -156,6 +156,20 @@ class Zend_Application_Resource_MailTest extends PHPUnit_Framework_TestCase
     }
 
     /**
+     * Got notice: Undefined index:  type
+     */
+    public function testDefaultTransport() {
+        $options = array('transport' => array(//'type' => 'sendmail', // dont define type
+                                              'register' => true)); 
+        $resource = new Zend_Application_Resource_Mail(array());
+        $resource->setBootstrap($this->bootstrap);
+        $resource->setOptions($options);
+
+        $resource->init();
+        $this->assertTrue(Zend_Mail::getDefaultTransport() instanceof Zend_Mail_Transport_Sendmail);        
+    }
+    
+    /**
     * @group ZF-8811
     */
     public function testDefaultsCaseSensivity() {
@@ -169,7 +183,20 @@ class Zend_Application_Resource_MailTest extends PHPUnit_Framework_TestCase
         $this->assertNull(Zend_Mail::getDefaultTransport());
         $this->assertEquals($options['defaultFroM'], Zend_Mail::getDefaultFrom());
         $this->assertEquals($options['defAultReplyTo'], Zend_Mail::getDefaultReplyTo());
+    }
+    
+    /**
+     * @group ZF-8981
+     */
+    public function testNumericRegisterDirectiveIsPassedOnCorrectly() {
+        $options = array('transport' => array('type' => 'sendmail',
+                                              'register' => '1')); // Culprit
+        $resource = new Zend_Application_Resource_Mail(array());
+        $resource->setBootstrap($this->bootstrap);
+        $resource->setOptions($options);
 
+        $resource->init();
+        $this->assertTrue(Zend_Mail::getDefaultTransport() instanceof Zend_Mail_Transport_Sendmail);    	
     }
 }