Hi,

many thanks for the indications Matthew !
I've now attached a unit test to the ticket. It shows both the old (wrong) 
parsing and the new (correct) parsing in two different cases.

Let me know if there is anything else I can do to help,
Dominik

On 2011-07-05, at 5:43 PM, Matthew Weier O'Phinney wrote:

> -- Dominik Gehl <[email protected]> wrote
> (on Tuesday, 05 July 2011, 01:43 PM -0400):
>> Currently there is no test of the protected _decodeLine function in
>> the unit tests that ship with Zend Framework. Could you let me know
>> how you handle unit tests of protected functions in Zend Framework ?
> 
> Unit tests do not need to directly test specific methods; they should
> test behavior.
> 
> In this case, I would write a test that calls requestAndResponse(), and
> checks the response to ensure the tokens parsed are correct. 
> 
> Alternately, you can create a Proxy object and expose _decodeLine
> publically, and simply call it. As an example:
> 
>    class Zend_Mail_Protocol_TestAsset_Imap extends Zend_Mail_Protocol_Imap
>    {
>        protected $proxy;
> 
>        public $proxyLines      = array();
>        public $proxyLinesIndex = -1;
> 
>        public function __construct(Zend_Mail_Protocol_Imap $imap)
>        {
>            $this->proxy = $imap;
>        }
> 
>        public function _decodeLine($line)
>        {
>            // cut and paste the body of _decodeLine here
>        }
> 
>        protected function _nextLine()
>        {
>            $count = count($this->proxyLines);
>            if (!$count || ($this->proxyLinesIndex >= $count)) {
>                require_once 'Zend/Mail/Protocol/Exception.php';
>                throw new Zend_Mail_Protocol_Exception('cannot read - 
> connection closed?');
>            }
>            $this->proxyLinesIndex++;
>            return $this->proxyLines[$this->proxyLinesIndex++];
>        }
>    }
> 
> To use it, you'd then do something like this:
> 
>    $imap  = new Zend_Mail_Protocol_Imap();
>    $proxy = new Zend_Mail_Protocol_TestAsset_Imap($imap);
> 
>    $proxy->proxyLines = array(...); // if a multi-line decode is necessary
>    $line   = '...';
>    $result = $proxy->_decodeLine($line);
>    // now do assertions on the result
> 
> If you're not needing to test against a multi-line statement, you can
> simplify the above and remove the _nextLine() method and $proxyLines*
> attributes, and change the _decodeLine() method to simply "return
> $this->proxy->_decodeLine($line);" This will require less maintenance
> long-term (i.e., the need to cut-and-paste the method body between the
> library implementation and the proxy object), but may miss some edge
> cases.
> 
> Good luck!
> 
>> On 2011-07-05, at 1:34 PM, Matthew Weier O'Phinney wrote:
>> 
>>> -- Dominik Gehl <[email protected]> wrote
>>> (on Tuesday, 05 July 2011, 12:56 PM -0400):
>>>> I discovered a bug in Zend_Mail_Protocol_Imap::_decodeLine back in
>>>> April 2010 and created a ticket for it:
>>>> http://framework.zend.com/issues/browse/ZF-9624. I also added at that
>>>> time a possible fix for it to the ticket ... Unfortunately, the bug is
>>>> still open ... Is there anything else I can do in order for the patch
>>>> to get accepted ? Someone I should contact directly ?
>>> 
>>> Please attach a unit test with assertions showing the behavior desired.
>>> 
>>> -- 
>>> Matthew Weier O'Phinney
>>> Project Lead            | [email protected]
>>> Zend Framework          | http://framework.zend.com/
>>> PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc
>>> 
>>> -- 
>>> List: [email protected]
>>> Info: http://framework.zend.com/archives
>>> Unsubscribe: [email protected]
>>> 
>>> 
>> 
> 
> -- 
> Matthew Weier O'Phinney
> Project Lead            | [email protected]
> Zend Framework          | http://framework.zend.com/
> PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc
> 
> -- 
> List: [email protected]
> Info: http://framework.zend.com/archives
> Unsubscribe: [email protected]
> 
> 


--
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]


Reply via email to