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/topology.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' => [ ' 10 10 ', [], ], 'non-unique-exchange' => [ ' ', [ "Element 'exchange': Duplicate key-sequence ['ex01', 'amqp'] in unique identity-constraint 'unique-exchange-name-connection'." ], ], 'non-unique-exchange-binding' => [ ' ', [ "Element 'binding': Duplicate key-sequence ['bind01'] in unique identity-constraint 'unique-binding-id'." ], ], 'invalid-destination-type-binding' => [ ' ', [ "Element 'binding', attribute 'destinationType': [facet 'enumeration'] The value 'topic' is not an element of the set {'queue'}.", "Element 'binding', attribute 'destinationType': 'topic' is not a valid value of the atomic type 'destinationType'." ], ], 'invalid-exchange-type-binding' => [ ' ', [ "Element 'exchange', attribute 'type': [facet 'enumeration'] The value 'exchange' is not an element of the set {'topic'}.", "Element 'exchange', attribute 'type': 'exchange' is not a valid value of the atomic type 'exchangeType'." ], ], ]; // @codingStandardsIgnoreEnd } }