markTestSkipped('Skipped on HHVM. Will be fixed in MAGETWO-45033'); } $urnResolver = new \Magento\Framework\Config\Dom\UrnResolver(); $this->_schemaFile = $urnResolver->getRealPath('urn:magento:framework-message-queue:etc/publisher.xsd'); } /** * @param string $fixtureXml * @param array $expectedErrors * @dataProvider exemplarXmlDataProvider */ public function testExemplarXml($fixtureXml, array $expectedErrors) { $validationState = $this->createMock(\Magento\Framework\Config\ValidationStateInterface::class); $validationState->expects($this->any()) ->method('isValidationRequired') ->willReturn(true); $messageFormat = '%message%'; $dom = new \Magento\Framework\Config\Dom($fixtureXml, $validationState, [], null, null, $messageFormat); $actualErrors = []; $actualResult = $dom->validate($this->_schemaFile, $actualErrors); $this->assertEquals(empty($expectedErrors), $actualResult, "Validation result is invalid."); $this->assertEquals($expectedErrors, $actualErrors, "Validation errors does not match."); } /** * @return array * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function exemplarXmlDataProvider() { // @codingStandardsIgnoreStart return [ /** Valid configurations */ 'valid' => [ ' ', [], ], 'non unique publisher topic' => [ ' ', [ "Element 'publisher': Duplicate key-sequence ['topic.message.queue.config.01'] in unique identity-constraint 'unique-publisher-topic'." ], ], 'non unique publisher connection name' => [ ' ', [ "Element 'connection': Duplicate key-sequence ['amqp'] in unique identity-constraint 'unique-connection-name'." ], ], 'missed required publisher attribute' => [ ' ', [ "Element 'publisher': The attribute 'topic' is required but missing." ], ], 'missed required connection attribute' => [ ' ', [ "Element 'connection': The attribute 'name' is required but missing." ], ], 'unexpected publisher element' => [ ' 20 ', [ "Element 'unexpected': This element is not expected. Expected is ( publisher )." ], ], 'unexpected connection element' => [ ' 20 ', [ "Element 'unexpected': This element is not expected. Expected is ( connection )." ], ], 'unexpected publisher attribute' => [ ' ', [ "Element 'publisher', attribute 'unexpected': The attribute 'unexpected' is not allowed.", ], ], 'unexpected connection attribute' => [ ' ', [ "Element 'connection', attribute 'unexpected': The attribute 'unexpected' is not allowed.", ], ], 'invalid connection attribute value' => [ ' ', [ "Element 'connection', attribute 'disabled': 'disabled' is not a valid value of the atomic type 'xs:boolean'.", ], ], 'invalid publisher attribute value' => [ ' ', [ "Element 'publisher', attribute 'disabled': 'disabled' is not a valid value of the atomic type 'xs:boolean'.", ], ], ]; // @codingStandardsIgnoreEnd } }