/** * @expectedException \InvalidArgumentException */ public function testCreateWithException() { $filterClassPrefix = 'Magento\\Framework\\Data\\Form\\Filter\\'; $filterCode = 'Undefined'; $data = []; $filter = new \stdClass(); $this->objectManager->expects($this->once())->method('create')->with($filterClassPrefix . ucfirst($filterCode), $data)->willReturn($filter); $this->factory->create($filterCode, $data); }
public function testSetDateWithFilter() { $date = '2014-01-01'; $filterCode = 'date'; $this->attribute->expects($this->once())->method('getInputFilter')->willReturn($filterCode); $filterMock = $this->getMockBuilder('Magento\\Framework\\Data\\Form\\Filter\\Date')->disableOriginalConstructor()->getMock(); $filterMock->expects($this->once())->method('outputFilter')->with($date)->willReturn(self::DATE); $this->filterFactory->expects($this->once())->method('create')->with($filterCode, ['format' => self::DATE_FORMAT])->willReturn($filterMock); $this->_block->setDate($date); }
/** * Return Data Form Filter or false * * @return \Magento\Framework\Data\Form\Filter\FilterInterface|false */ protected function getFormFilter() { $attributeMetadata = $this->_getAttribute('dob'); $filterCode = $attributeMetadata->getInputFilter(); if ($filterCode) { $data = []; if ($filterCode == 'date') { $data['format'] = $this->getDateFormat(); } $filter = $this->filterFactory->create($filterCode, $data); return $filter; } return false; }