PhpUnit如何从对象获取值和参数

时间:2018-09-18 10:24:32

标签: magento phpunit magento2

我有这个测试:

public function testSubscribe()
{

    $this->subscriberFactoryMock->expects($this->any())
        ->method('create')
        ->will($this->returnValue($this->subscriberMock));

    $this->subscriberMock->expects($this->any())
        ->method('loadByEmail')
        ->will($this->returnValue(1));

    $this->subscriberMock->expects($this->any())
        ->method('getId')
        ->will($this->returnValue(10));

    $this->subscriberMock->expects($this->any())
        ->method('subscribe')
        ->with('piotr.gazda@monogo.pl');
    $this->resultMock->expects($this->any())
        ->method('setData')
        ->with('result',1);
    $this->resultMock->setData('result',1);

    $this->newsletterRequestManager->subscribe(1,'piotr.gazda@monogo.pl');

}

$ resultMock 是Mock * Magento \ Framework \ DataObject *

如何从DataObject中获取结果值

0 个答案:

没有答案