/** * @param string|int|float $sortOrder * @dataProvider getInvalidSortOrder * @expectedException \Magento\Framework\Exception\InputException * @expectedExceptionMessage Sort order must be a positive integer. */ public function testIsValidThrowsExceptionIfSortOrderIsInvalid($sortOrder) { $sampleContentData = ['title' => 'Title', 'sort_order' => $sortOrder, 'sample_type' => 'file']; $this->fileValidatorMock->expects($this->any())->method('isValid')->will($this->returnValue(true)); $this->urlValidatorMock->expects($this->any())->method('isValid')->will($this->returnValue(true)); $this->validator->isValid($this->getSampleContentMock($sampleContentData)); }
/** * @param string|int|float $numberOfDownloads * @dataProvider getInvalidNumberOfDownloads * @expectedException \Magento\Framework\Exception\InputException * @expectedExceptionMessage Number of downloads must be a positive integer. */ public function testIsValidThrowsExceptionIfNumberOfDownloadsIsInvalid($numberOfDownloads) { $linkContentData = ['title' => 'Title', 'sort_order' => 1, 'price' => 10.5, 'shareable' => true, 'number_of_downloads' => $numberOfDownloads, 'link_type' => 'file', 'sample_type' => 'file']; $this->urlValidatorMock->expects($this->any())->method('isValid')->will($this->returnValue(true)); $this->fileValidatorMock->expects($this->any())->method('isValid')->will($this->returnValue(true)); $contentMock = $this->getLinkContentMock($linkContentData); $this->validator->isValid($contentMock); }
/** * @expectedException \Magento\Framework\Exception\InputException * @expectedExceptionMessage Provided file name contains forbidden characters. * @dataProvider getInvalidNames * @param string $fileName */ public function testIsValidThrowsExceptionIfProvidedImageNameContainsForbiddenCharacters($fileName) { $this->fileContentMock->expects($this->any())->method('getFileData')->will($this->returnValue(base64_encode('test content'))); $this->fileContentMock->expects($this->any())->method('getName')->will($this->returnValue($fileName)); $this->assertTrue($this->validator->isValid($this->fileContentMock)); }