1 回答

TA貢獻(xiàn)1804條經(jīng)驗(yàn) 獲得超7個(gè)贊
的目的getMockForTrait
是獨(dú)立測(cè)試特征。您必須模擬該方法PagePublishValidator
:
public function testPreUpdateWithChildPageAndNewParent()
{
? ? $rootPage = $this->buildPage('', 'root');
? ? $validator = $this->getMockBuilder(PagePublishValidator::class)
? ? ? ? ->setMethods(['getPrevious'])
? ? ? ? ->setConstructorArgs([PageEventHandler::PAGE_TYPE_PRODUCT_LIST])
? ? ? ? ->getMock();
? ? $validator->expects($this->once())
? ? ? ? ->method('getPrevious')
? ? ? ? ->with($rootPage)
? ? ? ? ->willReturn($rootPage);
? ? $handler = new PageEventHandler(
? ? ? ? $this->createAssertingMockProducer([], 0),
? ? ? ? new NullProducer(),
? ? ? ? $validator
? ? );
? ? $handler->preUpdate($rootPage);
}
- 1 回答
- 0 關(guān)注
- 121 瀏覽
添加回答
舉報(bào)