@@ -121,15 +121,15 @@ public function testAddEmailToProfile()
121121 */
122122 public function testGetContentForPlain ()
123123 {
124- $ content = $ this ->getMock ('Zend_Mime_Part ' , array ('getRawContent ' ), array (), '' , false );;
125- $ content ->expects ($ this ->once ())->method ('getRawContent ' )->willReturn ('raw content ' );
124+ $ mimePart = $ this ->getMock ('Zend_Mime_Part ' , null , array (), '' , false );;
126125
127126 $ mail = $ this ->getMock ('Zend_Mail ' , array ('getBodyText ' , 'getBodyHtml ' ));
128- $ mail ->expects ($ this ->once ())->method ('getBodyText ' )->willReturn ($ content );
127+ $ mail ->expects ($ this ->once ())->method ('getBodyText ' )->willReturn ($ mimePart );
129128 $ mail ->expects ($ this ->never ())->method ('getBodyHtml ' );
130129
131- $ model = $ this ->getModelMock ('core/email_template ' , array ('isPlain ' ));
130+ $ model = $ this ->getModelMock ('core/email_template ' , array ('isPlain ' , ' getPartDecodedContent ' ));
132131 $ model ->expects ($ this ->any ())->method ('isPlain ' )->willReturn (true );
132+ $ model ->expects ($ this ->once ())->method ('getPartDecodedContent ' )->with ($ mimePart )->willReturn ('raw content ' );
133133
134134 $ actual = $ model ->getContent ($ mail );
135135 $ this ->assertEquals ('raw content ' , $ actual );
@@ -141,15 +141,15 @@ public function testGetContentForPlain()
141141 */
142142 public function testGetContentForNonPlain ()
143143 {
144- $ content = $ this ->getMock ('Zend_Mime_Part ' , array ('getRawContent ' ), array (), '' , false );;
145- $ content ->expects ($ this ->once ())->method ('getRawContent ' )->willReturn ('raw html content ' );
144+ $ mimePart = $ this ->getMock ('Zend_Mime_Part ' , null , array (), '' , false );;
146145
147146 $ mail = $ this ->getMock ('Zend_Mail ' , array ('getBodyText ' , 'getBodyHtml ' ));
148147 $ mail ->expects ($ this ->never ())->method ('getBodyText ' );
149- $ mail ->expects ($ this ->once ())->method ('getBodyHtml ' )->willReturn ($ content );
148+ $ mail ->expects ($ this ->once ())->method ('getBodyHtml ' )->willReturn ($ mimePart );
150149
151- $ model = $ this ->getModelMock ('core/email_template ' , array ('isPlain ' ));
150+ $ model = $ this ->getModelMock ('core/email_template ' , array ('isPlain ' , ' getPartDecodedContent ' ));
152151 $ model ->expects ($ this ->any ())->method ('isPlain ' )->willReturn (false );
152+ $ model ->expects ($ this ->once ())->method ('getPartDecodedContent ' )->with ($ mimePart )->willReturn ('raw html content ' );
153153
154154 $ actual = $ model ->getContent ($ mail );
155155 $ this ->assertEquals ('raw html content ' , $ actual );
@@ -178,6 +178,33 @@ public function testGetContentForQueue()
178178 }
179179
180180
181+ /**
182+ * @covers Sheep_Debug_Model_Core_Email_Template_Capture::getPartDecodedContent
183+ */
184+ public function testGetPartDecodedContent ()
185+ {
186+ // this condition doesn't seem right to live in a test
187+ $ zendWithGetRawContent = Zend_Version::compareVersion ('1.12.0 ' ) <= 0 ;
188+
189+ $ mimePart = $ this ->getMock ('Zend_Mime_Part ' , array (), array (), '' , false );
190+ if ($ zendWithGetRawContent ) {
191+ $ mimePart ->expects ($ this ->any ())->method ('getRawContent ' )->willReturn ('raw content ' );
192+ } else {
193+ $ mimePart ->expects ($ this ->any ())->method ('getContent ' )->willReturn ('content ' );
194+ }
195+
196+ $ model = $ this ->getModelMock ('core/email_template ' , array ('isPlain ' ));
197+ $ actual = $ model ->getPartDecodedContent ($ mimePart );
198+
199+ if ($ zendWithGetRawContent ) {
200+ $ this ->assertEquals ('raw content ' , $ actual );
201+ } else {
202+ $ this ->assertEquals ('content ' , $ actual );
203+
204+ }
205+ }
206+
207+
181208 /**
182209 * @covers Sheep_Debug_Model_Core_Email_Template_Capture::decodeSubject
183210 */
@@ -188,6 +215,9 @@ public function testDecodeSubject()
188215 }
189216
190217
218+ /**
219+ * @covers Sheep_Debug_Model_Core_Email_Template_Capture::decodeSubject
220+ */
191221 public function testDecodeSubjectForQueue ()
192222 {
193223 $ queue = $ this ->getModelMock ('core/email_queue ' , array ('getMessageParameters ' ));
0 commit comments