mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-12 07:11:42 +09:00
Added script to validate XML Query/Schema Language files
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@10544 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
532a6a0645
commit
6394a5c278
33 changed files with 4202 additions and 0 deletions
23
tools/dbxml_validator/tests/data/checkMissingPipe.xml
Normal file
23
tools/dbxml_validator/tests/data/checkMissingPipe.xml
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<query id="checkMissingPipe" action="select">
|
||||
<tables>
|
||||
<table name="tableName" alias="alias" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="columnName" alias="alias" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="like_prefix" column="column1" var="variable" filter="user_id" default="default" notnull="notnull" minlength="10" maxlength="1000" pipe="AND"/>
|
||||
<group>
|
||||
<condition operation="notlike_tail" column="column" var="variable" filter="numbers" default="default" notnull="notnull" minlength ="0" maxlength="10000" pipe="and"/>
|
||||
</group>
|
||||
</conditions>
|
||||
<navigation>
|
||||
<index var="var" default="default" order="desc|asc" />
|
||||
<list_count var="var" default="25" />
|
||||
<page_count var="var" default="5" />
|
||||
<page var="var" default="2" />
|
||||
</navigation>
|
||||
<groups>
|
||||
<group column="GroupBy daesang" />
|
||||
</groups>
|
||||
</query>
|
||||
24
tools/dbxml_validator/tests/data/dupListCount.xml
Normal file
24
tools/dbxml_validator/tests/data/dupListCount.xml
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<query id="dupListCount" action="select">
|
||||
<tables>
|
||||
<table name="tableName" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="columnName" alias="alias" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="like_prefix" column="column1" var="variable" filter="user_id" default="default" notnull="notnull" minlength="10" maxlength="1000" pipe="AND"/>
|
||||
<group pipe="and">
|
||||
<condition operation="notlike_tail" column="column" var="variable" filter="numbers" default="default" notnull="notnull" minlength ="0" maxlength="10000" pipe="and"/>
|
||||
</group>
|
||||
</conditions>
|
||||
<navigation>
|
||||
<index var="var" default="default" order="desc|asc" />
|
||||
<list_count var="var" default="25" />
|
||||
<list_count var="var" default="25" />
|
||||
<page_count var="var" default="5" />
|
||||
<page var="var" default="2" />
|
||||
</navigation>
|
||||
<groups>
|
||||
<group column="GroupBy daesang" />
|
||||
</groups>
|
||||
</query>
|
||||
25
tools/dbxml_validator/tests/data/dupPage.xml
Normal file
25
tools/dbxml_validator/tests/data/dupPage.xml
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<query id="dupPage" action="select">
|
||||
<tables>
|
||||
<table name="tableName" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="columnName" alias="alias" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="like_prefix" column="column1" var="variable" filter="user_id" default="default" notnull="notnull" minlength="10" maxlength="1000" pipe="AND"/>
|
||||
<group pipe="and">
|
||||
<condition operation="notlike_tail" column="column" var="variable" filter="numbers" default="default" notnull="notnull" minlength ="0" maxlength="10000" pipe="and"/>
|
||||
</group>
|
||||
</conditions>
|
||||
<navigation>
|
||||
<index var="var" default="default" order="desc|asc" />
|
||||
<list_count var="var" default="25" />
|
||||
<page_count var="var" default="5" />
|
||||
<page var="var" default="2" />
|
||||
<page var="var" default="2" />
|
||||
</navigation>
|
||||
<groups>
|
||||
<group column="GroupBy daesang" />
|
||||
</groups>
|
||||
</query>
|
||||
|
||||
24
tools/dbxml_validator/tests/data/dupPageCount.xml
Normal file
24
tools/dbxml_validator/tests/data/dupPageCount.xml
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<query id="dupPageCount" action="select">
|
||||
<tables>
|
||||
<table name="tableName" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="columnName" alias="alias" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="like_prefix" column="column1" var="variable" filter="user_id" default="default" notnull="notnull" minlength="10" maxlength="1000" pipe="AND"/>
|
||||
<group pipe="and">
|
||||
<condition operation="notlike_tail" column="column" var="variable" filter="numbers" default="default" notnull="notnull" minlength ="0" maxlength="10000" pipe="and"/>
|
||||
</group>
|
||||
</conditions>
|
||||
<navigation>
|
||||
<index var="var" default="default" order="desc|asc" />
|
||||
<list_count var="var" default="25" />
|
||||
<page_count var="var" default="5" />
|
||||
<page_count var="var" default="5" />
|
||||
<page var="var" default="2" />
|
||||
</navigation>
|
||||
<groups>
|
||||
<group column="GroupBy daesang" />
|
||||
</groups>
|
||||
</query>
|
||||
35
tools/dbxml_validator/tests/data/dupTblName.xml
Normal file
35
tools/dbxml_validator/tests/data/dupTblName.xml
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<query id="dupTblName" action="select">
|
||||
<tables>
|
||||
<table name="tableName" />
|
||||
<table query="true" alias="tableName">
|
||||
<tables>
|
||||
<table name="documents" alias="documents" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="member_srl" alias="member_srl" />
|
||||
<column name="count(*)" alias="count" />
|
||||
</columns>
|
||||
<groups>
|
||||
<group column="member_srl" />
|
||||
</groups>
|
||||
</table>
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="columnName" alias="alias" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="like_prefix" column="column1" var="variable" filter="user_id" default="default" notnull="notnull" minlength="10" maxlength="1000" pipe="AND"/>
|
||||
<group pipe="and">
|
||||
<condition operation="notlike_tail" column="column" var="variable" filter="numbers" default="default" notnull="notnull" minlength ="0" maxlength="10000" pipe="and"/>
|
||||
</group>
|
||||
</conditions>
|
||||
<navigation>
|
||||
<index var="var" default="default" order="desc|asc" />
|
||||
<list_count var="var" default="25" />
|
||||
<page_count var="var" default="5" />
|
||||
<page var="var" default="2" />
|
||||
</navigation>
|
||||
<groups>
|
||||
<group column="GroupBy daesang" />
|
||||
</groups>
|
||||
</query>
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<query id="duplicateColumnsInSelect" action="select">
|
||||
<columns>
|
||||
<column name="count(*)" />
|
||||
<column name="count(*)" />
|
||||
</columns>
|
||||
<tables>
|
||||
<table name="tblName" />
|
||||
</tables>
|
||||
</query>
|
||||
27
tools/dbxml_validator/tests/data/emptyTableSubquery.xml
Normal file
27
tools/dbxml_validator/tests/data/emptyTableSubquery.xml
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<query id="emptyTableSubquery" action="select">
|
||||
<tables>
|
||||
<table name="tableName" />
|
||||
<table query="true">
|
||||
</table>
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="columnName" alias="alias" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="like_prefix" column="column1" var="variable" filter="user_id" default="default" notnull="notnull" minlength="10" maxlength="1000" pipe="AND"/>
|
||||
<group pipe="and">
|
||||
<condition operation="notlike_tail" column="column" var="variable" filter="numbers" default="default" notnull="notnull" minlength ="0" maxlength="10000" pipe="and"/>
|
||||
</group>
|
||||
</conditions>
|
||||
<navigation>
|
||||
<index var="var" default="default" order="desc|asc" />
|
||||
<list_count var="var" default="25" />
|
||||
<page_count var="var" default="5" />
|
||||
<page var="var" default="2" />
|
||||
</navigation>
|
||||
<groups>
|
||||
<group column="GroupBy daesang" />
|
||||
</groups>
|
||||
</query>
|
||||
|
||||
|
||||
38
tools/dbxml_validator/tests/data/joinedSubquery.xml
Normal file
38
tools/dbxml_validator/tests/data/joinedSubquery.xml
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<query id="joinedSubquery" action="select">
|
||||
<tables>
|
||||
<table name="tableName" />
|
||||
<table query="true" alias="tableSubquery" type="left join">
|
||||
<tables>
|
||||
<table name="documents" alias="documents" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="member_srl" alias="member_srl" />
|
||||
<column name="count(*)" alias="count" />
|
||||
</columns>
|
||||
<groups>
|
||||
<group column="member_srl" />
|
||||
</groups>
|
||||
</table>
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="columnName" alias="alias" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="like_prefix" column="column1" var="variable" filter="user_id" default="default" notnull="notnull" minlength="10" maxlength="1000" pipe="AND"/>
|
||||
<group pipe="and">
|
||||
<condition operation="notlike_tail" column="column" var="variable" filter="numbers" default="default" notnull="notnull" minlength ="0" maxlength="10000" pipe="and"/>
|
||||
</group>
|
||||
</conditions>
|
||||
<navigation>
|
||||
<index var="var" default="default" order="desc|asc" />
|
||||
<list_count var="var" default="25" />
|
||||
<page_count var="var" default="5" />
|
||||
<page var="var" default="2" />
|
||||
</navigation>
|
||||
<groups>
|
||||
<group column="GroupBy daesang" />
|
||||
</groups>
|
||||
</query>
|
||||
|
||||
|
||||
|
||||
29
tools/dbxml_validator/tests/data/joinedTableCondition.xml
Normal file
29
tools/dbxml_validator/tests/data/joinedTableCondition.xml
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<query id="joinedTableCondition" action="select">
|
||||
<tables>
|
||||
<table name="tableName" />
|
||||
<table alias="tableSubquery" type="left join">
|
||||
</table>
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="columnName" alias="alias" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="like_prefix" column="column1" var="variable" filter="user_id" default="default" notnull="notnull" minlength="10" maxlength="1000" pipe="AND"/>
|
||||
<group pipe="and">
|
||||
<condition operation="notlike_tail" column="column" var="variable" filter="numbers" default="default" notnull="notnull" minlength ="0" maxlength="10000" pipe="and"/>
|
||||
</group>
|
||||
</conditions>
|
||||
<navigation>
|
||||
<index var="var" default="default" order="desc|asc" />
|
||||
<list_count var="var" default="25" />
|
||||
<page_count var="var" default="5" />
|
||||
<page var="var" default="2" />
|
||||
</navigation>
|
||||
<groups>
|
||||
<group column="GroupBy daesang" />
|
||||
</groups>
|
||||
</query>
|
||||
|
||||
|
||||
|
||||
|
||||
36
tools/dbxml_validator/tests/data/namedTableSubquery.xml
Normal file
36
tools/dbxml_validator/tests/data/namedTableSubquery.xml
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<query id="namedTableSubquery" action="select">
|
||||
<tables>
|
||||
<table name="tableName" />
|
||||
<table query="true" name="tableSubqueryName">
|
||||
<tables>
|
||||
<table name="documents" alias="documents" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="member_srl" alias="member_srl" />
|
||||
<column name="count(*)" alias="count" />
|
||||
</columns>
|
||||
<groups>
|
||||
<group column="member_srl" />
|
||||
</groups>
|
||||
</table>
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="columnName" alias="alias" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="like_prefix" column="column1" var="variable" filter="user_id" default="default" notnull="notnull" minlength="10" maxlength="1000" pipe="AND"/>
|
||||
<group pipe="and">
|
||||
<condition operation="notlike_tail" column="column" var="variable" filter="numbers" default="default" notnull="notnull" minlength ="0" maxlength="10000" pipe="and"/>
|
||||
</group>
|
||||
</conditions>
|
||||
<navigation>
|
||||
<index var="var" default="default" order="desc|asc" />
|
||||
<list_count var="var" default="25" />
|
||||
<page_count var="var" default="5" />
|
||||
<page var="var" default="2" />
|
||||
</navigation>
|
||||
<groups>
|
||||
<group column="GroupBy daesang" />
|
||||
</groups>
|
||||
</query>
|
||||
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
<table name="tbl">
|
||||
<column name="col_name" type="text" />
|
||||
<!-- only number and bignumber types can have attribute 'auto_increment' -->
|
||||
<column name="col_name2" type="date" auto_increment="auto_increment" />
|
||||
</table>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<table name="tbl">
|
||||
<column name="col_name" type="text" />
|
||||
<!-- only FLOAT, CHAR and VARCHAR have size -->
|
||||
<column name="col_name2" type="number" size="5" />
|
||||
</table>
|
||||
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<table name="tbl">
|
||||
<column name="col_name" type="text" />
|
||||
<!-- VARCHAR type requires 'size' attribute -->
|
||||
<column name="col_name2" type="varchar" />
|
||||
</table>
|
||||
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<table name="tbl">
|
||||
<column name="col_name" type="text" />
|
||||
<!-- 'auto_increment' only supported by mysql, MSSql -->
|
||||
<column name="col_name2" type="number" auto_increment="auto_increment" />
|
||||
</table>
|
||||
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
<table name="tbl">
|
||||
<column name="col_name" type="text" />
|
||||
|
||||
<!-- type="tinytext" only supported by CUBRID -->
|
||||
<column name="col_name2" type="tinytext" />
|
||||
</table>
|
||||
|
||||
36
tools/dbxml_validator/tests/data/tableSubquery.xml
Normal file
36
tools/dbxml_validator/tests/data/tableSubquery.xml
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<query id="tableSubquery" action="select">
|
||||
<tables>
|
||||
<table name="tableName" />
|
||||
<table name="tableSubquery" alias="tableName2">
|
||||
<tables>
|
||||
<table name="documents" alias="documents" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="member_srl" alias="member_srl" />
|
||||
<column name="count(*)" alias="count" />
|
||||
</columns>
|
||||
<groups>
|
||||
<group column="member_srl" />
|
||||
</groups>
|
||||
</table>
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="columnName" alias="alias" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="like_prefix" column="column1" var="variable" filter="user_id" default="default" notnull="notnull" minlength="10" maxlength="1000" pipe="AND"/>
|
||||
<group pipe="and">
|
||||
<condition operation="notlike_tail" column="column" var="variable" filter="numbers" default="default" notnull="notnull" minlength ="0" maxlength="10000" pipe="and"/>
|
||||
</group>
|
||||
</conditions>
|
||||
<navigation>
|
||||
<index var="var" default="default" order="desc|asc" />
|
||||
<list_count var="var" default="25" />
|
||||
<page_count var="var" default="5" />
|
||||
<page var="var" default="2" />
|
||||
</navigation>
|
||||
<groups>
|
||||
<group column="GroupBy daesang" />
|
||||
</groups>
|
||||
</query>
|
||||
|
||||
37
tools/dbxml_validator/tests/data/unnamedTableSubquery.xml
Normal file
37
tools/dbxml_validator/tests/data/unnamedTableSubquery.xml
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<query id="unnamedTableSubquery" action="select">
|
||||
<tables>
|
||||
<table name="tableName" />
|
||||
<table query="true">
|
||||
<tables>
|
||||
<table name="documents" alias="documents" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="member_srl" alias="member_srl" />
|
||||
<column name="count(*)" alias="count" />
|
||||
</columns>
|
||||
<groups>
|
||||
<group column="member_srl" />
|
||||
</groups>
|
||||
</table>
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="columnName" alias="alias" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="like_prefix" column="column1" var="variable" filter="user_id" default="default" notnull="notnull" minlength="10" maxlength="1000" pipe="AND"/>
|
||||
<group pipe="and">
|
||||
<condition operation="notlike_tail" column="column" var="variable" filter="numbers" default="default" notnull="notnull" minlength ="0" maxlength="10000" pipe="and"/>
|
||||
</group>
|
||||
</conditions>
|
||||
<navigation>
|
||||
<index var="var" default="default" order="desc|asc" />
|
||||
<list_count var="var" default="25" />
|
||||
<page_count var="var" default="5" />
|
||||
<page var="var" default="2" />
|
||||
</navigation>
|
||||
<groups>
|
||||
<group column="GroupBy daesang" />
|
||||
</groups>
|
||||
</query>
|
||||
|
||||
|
||||
26
tools/dbxml_validator/tests/data/update.xml
Normal file
26
tools/dbxml_validator/tests/data/update.xml
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<query id="update" action="update">
|
||||
<tables>
|
||||
<table name="table1" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="column1" default="10"/>
|
||||
<column name="column2" default="12" />
|
||||
<column name="column3" default="13"/>
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="more" column="column4" default="100" var="condition_value">
|
||||
<query id="documentMaxRegdate">
|
||||
<tables>
|
||||
<table name="documents" alias="documents" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="max(regdate)" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="equal" column="documents.user_id" var="member.user_id" notnull="notnull" />
|
||||
</conditions>
|
||||
</query>
|
||||
</condition>
|
||||
</conditions>
|
||||
</query>
|
||||
|
||||
6
tools/dbxml_validator/tests/data/wrongQueryId.xml
Normal file
6
tools/dbxml_validator/tests/data/wrongQueryId.xml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<query id="noQueryId" action="select">
|
||||
<columns />
|
||||
<tables>
|
||||
<table name="source_tbl" />
|
||||
</tables>
|
||||
</query>
|
||||
227
tools/dbxml_validator/tests/xmlQueriesTest.php
Normal file
227
tools/dbxml_validator/tests/xmlQueriesTest.php
Normal file
|
|
@ -0,0 +1,227 @@
|
|||
<?php
|
||||
|
||||
if (!defined('__DIR__'))
|
||||
define('__DIR__', realpath(dirname(__FILE__)));
|
||||
|
||||
/** The tests here are meant only for the built-in checks in validator.php,
|
||||
and not for the entire syntax expressed by the .xsd files. */
|
||||
class XmlQueriesTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
// taken from validator.php
|
||||
|
||||
const RETCODE_VALIDATOR_INTERNAL = 60;
|
||||
const RETCODE_GENERIC_XML_SYNTAX = 50;
|
||||
const RETCODE_QUERY_ELEMENT = 40;
|
||||
const RETCODE_XSD_VALIDATION = 30;
|
||||
const RETCODE_BUILTIN_CHECKS = 20;
|
||||
const RETCODE_DB_SCHEMA_MATCH =10; // no schema match is currently implemented.
|
||||
const RETCODE_SUCCESS = 0;
|
||||
|
||||
public $validator_cmd;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->validator_cmd = "php " . escapeshellarg(__DIR__ . '/../validate.php') . " ";
|
||||
}
|
||||
|
||||
// recursive glob
|
||||
// On Windows glob() is case-sensitive.
|
||||
public function globr($sDir, $sPattern, $nFlags = NULL)
|
||||
{
|
||||
// Get the list of all matching files currently in the
|
||||
// directory.
|
||||
|
||||
$aFiles = glob("$sDir/$sPattern", $nFlags);
|
||||
|
||||
$this->assertTrue(is_array($aFiles), 'directory listing failed.');
|
||||
|
||||
$aDirs = glob("$sDir/*", GLOB_ONLYDIR | GLOB_NOSORT | GLOB_NOESCAPE | GLOB_ERR);
|
||||
$this->assertTrue(is_array($aDirs), 'directory listing failed.');
|
||||
|
||||
foreach ($aDirs as $sSubDir)
|
||||
{
|
||||
if ($sSubDir != '.' && $sSubDir != '..')
|
||||
{
|
||||
$aSubFiles = $this->globr($sSubDir, $sPattern, $nFlags);
|
||||
$aFiles = array_merge($aFiles, $aSubFiles);
|
||||
}
|
||||
}
|
||||
|
||||
// return merged array with all (recursive) files
|
||||
return $aFiles;
|
||||
}
|
||||
|
||||
/** Tests all XML Query and Schema Language files (in all modules/addons/widgets) in XE */
|
||||
public function invoke_testReleasedXMLLangFiles
|
||||
(
|
||||
$released_files,
|
||||
$expected_return_code,
|
||||
$validator_args = ''
|
||||
)
|
||||
{
|
||||
// this file is in tools/dbxml_validator/tests
|
||||
$xe_dir = __DIR__ . '/../../..';
|
||||
|
||||
$this->assertTrue(file_exists($xe_dir . '/index.php'), 'XE directory not found');
|
||||
|
||||
$cnt = 0;
|
||||
$cmd = $this->validator_cmd;
|
||||
$xml_files = array();
|
||||
|
||||
foreach ($released_files as $released_file_mask)
|
||||
$xml_files =
|
||||
array_merge
|
||||
(
|
||||
$xml_files,
|
||||
$this->globr
|
||||
(
|
||||
$xe_dir,
|
||||
$released_file_mask,
|
||||
GLOB_NOSORT | GLOB_NOESCAPE | GLOB_ERR
|
||||
)
|
||||
);
|
||||
|
||||
while ($cnt < count($xml_files))
|
||||
{
|
||||
$cmd = $this->validator_cmd . $validator_args;
|
||||
|
||||
// Validate 50 files at once
|
||||
foreach (array_slice($xml_files, $cnt, 50) as $xml_file)
|
||||
$cmd .= " " . escapeshellarg($xml_file);
|
||||
|
||||
exec($cmd . ' 2>&1', $validator_output, $return_code);
|
||||
|
||||
$output_text = trim(trim(implode("\n", $validator_output)), "\n");
|
||||
|
||||
// Validator should not crash/exit-with-an-error.
|
||||
$this->assertLessThanOrEqual
|
||||
(
|
||||
$expected_return_code,
|
||||
$return_code,
|
||||
"{$cmd}\n\n{$output_text}\nValidator returned code {$return_code}."
|
||||
);
|
||||
|
||||
$cnt += 50;
|
||||
}
|
||||
}
|
||||
|
||||
public function testReleasedXMLQueryLangFiles()
|
||||
{
|
||||
$this->invoke_testReleasedXMLLangFiles
|
||||
(
|
||||
array('queries/*.xml', 'xml_query/*.xml'),
|
||||
self::RETCODE_QUERY_ELEMENT
|
||||
);
|
||||
|
||||
$this->markTestIncomplete('XML Query Language files should be fixed first.');
|
||||
}
|
||||
|
||||
public function testReleasedXMLSchemaLangFiles()
|
||||
{
|
||||
$this->invoke_testReleasedXMLLangFiles
|
||||
(
|
||||
array('schemas/*.xml'),
|
||||
self::RETCODE_BUILTIN_CHECKS,
|
||||
' --schema-language'
|
||||
);
|
||||
|
||||
$this->markTestIncomplete('XML Schema Language files should be fixed first.');
|
||||
}
|
||||
|
||||
public function invoke_testInvalidXmlFiles($filename, $err_code, $args = '')
|
||||
{
|
||||
$cmd = $this->validator_cmd . ' '. $args . ' ' . escapeshellarg($filename);
|
||||
$validator_output = array();
|
||||
$return_code = 0;
|
||||
|
||||
exec($cmd . '2>&1', $validator_output, $return_code);
|
||||
|
||||
$output_text = trim(trim(implode("\n", $validator_output)), "\n");
|
||||
|
||||
// Validator should not crash/exit-with-an-error.
|
||||
$this->assertEquals
|
||||
(
|
||||
$err_code,
|
||||
$return_code,
|
||||
"{$cmd}\n{$output_text}\nValidator returned code {$return_code}."
|
||||
);
|
||||
|
||||
// Validator should output some error on the test files
|
||||
$basefilename = basename($filename);
|
||||
$this->assertNotEmpty($output_text, "Error reporting failed for {$basefilename} validation.");
|
||||
|
||||
}
|
||||
|
||||
public function testInvalidQueryId()
|
||||
{
|
||||
return $this->invoke_testInvalidXmlFiles(__DIR__.'/data/wrongQueryId.xml', self::RETCODE_QUERY_ELEMENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getFilesList
|
||||
*/
|
||||
public function testInvalidXMLQueryFiles($filename)
|
||||
{
|
||||
return $this->invoke_testInvalidXmlFiles($filename, self::RETCODE_BUILTIN_CHECKS);
|
||||
}
|
||||
|
||||
public function getDirFilesList($dir_name)
|
||||
{
|
||||
$output = array();
|
||||
|
||||
$dir = opendir(__DIR__ . '/' . $dir_name);
|
||||
|
||||
if ($dir)
|
||||
{
|
||||
$entry = readdir($dir);
|
||||
|
||||
while ($entry !== FALSE)
|
||||
{
|
||||
$fname = __DIR__ . '/' . $dir_name .'/' . $entry;
|
||||
|
||||
if (!is_dir($fname)&& $entry != 'wrongQueryId.xml')
|
||||
$output[] = array($fname);
|
||||
|
||||
$entry = readdir($dir);
|
||||
}
|
||||
|
||||
closedir($dir);
|
||||
}
|
||||
else
|
||||
$this->assertFalse(TRUE);
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
public function getFilesList()
|
||||
{
|
||||
return $this->getDirFilesList('data');
|
||||
}
|
||||
|
||||
public function getSchemaFilesList()
|
||||
{
|
||||
return $this->getDirFilesList('data/schema');
|
||||
}
|
||||
|
||||
public function getSchemaWarningFilesList()
|
||||
{
|
||||
return $this->getDirFilesList('data/schema/warnings');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getSchemaFilesList
|
||||
*/
|
||||
public function testInvalidXMLSchemaFiles($filename)
|
||||
{
|
||||
return $this->invoke_testInvalidXmlFiles($filename, self::RETCODE_BUILTIN_CHECKS, '--schema-language');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getSchemaWarningFilesList
|
||||
*/
|
||||
public function testWarningXMLSchemaFiles($filename)
|
||||
{
|
||||
return $this->invoke_testInvalidXmlFiles($filename, self::RETCODE_SUCCESS, '--schema-language');
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue