markTestSkipped('Skipped on HHVM. Will be fixed in MAGETWO-45033');
        }
        $urnResolver = new \Magento\Framework\Config\Dom\UrnResolver();
        $this->schemaFile = $urnResolver->getRealPath(
            'urn:magento:module:Magento_Integration:etc/integration/config.xsd'
        );
    }
    /**
     * @param string $fixtureXml
     * @param array $expectedErrors
     * @dataProvider exemplarXmlDataProvider
     */
    public function testExemplarXml($fixtureXml, array $expectedErrors)
    {
        $validationStateMock = $this->createMock(\Magento\Framework\Config\ValidationStateInterface::class);
        $validationStateMock->method('isValidationRequired')
            ->willReturn(true);
        $messageFormat = '%message%';
        $dom = new \Magento\Framework\Config\Dom($fixtureXml, $validationStateMock, [], null, null, $messageFormat);
        $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()
    {
        return [
            /** Valid configurations */
            'valid' => [
                '
                    
                        test-integration@magento.com
                        https://endpoint.url
                        http://www.example.com/identity
                    
                ',
                [],
            ],
            'valid with several entities' => [
                '
                    
                        test-integration1@magento.com
                        http://endpoint.url
                        http://www.example.com/identity
                    
                    
                        test-integration2@magento.com
                    
                ',
                [],
            ],
            /** Missing required elements */
            'empty root node' => [
                '',
                ["Element 'integrations': Missing child element(s). Expected is ( integration )."],
            ],
            'empty integration' => [
                '
                    
                ',
                ["Element 'integration': Missing child element(s). Expected is ( email )."],
            ],
            'integration without email' => [
                '
                    
                        http://endpoint.url
                        http://www.example.com/identity
                    
                ',
                ["Element 'endpoint_url': This element is not expected. Expected is ( email )."],
            ],
            /** Empty nodes */
            'empty email' => [
                '
                    
                        
                        http://endpoint.url
                        http://www.example.com/identity
                    
                ',
                [
                    "Element 'email': [facet 'pattern'] The value '' is not " .
                    "accepted by the pattern '[^@]+@[^\.]+\..+'.",
                    "Element 'email': '' is not a valid value of the atomic type 'emailType'."
                ],
            ],
            'endpoint_url is empty' => [
                '
                    
                        test-integration1@magento.com
                        
                    
                ',
                [
                    "Element 'endpoint_url': [facet 'minLength'] The value has a length of '0'; this underruns" .
                    " the allowed minimum length of '4'.",
                    "Element 'endpoint_url': '' is not a valid value of the atomic type 'urlType'."
                ],
            ],
            'identity_link_url is empty' => [
                '
                    
                        test-integration1@magento.com
                        http://endpoint.url
                        
                    
                ',
                [
                    "Element 'identity_link_url': [facet 'minLength'] The value has a length of '0'; this underruns" .
                    " the allowed minimum length of '4'.",
                    "Element 'identity_link_url': '' is not a valid value of the atomic type 'urlType'."
                ],
            ],
            /** Invalid structure */
            'irrelevant root node' => [
                '',
                ["Element 'integration': No matching global declaration available for the validation root."],
            ],
            'irrelevant node in root' => [
                '
                    
                        test-integration1@magento.com
                        http://endpoint.url
                        http://www.example.com/identity
                    
                    
                ',
                ["Element 'invalid': This element is not expected. Expected is ( integration )."],
            ],
            'irrelevant node in integration' => [
                '
                    
                        test-integration1@magento.com
                        http://endpoint.url
                        http://www.example.com/identity
                        
                    
                ',
                ["Element 'invalid': This element is not expected."],
            ],
            'irrelevant node in authentication' => [
                '
                    
                        test-integration1@magento.com
                        http://endpoint.url
                        http://www.example.com/identity
                        
                    
                ',
                ["Element 'invalid': This element is not expected."],
            ],
            /** Excessive attributes */
            'invalid attribute in root' => [
                '
                    
                        test-integration1@magento.com
                        http://endpoint.url
                        http://www.example.com/identity
                    
                ',
                ["Element 'integrations', attribute 'invalid': The attribute 'invalid' is not allowed."],
            ],
            'invalid attribute in integration' => [
                '
                    
                        test-integration1@magento.com
                        http://endpoint.url
                        http://www.example.com/identity
                    
                ',
                ["Element 'integration', attribute 'invalid': The attribute 'invalid' is not allowed."],
            ],
            'invalid attribute in email' => [
                '
                    
                        test-integration1@magento.com
                        http://endpoint.url
                        http://www.example.com/identity
                    
                ',
                ["Element 'email', attribute 'invalid': The attribute 'invalid' is not allowed."],
            ],
            'invalid attribute in endpoint_url' => [
                '
                    
                        test-integration1@magento.com
                        http://endpoint.url
                        http://www.example.com/identity
                    
                ',
                ["Element 'endpoint_url', attribute 'invalid': The attribute 'invalid' is not allowed."],
            ],
            'invalid attribute in identity_link_url' => [
                '
                    
                        test-integration1@magento.com
                        http://endpoint.url
                        http://endpoint.url
                    
                ',
                ["Element 'identity_link_url', attribute 'invalid': The attribute 'invalid' is not allowed."],
            ],
            /** Missing or empty required attributes */
            'integration without name' => [
                '
                    
                        test-integration1@magento.com
                        http://endpoint.url
                        http://www.example.com/identity
                    
                ',
                ["Element 'integration': The attribute 'name' is required but missing."],
            ],
            'integration with empty name' => [
                '
                    
                        test-integration1@magento.com
                        http://endpoint.url
                        http://www.example.com/identity
                    
                ',
                [
                    "Element 'integration', attribute 'name': [facet 'minLength'] The value '' has a length of '0'; " .
                    "this underruns the allowed minimum length of '2'.",
                    "Element 'integration', attribute 'name': " .
                    "'' is not a valid value of the atomic type 'integrationNameType'."
                ],
            ],
            /** Invalid values */
            'invalid email' => [
                '
                    
                        invalid
                        http://endpoint.url
                        http://www.example.com/identity
                    
                ',
                [
                    "Element 'email': [facet 'pattern'] The value 'invalid' " .
                    "is not accepted by the pattern '[^@]+@[^\.]+\..+'.",
                    "Element 'email': 'invalid' is not a valid value of the atomic type 'emailType'."
                ],
            ]
        ];
    }
}