Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
framework
TestFramework
Test
Unit
Unit
Utility
XsdValidatorTest.php
Go to the documentation of this file.
1
<?php
6
namespace
Magento\Framework\TestFramework\Test\Unit\Unit\Utility
;
7
8
class
XsdValidatorTest
extends
\PHPUnit\Framework\TestCase
9
{
13
protected
$_validator
;
14
19
protected
$_xsdSchema
;
20
21
protected
function
setUp
()
22
{
23
if
(!
function_exists
(
'libxml_set_external_entity_loader'
)) {
24
$this->markTestSkipped(
'Skipped on HHVM. Will be fixed in MAGETWO-45033'
);
25
}
26
$this->_validator = new \Magento\Framework\TestFramework\Unit\Utility\XsdValidator();
27
$this->_xsdSchema = realpath(
__DIR__
.
'/_files/valid.xsd'
);
28
}
29
30
public
function
testValidXml
()
31
{
32
$xmlFile = realpath(
__DIR__
.
'/_files/valid.xml'
);
33
$xmlString =
file_get_contents
($xmlFile);
34
35
$this->assertEquals([], $this->_validator->validate($this->_xsdSchema, $xmlString));
36
}
37
38
public
function
testInvalidXml
()
39
{
40
$xmlFile = realpath(
__DIR__
.
'/_files/invalid.xml'
);
41
$expected = [
42
"Element 'block', attribute 'type': The attribute 'type' is not allowed.\nLine: 9\n"
,
43
"Element 'actions': This element is not expected. Expected is ( property ).\nLine: 10\n"
,
44
];
45
$xmlString =
file_get_contents
($xmlFile);
46
47
$this->assertEquals($expected, $this->_validator->validate($this->_xsdSchema, $xmlString));
48
}
49
}
__DIR__
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition:
_bootstrap.php:60
Magento\Framework\TestFramework\Test\Unit\Unit\Utility\XsdValidatorTest\$_xsdSchema
$_xsdSchema
Definition:
XsdValidatorTest.php:19
Magento\Framework\TestFramework\Test\Unit\Unit\Utility\XsdValidatorTest\setUp
setUp()
Definition:
XsdValidatorTest.php:21
Magento\Framework\TestFramework\Test\Unit\Unit\Utility
Definition:
XsdValidatorTest.php:6
Magento\Framework\TestFramework\Test\Unit\Unit\Utility\XsdValidatorTest\$_validator
$_validator
Definition:
XsdValidatorTest.php:13
Magento\Framework\TestFramework\Test\Unit\Unit\Utility\XsdValidatorTest\testValidXml
testValidXml()
Definition:
XsdValidatorTest.php:30
Magento\Framework\TestFramework\Test\Unit\Unit\Utility\XsdValidatorTest\testInvalidXml
testInvalidXml()
Definition:
XsdValidatorTest.php:38
Magento\Framework\Filesystem\Driver\file_get_contents
file_get_contents()
Definition:
http_mock.php:15
Magento\Deploy\Console\Command\function_exists
function_exists($func)
Definition:
FunctionExistMock.php:13
Magento\Framework\TestFramework\Test\Unit\Unit\Utility\XsdValidatorTest
Definition:
XsdValidatorTest.php:8