/** * @dataProvider notIsValidDataProvider * @param $data * @param $result */ public function testNotIsValid($data, $result) { $provider = $this->getMockForAbstractClass('\\Magento\\CheckoutAgreements\\Model\\AgreementsProviderInterface'); $provider->expects($this->once())->method('getRequiredAgreementIds')->will($this->returnValue([1, 3, '4'])); $this->object = $this->objectManagerHelper->getObject('Magento\\CheckoutAgreements\\Model\\AgreementsValidator', ['list' => [$provider]]); $this->assertEquals($result, $this->object->isValid($data)); }
/** * @param int[] $agreements * @throws \Magento\Framework\Exception\CouldNotSaveException * @return void */ protected function validateAgreements($agreements) { if (!$this->agreementsValidator->isValid($agreements)) { throw new \Magento\Framework\Exception\CouldNotSaveException(__('Please agree to all the terms and conditions before placing the order.')); } }