/** * Test logging of bad content links. * * @dataProvider providerBadContentLink */ public function testConvertBadContentLink($input, $output, $contentId, $exception, $logType, $logMessage) { $inputDocument = new DOMDocument(); $inputDocument->loadXML($input); $contentService = $this->getMockContentService(); $locationService = $this->getMockLocationService(); $urlAliasRouter = $this->getMockUrlAliasRouter(); $logger = $this->getMock('Psr\\Log\\LoggerInterface'); $logger->expects($this->once())->method($logType)->with($this->equalTo($logMessage)); $contentService->expects($this->once())->method('loadContentInfo')->with($this->equalTo($contentId))->will($this->throwException($exception)); $converter = new Link($locationService, $contentService, $urlAliasRouter, $logger); $outputDocument = $converter->convert($inputDocument); $expectedOutputDocument = new DOMDocument(); $expectedOutputDocument->loadXML($output); $this->assertEquals($expectedOutputDocument, $outputDocument); }
/** * Test logging of bad content links * * @dataProvider providerBadContentLink */ public function testConvertBadContentLink($xmlString, $contentId, $exception, $logType, $logMessage) { $xmlDoc = new \DOMDocument(); $xmlDoc->loadXML($xmlString); $contentService = $this->getMockContentService(); $locationService = $this->getMockLocationService(); $urlAliasRouter = $this->getMockUrlAliasRouter(); $logger = $this->getMock('Psr\\Log\\LoggerInterface'); $logger->expects($this->once())->method($logType)->with($this->equalTo($logMessage)); $contentService->expects($this->once())->method('loadContentInfo')->with($this->equalTo($contentId))->will($this->throwException($exception)); $converter = new Link($locationService, $contentService, $urlAliasRouter, $logger); $converter->convert($xmlDoc); }