markTestSkipped('Skipped on HHVM. Will be fixed in MAGETWO-45033'); } $this->formatter = $this->createMock(Formatter::class); $this->domFactory = $this->createMock(DomDocumentFactory::class); $this->xsltProcessorFactory = $this->createMock(XsltProcessorFactory::class); $this->command = new XmlConverterCommand($this->formatter, $this->domFactory, $this->xsltProcessorFactory); } /** * @return void */ public function testExecute(): void { $domXml = $this->createMock(\DOMDocument::class); $domXsl = clone $domXml; $domXml->expects($this->once())->method('load')->with('file.xml'); $domXsl->expects($this->once())->method('load')->with('file.xsl'); $this->domFactory ->method('create') ->willReturnOnConsecutiveCalls($domXml, $domXsl); $xsltProcessor = $this->createMock(\XSLTProcessor::class); $xsltProcessor->expects($this->once())->method('transformToXml')->with($domXml)->willReturn('XML'); $this->xsltProcessorFactory->expects($this->once())->method('create')->willReturn($xsltProcessor); $this->formatter->expects($this->once())->method('format')->with('XML')->willReturn('result'); $commandTester = new CommandTester($this->command); $commandTester->execute( [ XmlConverterCommand::XML_FILE_ARGUMENT => 'file.xml', XmlConverterCommand::PROCESSOR_ARGUMENT => 'file.xsl' ] ); $this->assertStringContainsString('result', $commandTester->getDisplay()); } /** * @return void */ public function testWrongParameter(): void { $this->expectException('RuntimeException'); $this->expectExceptionMessage('Not enough arguments'); $commandTester = new CommandTester($this->command); $commandTester->execute([]); } }