[TYPO3-dev] Problem Mocking t3lib

Oliver Klee typo3-german-02 at oliverklee.de
Tue Dec 4 14:34:46 CET 2012


Hi Federico,

Am 28.11.2012 17:09, schrieb Federico Bernardin:
> I try to mocking with tx_phpunit the class t3lib_mail_Message to verify that a specified method will be executed.
> But I have the error below:
> Fatal error: Call to a member function defineOrdering() on a non-object in xxxxxxxxxxxxxxx/typo3/contrib/swiftmailer/classes/Swift/Mime/SimpleMessage.php on line 38

please check the corresponding line:

$this->_headers->defineOrdering(

$this->_headers is set via a constructor parameter in the parent class:

  public function __construct(Swift_Mime_HeaderSet $headers,
    Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache,
    Swift_Mime_Grammar $grammar)
  {
    $this->_cacheKey = uniqid();
    $this->_cache = $cache;
    $this->_headers = $headers;

So you'll either need to pass the constructor parameter ...

$mock = $this->getMock(
  'Swift_Mime_SimpleMessage', array(...), array($headers, $encoder ...)
);

... or skip the calling the original constructor:

$mock = $this->getMock(
  'Swift_Mime_SimpleMessage', array(...), array(), '', FALSE
);

Hope this helps.

All the best,


Oli
-- 
Certified TYPO3 Integrator | TYPO3 Security Team Member



More information about the TYPO3-dev mailing list