Hi Tomas,

thank you for your answer.
I also thought about this possibility, but had hoped that there would be an 
easier way.
I have not written any tests yet and would now have to adjust each class of 
mine.
If there is no other option then I will probably have to do it that way.

Best regards
Markus

Von: Tomas Kvietkauskas <[email protected]>
Datum: Mittwoch, 3. Januar 2018 um 17:16
An: "[email protected]" <[email protected]>
Betreff: Re: Testing methods with parent call

Hello Markus,
in short, its possible:
move parent::method() to its own private function e.g.
private function callParentSend() {
  parent::send();
}
then call callParentSend() in send method

..
$this->callParentSend();
..

then callParentSend() function can be mocked or ignored

-
Tomas

2018-01-03 18:11 GMT+02:00 Lehmann Markus 
<[email protected]<mailto:[email protected]>>:
Hello everybody,

First of all, I wish you all a happy new year.
I'm having a testing problem and I hope you can help me with that since I have 
not found anything useful so far.
I am currently writing my first tests and I do not know how to deal with the 
case if a method calls its parent method.
How can you test something like that? I do not want to test the code of all 
parent classes.
Especially, more and more parents are added per module.
Example:

class test__newsletter extends test__newsletter_parent
{

  public function send()
  {
    parent::send();
    if ($this->_iNewsletterStatus === 1 || $this->_iNewsletterStatus === 2) {
      $aParams = oxRegistry::getConfig()->getRequestParameter("editval");
      $this->getUtils()->callTestAsync(
        test_aws_api_constants::EVENT_OXID_NL_FORM_DOI,
        $aParams['oxuser__oxusername']
      )
      ;
    }
  }

Is it possible to mock the parent call?

Thank you very much and greetings
Markus

Reply via email to