1 回答

TA貢獻1804條經驗 獲得超7個贊
的目的getMockForTrait
是獨立測試特征。您必須模擬該方法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 關注
- 124 瀏覽
添加回答
舉報