public function testGetValueWhenDateCannotBeRepresentedUsingIso8601() { $attributeValue = '11-11-2011'; $dateFormat = 'dd-mm-yyyy'; $object = new \Magento\Framework\Object(['datetime' => $attributeValue]); $this->localeDateMock->expects($this->once())->method('getDateFormat')->with(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM)->will($this->returnValue($dateFormat)); $this->attributeMock->expects($this->any())->method('getData')->with('frontend_input')->will($this->returnValue('text')); $dateMock = $this->getMock('\\Magento\\Framework\\Stdlib\\DateTime\\DateInterface'); $dateMock->expects($this->once())->method('toString')->with($dateFormat)->will($this->returnValue($attributeValue)); $this->localeDateMock->expects($this->at(1))->method('date')->will($this->throwException(new \Exception('Wrong Date'))); $this->localeDateMock->expects($this->at(2))->method('date')->with($attributeValue, null, null, false)->will($this->returnValue($dateMock)); $this->assertEquals($attributeValue, $this->model->getValue($object)); }