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]>:
> 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
>