From 62a1f81cb61b4fec86597f3cce93e729c7cc85c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Walter?= Date: Sat, 1 Nov 2014 09:00:22 +0100 Subject: [PATCH 01/16] added initial set of schemas for JOomla 3.3.x --- .gitattributes | 57 ++++ .gitignore | 25 ++ v3/README.md | 12 + v3/common.xsd | 668 +++++++++++++++++++++++++++++++++++++++++ v3/component.xml | 137 +++++++++ v3/component.xsd | 42 +++ v3/language.xml | 24 ++ v3/language.xsd | 45 +++ v3/library.xml | 20 ++ v3/library.xsd | 42 +++ v3/module.xml | 83 +++++ v3/module.xsd | 38 +++ v3/package.xml | 29 ++ v3/package.xsd | 60 ++++ v3/plugin.xml | 82 +++++ v3/plugin.xsd | 79 +++++ v3/templateDetails.xml | 29 ++ v3/templateDetails.xsd | 30 ++ 18 files changed, 1502 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 v3/README.md create mode 100644 v3/common.xsd create mode 100644 v3/component.xml create mode 100644 v3/component.xsd create mode 100644 v3/language.xml create mode 100644 v3/language.xsd create mode 100644 v3/library.xml create mode 100644 v3/library.xsd create mode 100644 v3/module.xml create mode 100644 v3/module.xsd create mode 100644 v3/package.xml create mode 100644 v3/package.xsd create mode 100644 v3/plugin.xml create mode 100644 v3/plugin.xsd create mode 100644 v3/templateDetails.xml create mode 100644 v3/templateDetails.xsd diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..896087d --- /dev/null +++ b/.gitattributes @@ -0,0 +1,57 @@ +# Set default behaviour, in case users don't have core.autocrlf set. +* text=auto + +# Explicitly declare text files we want to always be normalized and converted +# to native line endings on checkout. +*.java text +*.xml text +*.xsl text +*.csv text +*.conf text +*.properties text +*.jsp text +*.css text +*.scss text +*.svg text +*.js text +*.html text +*.episode text +*.xsd text +*.dtd text + +# Denote all files that are truly binary and should not be modified. +*.png binary +*.jpg binary +*.gif binary +*.zip binary +*.jar binary +*.doc binary +*.docx binary +*.dot binary +*.xls binary +*.otf binary +*.eot binary +*.ttf binary +*.ttf binary +*.woff binary +*.der binary + +# Custom for Visual Studio +*.cs diff=csharp +*.sln merge=union +*.csproj merge=union +*.vbproj merge=union +*.fsproj merge=union +*.dbproj merge=union + +*.doc diff=astextplain +*.DOC diff=astextplain +*.docx diff=astextplain +*.DOCX diff=astextplain +*.dot diff=astextplain +*.DOT diff=astextplain +*.pdf diff=astextplain +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..642f94a --- /dev/null +++ b/.gitignore @@ -0,0 +1,25 @@ +### Eclipse +.project +.metadata +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.classpath +.project +.settings/ +.loadpath +.externalToolBuilders/ +*.launch + +### IDEA +*.ipr +*.iws +*.iml + +### Maven +target/ +overlays/ + diff --git a/v3/README.md b/v3/README.md new file mode 100644 index 0000000..a84713a --- /dev/null +++ b/v3/README.md @@ -0,0 +1,12 @@ +joomla-xsd +========== + +Schema Validation for Joomla 1.6/1.7/2.5/3.0/3.1 Extensions + +Without them, Joomla accept any entry in manifest xml and never complains about + +* Mistyping, like a valid xml but that the Joomla installer do not understand or only partially, +* Wrong constructs, xml tag child misplaced, +* Invalid data type, like a path not being a valid path, an expected integer being a text and so on… +Joomla just silently die during install or install only partially extensions. These days are over as developers with any +decent IDE will be able to validate while typing and enjoy auto completion. diff --git a/v3/common.xsd b/v3/common.xsd new file mode 100644 index 0000000..f3aab61 --- /dev/null +++ b/v3/common.xsd @@ -0,0 +1,668 @@ + + + + + + The default value install will be also used if the method attribute is not used. The install value means the + installer will gracefully stop if it finds any existing file/folder of the new extension. + + + + + + + + + + + This attribute describes the type of the extension for the installer. Based on this type further requirements to + sub-tags apply. + + + + + + + + + + + + + + + + + String that identifies the version of Joomla for which this extension is developed. + + + + + + + + + + + + String that identifies the version of your extension. + + + + + + + + + + + + + + + + + The value inside the tag is the menu's label. Unlike Joomla! 1.5, you can not use a natural language string. For example, if you would enter "Example Component" instead of COM_EXAMPLE, it would result in your component name appearing as example-component in the menu and you would be unable to provide a translation. In order to provide a translation you need to create a file named en-GB.com_example.sys.ini in administrator/languages/en-GB + + + + The (relative) path to an image (16x16 pixels) to appear beside the menu item. + Must be an url compatible as a file too (e.g. no spaces) ! + + + + + A link to send the user to when the menu item is clicked. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The administration section is defined in this element. Since only components apply to both the site and the administrator, only component manifests can include this element. + + + + + + + + + + + + + This element may contain one or more server element, each describing a location to fetch updates from. + + + + + + + + + + + This element define one server to fetch updates from. + + + + + + + + The name of the update server. + + + + + + + + + + + The update server type. + + + + + + + + + The priority of the update server. + + + + + + + + + + + + + + + + + + + + + This defines the directory that contains SQL files for component incremental database updates. You may choose to put + the SQL files somewhere else in your component release, but make sure their location is documented here. + + + + + + + + + + This tag is considered to be deprecated since Joomla! 1.6. We encourage you to put extension 's language files in the extension folder and Joomla! is responsible for the loading of required language files. + + + + + + + + + + + + + + + + + + + + describes the configuration options for the extension. If applicable, the options will be shown by the appropriate Manager (Plugin Manager, Module Manager or Template Manager). Configuration options can also be defined in a separate file named config.xml. Its root element should be config. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The client attribute allows you to specify for which application client the new module is available. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Specify a directory in the ZIP package to copy from. This will copy an entire folder at once + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Dependencies are not currently supported, but were added for that possibility in the future. + + + + + + + + + + Dependencies are not currently supported, but were added for that possibility in the future. + + + + + + + + + + + + + + + + + + This attribute describes the type of the extension for the installer. Based on this type further requirements to + sub-tags apply. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Defines a string subset safe in most file systems as file name (excluding path). + + + + + + + + + + + + + + + + + Validate filepath + + + + + + + + + + Validate filepath + + + + + + + + diff --git a/v3/component.xml b/v3/component.xml new file mode 100644 index 0000000..be6c940 --- /dev/null +++ b/v3/component.xml @@ -0,0 +1,137 @@ + + + + + + com_alpha + John Doe + john.doe@example.org + http://www.example.org + (C) 2008 Copyright Info + License Info + 1.0 + March 2006 + COM_ALPHA_XML_DESCRIPTION + + + file.script.php + + + + + + sql/install.mysql.utf8.sql + + + + + sql/uninstall.mysql.utf8.sql + + + + + sql/updates/mysql + sql/updates/sqlsrv + + + + + + alpha.php + + + + + + + + com_alpha.jpg + + + + + Alpha + + Installer + Users + + + + admin.alpha.php + image.png + applications-internet.png + applications-internet-16.png + sql + + + + + + en-GB/en-GB.com_alpha.ini + en-GB/en-GB.com_alpha.sys.ini + + + + + + + http://jsitepoint.com/update/components/com_alpha/extension.xml + http://jsitepoint.com/update/update.xml + + + + + + #__alpha_install
+ #__alpha_update
+
+ + + + + + + + +
+ + + + + + + + + + + +
+
+ + + + + + + + + +
+
+
+ +
diff --git a/v3/component.xsd b/v3/component.xsd new file mode 100644 index 0000000..a92ac29 --- /dev/null +++ b/v3/component.xsd @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/v3/language.xml b/v3/language.xml new file mode 100644 index 0000000..744c802 --- /dev/null +++ b/v3/language.xml @@ -0,0 +1,24 @@ + + + Examplish (Example) + en-US + 1.6.0 + 2008-03-15 + Joomla! Project + admin@joomla.org + www.joomla.org + Copyright (C) 2005 - 2011 Open Source Matters. All rights reserved. + http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + + + Examplish (Example) + xx-XX + 0 + xx_XX.utf8, xx_XX.UTF-8, xx_XX, xx, examplish, examplish-example + iso-8859-1 + examplish + freesans + + + + diff --git a/v3/language.xsd b/v3/language.xsd new file mode 100644 index 0000000..489d403 --- /dev/null +++ b/v3/language.xsd @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/v3/library.xml b/v3/library.xml new file mode 100644 index 0000000..0279b3e --- /dev/null +++ b/v3/library.xml @@ -0,0 +1,20 @@ + + + + lib_alpha + alpha + LIB_ALPHA_XML_DESCRIPTION + July 2008 + John Doe + john.doe@example.org + http://www.example.org + (C) 2008 Copyright Info + License Info + 3.0.0 + Joomla! + http://www.joomla.org + http://update.joomla.org/libraries/alpha + + alpha.php + + \ No newline at end of file diff --git a/v3/library.xsd b/v3/library.xsd new file mode 100644 index 0000000..656a6c8 --- /dev/null +++ b/v3/library.xsd @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/v3/module.xml b/v3/module.xml new file mode 100644 index 0000000..0cd99d4 --- /dev/null +++ b/v3/module.xml @@ -0,0 +1,83 @@ + + + + + Site Alpha + July 2008 + John Doe + john.doe@example.org + http://www.example.org + (C) 2008 Copyright Info + License Info + 1.6.0 + MOD_ALPHA_XML_DESCRIPTION + alpha.scriptfile.php + + + + + + + + sql/install.mysql.utf8.sql + + + + + + sql/uninstall.mysql.utf8.sql + + + + + + sql/updates/mysql + + + + + mod_alpha.php + any.php + sql + + + + com_alpha.jpg + + + + en-GB.mod_alpha.ini + fr-FR.mod_alpha.ini + + + + +
+ + + + + + + + + + + +
+
+ + + + + + + + + +
+
+
+
diff --git a/v3/module.xsd b/v3/module.xsd new file mode 100644 index 0000000..e61324f --- /dev/null +++ b/v3/module.xsd @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/v3/package.xml b/v3/package.xml new file mode 100644 index 0000000..be7bb35 --- /dev/null +++ b/v3/package.xml @@ -0,0 +1,29 @@ + + + Everything Demonstration + everything + 3.0.0 + http://www.joomla.org + Sam Moffatt + http://www.sammoffatt.com.au + Joomla! Installer Sample and Test Package. + http://update.joomla.org/update/packages/everything + + file.script.php + + + http://jsitepoint.com/update/package/everything/extension.xml + http://jsitepoint.com/update/update.xml + + + + lib_alpha.zip + com_alpha.zip + mod_alpha.zip + mod_alpha_admin.zip + plg_system_alpha.zip + tpl_simple.zip + lng_xx-XX.zip + lng_xx-XX_admin.zip + + \ No newline at end of file diff --git a/v3/package.xsd b/v3/package.xsd new file mode 100644 index 0000000..7fc5a21 --- /dev/null +++ b/v3/package.xsd @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Validate filepath + + + + + + + + diff --git a/v3/plugin.xml b/v3/plugin.xml new file mode 100644 index 0000000..6f13271 --- /dev/null +++ b/v3/plugin.xml @@ -0,0 +1,82 @@ + + + System - Alpha + July 2008 + John Doe + john.doe@example.org + http://www.example.org + (C) 2008 Copyright Info + License Info + 1.6.0 + PLG_ALPHA_XML_DESCRIPTION + + alpha.scriptfile.php + + + + + + sql/install.mysql.utf8.sql + + + + + sql/uninstall.mysql.utf8.sql + + + + + sql/updates/mysql + + + + + alpha.php + sql + language + + + + com_alpha.jpg + + + + + + + +
+ + + + + + + + + + + +
+
+ + + + + + + + + +
+
+
+
diff --git a/v3/plugin.xsd b/v3/plugin.xsd new file mode 100644 index 0000000..39ff36e --- /dev/null +++ b/v3/plugin.xsd @@ -0,0 +1,79 @@ + + + + + + + + + + + + author's name (e.g. Joomla! Project) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The group name specifies for which group of plugins the new plugin is available. The existing groups are the folder names within the directory /plugins. + The installer will create new folder names for group names that do not exist yet. + + + + + + + + + + + + + + + + + + + + + + diff --git a/v3/templateDetails.xml b/v3/templateDetails.xml new file mode 100644 index 0000000..c7738d8 --- /dev/null +++ b/v3/templateDetails.xml @@ -0,0 +1,29 @@ + + + + simple_template + July 2008 + John Doe + john.doe@example.org + http://www.example.org + (C) 2008 Copyright Info + License Info + 1.6.0 + TPL_TPL_SIMPLE_XML_DESCRIPTION + + index.php + + + + analytics + social + drawer + + + +
+ +
+
+
+
diff --git a/v3/templateDetails.xsd b/v3/templateDetails.xsd new file mode 100644 index 0000000..14f2767 --- /dev/null +++ b/v3/templateDetails.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 47d13232f4149f61738c3935ef53c0266c9bf75f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Walter?= Date: Sat, 1 Nov 2014 11:32:01 +0100 Subject: [PATCH 02/16] correct invalid xsd according to php DOMDocument class load --- v3/common.xsd | 14 ++++++++------ v3/component.xsd | 2 +- v3/plugin.xsd | 4 ++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/v3/common.xsd b/v3/common.xsd index f3aab61..34bb358 100644 --- a/v3/common.xsd +++ b/v3/common.xsd @@ -40,6 +40,8 @@ + + @@ -457,10 +459,10 @@ - - + + - + @@ -483,10 +485,10 @@ - + + - - + diff --git a/v3/component.xsd b/v3/component.xsd index a92ac29..4f548f5 100644 --- a/v3/component.xsd +++ b/v3/component.xsd @@ -1,7 +1,7 @@ - + diff --git a/v3/plugin.xsd b/v3/plugin.xsd index 39ff36e..0edce4c 100644 --- a/v3/plugin.xsd +++ b/v3/plugin.xsd @@ -38,11 +38,11 @@ - + - + From 47e799bbbd83a85f3bde7a3d3ea5e0f8095671f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Walter?= Date: Sat, 1 Nov 2014 11:33:16 +0100 Subject: [PATCH 03/16] added unit test that load all manifests from any joomla root and run for each file found a schema validation --- README.md | 7 +++ bootstrap.php | 4 ++ validate.php | 166 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 177 insertions(+) create mode 100644 bootstrap.php create mode 100644 validate.php diff --git a/README.md b/README.md index 4182ac0..b89d268 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,10 @@ schemas ======= Schemas for the Joomla! CMS + + +call validate like this + +phpunit --bootstrap bootstrap.php validate.php + + diff --git a/bootstrap.php b/bootstrap.php new file mode 100644 index 0000000..55472b6 --- /dev/null +++ b/bootstrap.php @@ -0,0 +1,4 @@ +xsdVersion = "v3"; + } else { + $this->xsdVersion = $joomla_version; + } + $this->xml = new DOMDocument(); + libxml_use_internal_errors(true); + } + + public function testValidate_forComponentManifests_expectValidTrue() + { + // Arrange + $manifests = $this->getManifests("components", "component"); + $schema = dirname(__FILE__) . "/" . $this->xsdVersion . "/component.xsd"; + + // Act + foreach ($manifests as $manifest) { + $this->xml->load($manifest); + $schemaValidate = $this->xml->schemaValidate($schema); + + // Assert + $this->libxml_display_errors(); + + //TODO can do this or first invalid manifest will break the build + //$this->assertEquals(TRUE, $schemaValidate); + } + } + + public function testValidate_forModuleManifests_expectValidTrue() + { + // Arrange + $manifests = $this->getManifests("modules", "module"); + $schema = dirname(__FILE__) . "/" . $this->xsdVersion . "/module.xsd"; + + // Act + foreach ($manifests as $manifest) { + $this->xml->load($manifest); + $schemaValidate = $this->xml->schemaValidate($schema); + + // Assert + $this->libxml_display_errors(); + + //TODO can do this or first invalid manifest will break the build + //$this->assertEquals(TRUE, $schemaValidate); + } + } + + public function testValidate_forPluginsManifests_expectValidTrue() + { + // Arrange + $manifests = $this->getManifests("plugins", "plugin"); + $schema = dirname(__FILE__) . "/" . $this->xsdVersion . "/plugin.xsd"; + + // Act + foreach ($manifests as $manifest) { + $this->xml->load($manifest); + $schemaValidate = $this->xml->schemaValidate($schema); + + // Assert + $this->libxml_display_errors(); + + //TODO can do this or first invalid manifest will break the build + //$this->assertEquals(TRUE, $schemaValidate); + } + } + + public function testValidate_forTemplatesManifests_expectValidTrue() + { + // Arrange + $manifests = $this->getManifests("templates", "template"); + $schema = dirname(__FILE__) . "/" . $this->xsdVersion . "/template.xsd"; + + // Act + foreach ($manifests as $manifest) { + $this->xml->load($manifest); + $schemaValidate = $this->xml->schemaValidate($schema); + + // Assert + $this->libxml_display_errors(); + + //TODO can do this or first invalid manifest will break the build + //$this->assertEquals(TRUE, $schemaValidate); + } + } + + function libxml_display_error($error) + { + $return = "
\n"; + switch ($error->level) { + case LIBXML_ERR_WARNING: + $return .= "Warning $error->code: "; + break; + case LIBXML_ERR_ERROR: + $return .= "Error $error->code: "; + break; + case LIBXML_ERR_FATAL: + $return .= "Fatal Error $error->code: "; + break; + } + $return .= trim($error->message); + if ($error->file) { + $return .= " in $error->file"; + } + $return .= " on line $error->line\n"; + + return $return; + } + + private function libxml_display_errors() + { + $errors = libxml_get_errors(); + foreach ($errors as $error) { + print $this->libxml_display_error($error); + } + libxml_clear_errors(); + } + + private function getManifests($folder = 'components', $type = 'component') + { + //from bootstrap file + global $joomla_root; + + $adminManifests = array(); + $adminPath = $joomla_root . 'administrator/' . $folder . '/'; + if (file_exists($adminPath)) { + $adminManifests = $this->getManifest($type, $adminPath); + } + + $siteManifests = $this->getManifest($type, $joomla_root . $folder); + + return array_merge($adminManifests, $siteManifests); + } + + private function getManifest($extensionType, $path) + { + $manifests = array(); + + $directory = new RecursiveDirectoryIterator($path); + $iterator = new RecursiveIteratorIterator($directory); + $regex = new RegexIterator($iterator, '/^.+\.xml$/i', RecursiveRegexIterator::GET_MATCH); + + $iterator_to_array = iterator_to_array($regex); + foreach ($iterator_to_array as $key => $filename) { + //TODO poor man approach + $file = fopen($key, 'r'); + $header = fread($file, 150); + if (strpos($header, 'type="' . $extensionType . '"') !== FALSE) { + $manifests[] = $key; + } + } + + return $manifests; + } + +} \ No newline at end of file From 06da7d387e1ce6974ad663a49c1f7629be20823b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Walter?= Date: Sat, 1 Nov 2014 11:39:29 +0100 Subject: [PATCH 04/16] added requiredType with either value 'true' or 'required' --- v3/common.xsd | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/v3/common.xsd b/v3/common.xsd index 34bb358..cd10f17 100644 --- a/v3/common.xsd +++ b/v3/common.xsd @@ -45,6 +45,16 @@ + + + Denote if a field is required or not + + + + + + + String that identifies the version of your extension. @@ -271,7 +281,7 @@ - + From d4ec8297e0fead021501369371156d2f44fcd744 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Walter?= Date: Sat, 1 Nov 2014 11:53:30 +0100 Subject: [PATCH 05/16] added support for in module schema --- v3/module.xsd | 2 ++ 1 file changed, 2 insertions(+) diff --git a/v3/module.xsd b/v3/module.xsd index e61324f..1875b64 100644 --- a/v3/module.xsd +++ b/v3/module.xsd @@ -26,6 +26,8 @@ + + From adb88765a37a172561742ad8e9c303e0b503b246 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Walter?= Date: Sat, 1 Nov 2014 12:05:00 +0100 Subject: [PATCH 06/16] added email format to allow empty email beside N/A --- v3/common.xsd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v3/common.xsd b/v3/common.xsd index cd10f17..78d0582 100644 --- a/v3/common.xsd +++ b/v3/common.xsd @@ -652,7 +652,7 @@ - + From a914d741879e92cfdc88aff48792d1d48fcdb68f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Walter?= Date: Sat, 1 Nov 2014 12:05:59 +0100 Subject: [PATCH 07/16] added email format to allow empty email beside N/A --- v3/common.xsd | 2 -- 1 file changed, 2 deletions(-) diff --git a/v3/common.xsd b/v3/common.xsd index 78d0582..af513ae 100644 --- a/v3/common.xsd +++ b/v3/common.xsd @@ -649,14 +649,12 @@ - - Validate filepath From f5ee46259dd0cf5956800930dcbf698e0361f266 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Walter?= Date: Sat, 1 Nov 2014 12:07:00 +0100 Subject: [PATCH 08/16] added validation also for joomla libraries --- v3/library.xsd | 4 ++-- validate.php | 25 ++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/v3/library.xsd b/v3/library.xsd index 656a6c8..11f180a 100644 --- a/v3/library.xsd +++ b/v3/library.xsd @@ -31,10 +31,10 @@ - + - + diff --git a/validate.php b/validate.php index 7f2291f..587afb3 100644 --- a/validate.php +++ b/validate.php @@ -94,6 +94,25 @@ public function testValidate_forTemplatesManifests_expectValidTrue() } } + public function testValidate_forLibraryManifests_expectValidTrue() + { + // Arrange + $manifests = $this->getManifests("manifests/libraries", "library"); + $schema = dirname(__FILE__) . "/" . $this->xsdVersion . "/library.xsd"; + + // Act + foreach ($manifests as $manifest) { + $this->xml->load($manifest); + $schemaValidate = $this->xml->schemaValidate($schema); + + // Assert + $this->libxml_display_errors(); + + //TODO can do this or first invalid manifest will break the build + //$this->assertEquals(TRUE, $schemaValidate); + } + } + function libxml_display_error($error) { $return = "
\n"; @@ -137,7 +156,11 @@ private function getManifests($folder = 'components', $type = 'component') $adminManifests = $this->getManifest($type, $adminPath); } - $siteManifests = $this->getManifest($type, $joomla_root . $folder); + $siteManifests = array(); + $sitePath = $joomla_root . $folder . '/'; + if (file_exists($sitePath)) { + $siteManifests = $this->getManifest($type, $sitePath); + } return array_merge($adminManifests, $siteManifests); } From 1eff4ce3d99891ad9479be7e446b17c28f64b0cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Walter?= Date: Sat, 1 Nov 2014 12:13:49 +0100 Subject: [PATCH 09/16] added validation for joomla language manifest --- validate.php | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/validate.php b/validate.php index 587afb3..0a85a3e 100644 --- a/validate.php +++ b/validate.php @@ -21,7 +21,7 @@ protected function setUp() public function testValidate_forComponentManifests_expectValidTrue() { // Arrange - $manifests = $this->getManifests("components", "component"); + $manifests = $this->getManifests("components", 'type="component"'); $schema = dirname(__FILE__) . "/" . $this->xsdVersion . "/component.xsd"; // Act @@ -40,7 +40,7 @@ public function testValidate_forComponentManifests_expectValidTrue() public function testValidate_forModuleManifests_expectValidTrue() { // Arrange - $manifests = $this->getManifests("modules", "module"); + $manifests = $this->getManifests("modules", 'type="module"'); $schema = dirname(__FILE__) . "/" . $this->xsdVersion . "/module.xsd"; // Act @@ -59,7 +59,7 @@ public function testValidate_forModuleManifests_expectValidTrue() public function testValidate_forPluginsManifests_expectValidTrue() { // Arrange - $manifests = $this->getManifests("plugins", "plugin"); + $manifests = $this->getManifests("plugins", 'type="plugin"'); $schema = dirname(__FILE__) . "/" . $this->xsdVersion . "/plugin.xsd"; // Act @@ -78,7 +78,7 @@ public function testValidate_forPluginsManifests_expectValidTrue() public function testValidate_forTemplatesManifests_expectValidTrue() { // Arrange - $manifests = $this->getManifests("templates", "template"); + $manifests = $this->getManifests("templates", 'type="template"'); $schema = dirname(__FILE__) . "/" . $this->xsdVersion . "/template.xsd"; // Act @@ -97,7 +97,7 @@ public function testValidate_forTemplatesManifests_expectValidTrue() public function testValidate_forLibraryManifests_expectValidTrue() { // Arrange - $manifests = $this->getManifests("manifests/libraries", "library"); + $manifests = $this->getManifests("manifests/libraries", 'type="library"'); $schema = dirname(__FILE__) . "/" . $this->xsdVersion . "/library.xsd"; // Act @@ -113,6 +113,25 @@ public function testValidate_forLibraryManifests_expectValidTrue() } } + public function testValidate_forLanguagesManifests_expectValidTrue() + { + // Arrange + $manifests = $this->getManifests("languages", "xsdVersion . "/language.xsd"; + + // Act + foreach ($manifests as $manifest) { + $this->xml->load($manifest); + $schemaValidate = $this->xml->schemaValidate($schema); + + // Assert + $this->libxml_display_errors(); + + //TODO can do this or first invalid manifest will break the build + //$this->assertEquals(TRUE, $schemaValidate); + } + } + function libxml_display_error($error) { $return = "
\n"; @@ -145,7 +164,7 @@ private function libxml_display_errors() libxml_clear_errors(); } - private function getManifests($folder = 'components', $type = 'component') + private function getManifests($folder = 'components', $extensionType) { //from bootstrap file global $joomla_root; @@ -153,13 +172,13 @@ private function getManifests($folder = 'components', $type = 'component') $adminManifests = array(); $adminPath = $joomla_root . 'administrator/' . $folder . '/'; if (file_exists($adminPath)) { - $adminManifests = $this->getManifest($type, $adminPath); + $adminManifests = $this->getManifest($extensionType, $adminPath); } $siteManifests = array(); $sitePath = $joomla_root . $folder . '/'; if (file_exists($sitePath)) { - $siteManifests = $this->getManifest($type, $sitePath); + $siteManifests = $this->getManifest($extensionType, $sitePath); } return array_merge($adminManifests, $siteManifests); @@ -178,7 +197,7 @@ private function getManifest($extensionType, $path) //TODO poor man approach $file = fopen($key, 'r'); $header = fread($file, 150); - if (strpos($header, 'type="' . $extensionType . '"') !== FALSE) { + if (strpos($header, $extensionType) !== FALSE) { $manifests[] = $key; } } From a43caf72d594fa0c888030ed131caf00cb8ff225 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Walter?= Date: Sat, 1 Nov 2014 12:19:48 +0100 Subject: [PATCH 10/16] added support for weekEnd type in language manifest and corrected typo 'language' --- v3/language.xsd | 10 ++++++++++ validate.php | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/v3/language.xsd b/v3/language.xsd index 489d403..9c9a6f0 100644 --- a/v3/language.xsd +++ b/v3/language.xsd @@ -32,6 +32,7 @@ + @@ -42,4 +43,13 @@ + + + Validate weekEnd + + + + + +
diff --git a/validate.php b/validate.php index 0a85a3e..83f5a36 100644 --- a/validate.php +++ b/validate.php @@ -116,7 +116,7 @@ public function testValidate_forLibraryManifests_expectValidTrue() public function testValidate_forLanguagesManifests_expectValidTrue() { // Arrange - $manifests = $this->getManifests("languages", "getManifests("language", "xsdVersion . "/language.xsd"; // Act From 8e5b10bb5edbeac0c98099dc6b45805e16a35e08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Walter?= Date: Sat, 1 Nov 2014 12:37:46 +0100 Subject: [PATCH 11/16] added some statistics at the end of the run, e.g. "Analysed 133 Joomla manifest(s), found 4 error(s)." --- validate.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/validate.php b/validate.php index 83f5a36..2d69546 100644 --- a/validate.php +++ b/validate.php @@ -4,6 +4,9 @@ class validate extends PHPUnit_Framework_TestCase { protected $xsdVersion; + protected static $count = 0; + protected static $errors = 0; + protected function setUp() { //from bootstrap file @@ -18,6 +21,17 @@ protected function setUp() libxml_use_internal_errors(true); } + public static function setUpBeforeClass() + { + self::$count = 0; + self::$errors = 0; + } + + public static function tearDownAfterClass() + { + printf("Analysed " . self::$count . " Joomla manifest(s), found ".self::$errors . " error(s)."); + } + public function testValidate_forComponentManifests_expectValidTrue() { // Arrange @@ -158,6 +172,9 @@ function libxml_display_error($error) private function libxml_display_errors() { $errors = libxml_get_errors(); + + self::$errors = self::$errors + sizeof($errors); + foreach ($errors as $error) { print $this->libxml_display_error($error); } @@ -202,6 +219,8 @@ private function getManifest($extensionType, $path) } } + self::$count = self::$count + sizeof($manifests); + return $manifests; } From 2c81caf791cd2173aecd4b352c4489a4e840dc61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Walter?= Date: Sat, 1 Nov 2014 12:50:23 +0100 Subject: [PATCH 12/16] removed .gitignore, reduce size of .gitattribute --- .gitattributes | 54 +------------------------------------------------- .gitignore | 25 ----------------------- 2 files changed, 1 insertion(+), 78 deletions(-) delete mode 100644 .gitignore diff --git a/.gitattributes b/.gitattributes index 896087d..6bd4eaf 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,57 +1,5 @@ # Set default behaviour, in case users don't have core.autocrlf set. * text=auto - -# Explicitly declare text files we want to always be normalized and converted -# to native line endings on checkout. -*.java text *.xml text -*.xsl text -*.csv text -*.conf text -*.properties text -*.jsp text -*.css text -*.scss text -*.svg text -*.js text -*.html text -*.episode text *.xsd text -*.dtd text - -# Denote all files that are truly binary and should not be modified. -*.png binary -*.jpg binary -*.gif binary -*.zip binary -*.jar binary -*.doc binary -*.docx binary -*.dot binary -*.xls binary -*.otf binary -*.eot binary -*.ttf binary -*.ttf binary -*.woff binary -*.der binary - -# Custom for Visual Studio -*.cs diff=csharp -*.sln merge=union -*.csproj merge=union -*.vbproj merge=union -*.fsproj merge=union -*.dbproj merge=union - -*.doc diff=astextplain -*.DOC diff=astextplain -*.docx diff=astextplain -*.DOCX diff=astextplain -*.dot diff=astextplain -*.DOT diff=astextplain -*.pdf diff=astextplain -*.PDF diff=astextplain -*.rtf diff=astextplain -*.RTF diff=astextplain - +*.dtd text \ No newline at end of file diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 642f94a..0000000 --- a/.gitignore +++ /dev/null @@ -1,25 +0,0 @@ -### Eclipse -.project -.metadata -tmp/ -*.tmp -*.bak -*.swp -*~.nib -local.properties -.classpath -.project -.settings/ -.loadpath -.externalToolBuilders/ -*.launch - -### IDEA -*.ipr -*.iws -*.iml - -### Maven -target/ -overlays/ - From 614c735e2b74039ff65f00387ac4df367c7b979b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Walter?= Date: Sat, 1 Nov 2014 12:53:55 +0100 Subject: [PATCH 13/16] moved files into xsd/ --- README.md | 6 - bootstrap.php | 4 - v3/README.md | 12 - v3/common.xsd | 678 ------------------------------- v3/component.xml | 137 ------- v3/component.xsd | 42 -- v3/language.xml | 24 -- v3/language.xsd | 55 --- v3/library.xml | 20 - v3/library.xsd | 42 -- v3/module.xml | 83 ---- v3/module.xsd | 40 -- v3/package.xml | 29 -- v3/package.xsd | 60 --- v3/plugin.xml | 82 ---- v3/plugin.xsd | 79 ---- v3/templateDetails.xml | 29 -- v3/templateDetails.xsd | 30 -- xsd/README.md | 7 + xsd/bootstrap.php | 5 + validate.php => xsd/validate.php | 0 21 files changed, 12 insertions(+), 1452 deletions(-) delete mode 100644 bootstrap.php delete mode 100644 v3/README.md delete mode 100644 v3/common.xsd delete mode 100644 v3/component.xml delete mode 100644 v3/component.xsd delete mode 100644 v3/language.xml delete mode 100644 v3/language.xsd delete mode 100644 v3/library.xml delete mode 100644 v3/library.xsd delete mode 100644 v3/module.xml delete mode 100644 v3/module.xsd delete mode 100644 v3/package.xml delete mode 100644 v3/package.xsd delete mode 100644 v3/plugin.xml delete mode 100644 v3/plugin.xsd delete mode 100644 v3/templateDetails.xml delete mode 100644 v3/templateDetails.xsd create mode 100644 xsd/README.md create mode 100644 xsd/bootstrap.php rename validate.php => xsd/validate.php (100%) diff --git a/README.md b/README.md index b89d268..c9106aa 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,3 @@ schemas Schemas for the Joomla! CMS - -call validate like this - -phpunit --bootstrap bootstrap.php validate.php - - diff --git a/bootstrap.php b/bootstrap.php deleted file mode 100644 index 55472b6..0000000 --- a/bootstrap.php +++ /dev/null @@ -1,4 +0,0 @@ - - - - - - The default value install will be also used if the method attribute is not used. The install value means the - installer will gracefully stop if it finds any existing file/folder of the new extension. - - - - - - - - - - - This attribute describes the type of the extension for the installer. Based on this type further requirements to - sub-tags apply. - - - - - - - - - - - - - - - - - String that identifies the version of Joomla for which this extension is developed. - - - - - - - - - - - - - - Denote if a field is required or not - - - - - - - - - - String that identifies the version of your extension. - - - - - - - - - - - - - - - - - The value inside the tag is the menu's label. Unlike Joomla! 1.5, you can not use a natural language string. For example, if you would enter "Example Component" instead of COM_EXAMPLE, it would result in your component name appearing as example-component in the menu and you would be unable to provide a translation. In order to provide a translation you need to create a file named en-GB.com_example.sys.ini in administrator/languages/en-GB - - - - The (relative) path to an image (16x16 pixels) to appear beside the menu item. - Must be an url compatible as a file too (e.g. no spaces) ! - - - - - A link to send the user to when the menu item is clicked. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The administration section is defined in this element. Since only components apply to both the site and the administrator, only component manifests can include this element. - - - - - - - - - - - - - This element may contain one or more server element, each describing a location to fetch updates from. - - - - - - - - - - - This element define one server to fetch updates from. - - - - - - - - The name of the update server. - - - - - - - - - - - The update server type. - - - - - - - - - The priority of the update server. - - - - - - - - - - - - - - - - - - - - - This defines the directory that contains SQL files for component incremental database updates. You may choose to put - the SQL files somewhere else in your component release, but make sure their location is documented here. - - - - - - - - - - This tag is considered to be deprecated since Joomla! 1.6. We encourage you to put extension 's language files in the extension folder and Joomla! is responsible for the loading of required language files. - - - - - - - - - - - - - - - - - - - - describes the configuration options for the extension. If applicable, the options will be shown by the appropriate Manager (Plugin Manager, Module Manager or Template Manager). Configuration options can also be defined in a separate file named config.xml. Its root element should be config. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The client attribute allows you to specify for which application client the new module is available. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Specify a directory in the ZIP package to copy from. This will copy an entire folder at once - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Dependencies are not currently supported, but were added for that possibility in the future. - - - - - - - - - - Dependencies are not currently supported, but were added for that possibility in the future. - - - - - - - - - - - - - - - - - - This attribute describes the type of the extension for the installer. Based on this type further requirements to - sub-tags apply. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Defines a string subset safe in most file systems as file name (excluding path). - - - - - - - - - - - - - - - Validate filepath - - - - - - - - - - Validate filepath - - - - - - - - diff --git a/v3/component.xml b/v3/component.xml deleted file mode 100644 index be6c940..0000000 --- a/v3/component.xml +++ /dev/null @@ -1,137 +0,0 @@ - - - - - - com_alpha - John Doe - john.doe@example.org - http://www.example.org - (C) 2008 Copyright Info - License Info - 1.0 - March 2006 - COM_ALPHA_XML_DESCRIPTION - - - file.script.php - - - - - - sql/install.mysql.utf8.sql - - - - - sql/uninstall.mysql.utf8.sql - - - - - sql/updates/mysql - sql/updates/sqlsrv - - - - - - alpha.php - - - - - - - - com_alpha.jpg - - - - - Alpha - - Installer - Users - - - - admin.alpha.php - image.png - applications-internet.png - applications-internet-16.png - sql - - - - - - en-GB/en-GB.com_alpha.ini - en-GB/en-GB.com_alpha.sys.ini - - - - - - - http://jsitepoint.com/update/components/com_alpha/extension.xml - http://jsitepoint.com/update/update.xml - - - - - - #__alpha_install
- #__alpha_update
-
- - - - - - - - -
- - - - - - - - - - - -
-
- - - - - - - - - -
-
-
- -
diff --git a/v3/component.xsd b/v3/component.xsd deleted file mode 100644 index 4f548f5..0000000 --- a/v3/component.xsd +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/v3/language.xml b/v3/language.xml deleted file mode 100644 index 744c802..0000000 --- a/v3/language.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - Examplish (Example) - en-US - 1.6.0 - 2008-03-15 - Joomla! Project - admin@joomla.org - www.joomla.org - Copyright (C) 2005 - 2011 Open Source Matters. All rights reserved. - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - - - Examplish (Example) - xx-XX - 0 - xx_XX.utf8, xx_XX.UTF-8, xx_XX, xx, examplish, examplish-example - iso-8859-1 - examplish - freesans - - - - diff --git a/v3/language.xsd b/v3/language.xsd deleted file mode 100644 index 9c9a6f0..0000000 --- a/v3/language.xsd +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Validate weekEnd - - - - - - - diff --git a/v3/library.xml b/v3/library.xml deleted file mode 100644 index 0279b3e..0000000 --- a/v3/library.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - lib_alpha - alpha - LIB_ALPHA_XML_DESCRIPTION - July 2008 - John Doe - john.doe@example.org - http://www.example.org - (C) 2008 Copyright Info - License Info - 3.0.0 - Joomla! - http://www.joomla.org - http://update.joomla.org/libraries/alpha - - alpha.php - - \ No newline at end of file diff --git a/v3/library.xsd b/v3/library.xsd deleted file mode 100644 index 11f180a..0000000 --- a/v3/library.xsd +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/v3/module.xml b/v3/module.xml deleted file mode 100644 index 0cd99d4..0000000 --- a/v3/module.xml +++ /dev/null @@ -1,83 +0,0 @@ - - - - - Site Alpha - July 2008 - John Doe - john.doe@example.org - http://www.example.org - (C) 2008 Copyright Info - License Info - 1.6.0 - MOD_ALPHA_XML_DESCRIPTION - alpha.scriptfile.php - - - - - - - - sql/install.mysql.utf8.sql - - - - - - sql/uninstall.mysql.utf8.sql - - - - - - sql/updates/mysql - - - - - mod_alpha.php - any.php - sql - - - - com_alpha.jpg - - - - en-GB.mod_alpha.ini - fr-FR.mod_alpha.ini - - - - -
- - - - - - - - - - - -
-
- - - - - - - - - -
-
-
-
diff --git a/v3/module.xsd b/v3/module.xsd deleted file mode 100644 index 1875b64..0000000 --- a/v3/module.xsd +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/v3/package.xml b/v3/package.xml deleted file mode 100644 index be7bb35..0000000 --- a/v3/package.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - Everything Demonstration - everything - 3.0.0 - http://www.joomla.org - Sam Moffatt - http://www.sammoffatt.com.au - Joomla! Installer Sample and Test Package. - http://update.joomla.org/update/packages/everything - - file.script.php - - - http://jsitepoint.com/update/package/everything/extension.xml - http://jsitepoint.com/update/update.xml - - - - lib_alpha.zip - com_alpha.zip - mod_alpha.zip - mod_alpha_admin.zip - plg_system_alpha.zip - tpl_simple.zip - lng_xx-XX.zip - lng_xx-XX_admin.zip - - \ No newline at end of file diff --git a/v3/package.xsd b/v3/package.xsd deleted file mode 100644 index 7fc5a21..0000000 --- a/v3/package.xsd +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Validate filepath - - - - - - - - diff --git a/v3/plugin.xml b/v3/plugin.xml deleted file mode 100644 index 6f13271..0000000 --- a/v3/plugin.xml +++ /dev/null @@ -1,82 +0,0 @@ - - - System - Alpha - July 2008 - John Doe - john.doe@example.org - http://www.example.org - (C) 2008 Copyright Info - License Info - 1.6.0 - PLG_ALPHA_XML_DESCRIPTION - - alpha.scriptfile.php - - - - - - sql/install.mysql.utf8.sql - - - - - sql/uninstall.mysql.utf8.sql - - - - - sql/updates/mysql - - - - - alpha.php - sql - language - - - - com_alpha.jpg - - - - - - - -
- - - - - - - - - - - -
-
- - - - - - - - - -
-
-
-
diff --git a/v3/plugin.xsd b/v3/plugin.xsd deleted file mode 100644 index 0edce4c..0000000 --- a/v3/plugin.xsd +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - - - - - - - author's name (e.g. Joomla! Project) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The group name specifies for which group of plugins the new plugin is available. The existing groups are the folder names within the directory /plugins. - The installer will create new folder names for group names that do not exist yet. - - - - - - - - - - - - - - - - - - - - - - diff --git a/v3/templateDetails.xml b/v3/templateDetails.xml deleted file mode 100644 index c7738d8..0000000 --- a/v3/templateDetails.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - simple_template - July 2008 - John Doe - john.doe@example.org - http://www.example.org - (C) 2008 Copyright Info - License Info - 1.6.0 - TPL_TPL_SIMPLE_XML_DESCRIPTION - - index.php - - - - analytics - social - drawer - - - -
- -
-
-
-
diff --git a/v3/templateDetails.xsd b/v3/templateDetails.xsd deleted file mode 100644 index 14f2767..0000000 --- a/v3/templateDetails.xsd +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/xsd/README.md b/xsd/README.md new file mode 100644 index 0000000..6d17e75 --- /dev/null +++ b/xsd/README.md @@ -0,0 +1,7 @@ + +call validate like this + +phpunit --bootstrap bootstrap.php validate.php + + + diff --git a/xsd/bootstrap.php b/xsd/bootstrap.php new file mode 100644 index 0000000..99f869c --- /dev/null +++ b/xsd/bootstrap.php @@ -0,0 +1,5 @@ + Date: Sat, 1 Nov 2014 12:56:28 +0100 Subject: [PATCH 14/16] moved files into xsd/ --- xsd/v3/README.md | 12 + xsd/v3/common.xsd | 678 +++++++++++++++++++++++++++++++++++++ xsd/v3/component.xml | 137 ++++++++ xsd/v3/component.xsd | 42 +++ xsd/v3/language.xml | 24 ++ xsd/v3/language.xsd | 55 +++ xsd/v3/library.xml | 20 ++ xsd/v3/library.xsd | 42 +++ xsd/v3/module.xml | 83 +++++ xsd/v3/module.xsd | 40 +++ xsd/v3/package.xml | 29 ++ xsd/v3/package.xsd | 60 ++++ xsd/v3/plugin.xml | 82 +++++ xsd/v3/plugin.xsd | 79 +++++ xsd/v3/templateDetails.xml | 29 ++ xsd/v3/templateDetails.xsd | 30 ++ xsd/validate.php | 1 + 17 files changed, 1443 insertions(+) create mode 100644 xsd/v3/README.md create mode 100644 xsd/v3/common.xsd create mode 100644 xsd/v3/component.xml create mode 100644 xsd/v3/component.xsd create mode 100644 xsd/v3/language.xml create mode 100644 xsd/v3/language.xsd create mode 100644 xsd/v3/library.xml create mode 100644 xsd/v3/library.xsd create mode 100644 xsd/v3/module.xml create mode 100644 xsd/v3/module.xsd create mode 100644 xsd/v3/package.xml create mode 100644 xsd/v3/package.xsd create mode 100644 xsd/v3/plugin.xml create mode 100644 xsd/v3/plugin.xsd create mode 100644 xsd/v3/templateDetails.xml create mode 100644 xsd/v3/templateDetails.xsd diff --git a/xsd/v3/README.md b/xsd/v3/README.md new file mode 100644 index 0000000..a84713a --- /dev/null +++ b/xsd/v3/README.md @@ -0,0 +1,12 @@ +joomla-xsd +========== + +Schema Validation for Joomla 1.6/1.7/2.5/3.0/3.1 Extensions + +Without them, Joomla accept any entry in manifest xml and never complains about + +* Mistyping, like a valid xml but that the Joomla installer do not understand or only partially, +* Wrong constructs, xml tag child misplaced, +* Invalid data type, like a path not being a valid path, an expected integer being a text and so on… +Joomla just silently die during install or install only partially extensions. These days are over as developers with any +decent IDE will be able to validate while typing and enjoy auto completion. diff --git a/xsd/v3/common.xsd b/xsd/v3/common.xsd new file mode 100644 index 0000000..af513ae --- /dev/null +++ b/xsd/v3/common.xsd @@ -0,0 +1,678 @@ + + + + + + The default value install will be also used if the method attribute is not used. The install value means the + installer will gracefully stop if it finds any existing file/folder of the new extension. + + + + + + + + + + + This attribute describes the type of the extension for the installer. Based on this type further requirements to + sub-tags apply. + + + + + + + + + + + + + + + + + String that identifies the version of Joomla for which this extension is developed. + + + + + + + + + + + + + + Denote if a field is required or not + + + + + + + + + + String that identifies the version of your extension. + + + + + + + + + + + + + + + + + The value inside the tag is the menu's label. Unlike Joomla! 1.5, you can not use a natural language string. For example, if you would enter "Example Component" instead of COM_EXAMPLE, it would result in your component name appearing as example-component in the menu and you would be unable to provide a translation. In order to provide a translation you need to create a file named en-GB.com_example.sys.ini in administrator/languages/en-GB + + + + The (relative) path to an image (16x16 pixels) to appear beside the menu item. + Must be an url compatible as a file too (e.g. no spaces) ! + + + + + A link to send the user to when the menu item is clicked. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The administration section is defined in this element. Since only components apply to both the site and the administrator, only component manifests can include this element. + + + + + + + + + + + + + This element may contain one or more server element, each describing a location to fetch updates from. + + + + + + + + + + + This element define one server to fetch updates from. + + + + + + + + The name of the update server. + + + + + + + + + + + The update server type. + + + + + + + + + The priority of the update server. + + + + + + + + + + + + + + + + + + + + + This defines the directory that contains SQL files for component incremental database updates. You may choose to put + the SQL files somewhere else in your component release, but make sure their location is documented here. + + + + + + + + + + This tag is considered to be deprecated since Joomla! 1.6. We encourage you to put extension 's language files in the extension folder and Joomla! is responsible for the loading of required language files. + + + + + + + + + + + + + + + + + + + + describes the configuration options for the extension. If applicable, the options will be shown by the appropriate Manager (Plugin Manager, Module Manager or Template Manager). Configuration options can also be defined in a separate file named config.xml. Its root element should be config. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The client attribute allows you to specify for which application client the new module is available. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Specify a directory in the ZIP package to copy from. This will copy an entire folder at once + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Dependencies are not currently supported, but were added for that possibility in the future. + + + + + + + + + + Dependencies are not currently supported, but were added for that possibility in the future. + + + + + + + + + + + + + + + + + + This attribute describes the type of the extension for the installer. Based on this type further requirements to + sub-tags apply. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Defines a string subset safe in most file systems as file name (excluding path). + + + + + + + + + + + + + + + Validate filepath + + + + + + + + + + Validate filepath + + + + + + + + diff --git a/xsd/v3/component.xml b/xsd/v3/component.xml new file mode 100644 index 0000000..8050759 --- /dev/null +++ b/xsd/v3/component.xml @@ -0,0 +1,137 @@ + + + + + + com_alpha + John Doe + john.doe@example.org + http://www.example.org + (C) 2008 Copyright Info + License Info + 1.0 + March 2006 + COM_ALPHA_XML_DESCRIPTION + + + file.script.php + + + + + + sql/install.mysql.utf8.sql + + + + + sql/uninstall.mysql.utf8.sql + + + + + sql/updates/mysql + sql/updates/sqlsrv + + + + + + alpha.php + + + + + + + + com_alpha.jpg + + + + + Alpha + + Installer + Users + + + + admin.alpha.php + image.png + applications-internet.png + applications-internet-16.png + sql + + + + + + en-GB/en-GB.com_alpha.ini + en-GB/en-GB.com_alpha.sys.ini + + + + + + + http://jsitepoint.com/update/components/com_alpha/extension.xml + http://jsitepoint.com/update/update.xml + + + + + + #__alpha_install
+ #__alpha_update
+
+ + + + + + + + +
+ + + + + + + + + + + +
+
+ + + + + + + + + +
+
+
+ +
diff --git a/xsd/v3/component.xsd b/xsd/v3/component.xsd new file mode 100644 index 0000000..4f548f5 --- /dev/null +++ b/xsd/v3/component.xsd @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd/v3/language.xml b/xsd/v3/language.xml new file mode 100644 index 0000000..3f541a5 --- /dev/null +++ b/xsd/v3/language.xml @@ -0,0 +1,24 @@ + + + Examplish (Example) + en-US + 1.6.0 + 2008-03-15 + Joomla! Project + admin@joomla.org + www.joomla.org + Copyright (C) 2005 - 2011 Open Source Matters. All rights reserved. + http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + + + Examplish (Example) + xx-XX + 0 + xx_XX.utf8, xx_XX.UTF-8, xx_XX, xx, examplish, examplish-example + iso-8859-1 + examplish + freesans + + + + diff --git a/xsd/v3/language.xsd b/xsd/v3/language.xsd new file mode 100644 index 0000000..103153e --- /dev/null +++ b/xsd/v3/language.xsd @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Validate weekEnd + + + + + + + diff --git a/xsd/v3/library.xml b/xsd/v3/library.xml new file mode 100644 index 0000000..610898a --- /dev/null +++ b/xsd/v3/library.xml @@ -0,0 +1,20 @@ + + + + lib_alpha + alpha + LIB_ALPHA_XML_DESCRIPTION + July 2008 + John Doe + john.doe@example.org + http://www.example.org + (C) 2008 Copyright Info + License Info + 3.0.0 + Joomla! + http://www.joomla.org + http://update.joomla.org/libraries/alpha + + alpha.php + + \ No newline at end of file diff --git a/xsd/v3/library.xsd b/xsd/v3/library.xsd new file mode 100644 index 0000000..be96ad7 --- /dev/null +++ b/xsd/v3/library.xsd @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd/v3/module.xml b/xsd/v3/module.xml new file mode 100644 index 0000000..909ed93 --- /dev/null +++ b/xsd/v3/module.xml @@ -0,0 +1,83 @@ + + + + + Site Alpha + July 2008 + John Doe + john.doe@example.org + http://www.example.org + (C) 2008 Copyright Info + License Info + 1.6.0 + MOD_ALPHA_XML_DESCRIPTION + alpha.scriptfile.php + + + + + + + + sql/install.mysql.utf8.sql + + + + + + sql/uninstall.mysql.utf8.sql + + + + + + sql/updates/mysql + + + + + mod_alpha.php + any.php + sql + + + + com_alpha.jpg + + + + en-GB.mod_alpha.ini + fr-FR.mod_alpha.ini + + + + +
+ + + + + + + + + + + +
+
+ + + + + + + + + +
+
+
+
diff --git a/xsd/v3/module.xsd b/xsd/v3/module.xsd new file mode 100644 index 0000000..432bedd --- /dev/null +++ b/xsd/v3/module.xsd @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd/v3/package.xml b/xsd/v3/package.xml new file mode 100644 index 0000000..c052a80 --- /dev/null +++ b/xsd/v3/package.xml @@ -0,0 +1,29 @@ + + + Everything Demonstration + everything + 3.0.0 + http://www.joomla.org + Sam Moffatt + http://www.sammoffatt.com.au + Joomla! Installer Sample and Test Package. + http://update.joomla.org/update/packages/everything + + file.script.php + + + http://jsitepoint.com/update/package/everything/extension.xml + http://jsitepoint.com/update/update.xml + + + + lib_alpha.zip + com_alpha.zip + mod_alpha.zip + mod_alpha_admin.zip + plg_system_alpha.zip + tpl_simple.zip + lng_xx-XX.zip + lng_xx-XX_admin.zip + + \ No newline at end of file diff --git a/xsd/v3/package.xsd b/xsd/v3/package.xsd new file mode 100644 index 0000000..569cd24 --- /dev/null +++ b/xsd/v3/package.xsd @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Validate filepath + + + + + + + + diff --git a/xsd/v3/plugin.xml b/xsd/v3/plugin.xml new file mode 100644 index 0000000..fbb4739 --- /dev/null +++ b/xsd/v3/plugin.xml @@ -0,0 +1,82 @@ + + + System - Alpha + July 2008 + John Doe + john.doe@example.org + http://www.example.org + (C) 2008 Copyright Info + License Info + 1.6.0 + PLG_ALPHA_XML_DESCRIPTION + + alpha.scriptfile.php + + + + + + sql/install.mysql.utf8.sql + + + + + sql/uninstall.mysql.utf8.sql + + + + + sql/updates/mysql + + + + + alpha.php + sql + language + + + + com_alpha.jpg + + + + + + + +
+ + + + + + + + + + + +
+
+ + + + + + + + + +
+
+
+
diff --git a/xsd/v3/plugin.xsd b/xsd/v3/plugin.xsd new file mode 100644 index 0000000..a4e34cf --- /dev/null +++ b/xsd/v3/plugin.xsd @@ -0,0 +1,79 @@ + + + + + + + + + + + + author's name (e.g. Joomla! Project) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The group name specifies for which group of plugins the new plugin is available. The existing groups are the folder names within the directory /plugins. + The installer will create new folder names for group names that do not exist yet. + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd/v3/templateDetails.xml b/xsd/v3/templateDetails.xml new file mode 100644 index 0000000..dafd533 --- /dev/null +++ b/xsd/v3/templateDetails.xml @@ -0,0 +1,29 @@ + + + + simple_template + July 2008 + John Doe + john.doe@example.org + http://www.example.org + (C) 2008 Copyright Info + License Info + 1.6.0 + TPL_TPL_SIMPLE_XML_DESCRIPTION + + index.php + + + + analytics + social + drawer + + + +
+ +
+
+
+
diff --git a/xsd/v3/templateDetails.xsd b/xsd/v3/templateDetails.xsd new file mode 100644 index 0000000..fea09ed --- /dev/null +++ b/xsd/v3/templateDetails.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xsd/validate.php b/xsd/validate.php index 2d69546..1c9b28e 100644 --- a/xsd/validate.php +++ b/xsd/validate.php @@ -6,6 +6,7 @@ class validate extends PHPUnit_Framework_TestCase protected static $count = 0; protected static $errors = 0; + protected $xml; protected function setUp() { From d418765f3b1b0eb0f654d310d2c1ea0c2d263b89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Walter?= Date: Sat, 1 Nov 2014 13:00:40 +0100 Subject: [PATCH 15/16] deleted not required files --- xsd/v3/README.md | 12 ---- xsd/v3/component.xml | 137 ------------------------------------- xsd/v3/language.xml | 24 ------- xsd/v3/library.xml | 20 ------ xsd/v3/module.xml | 83 ---------------------- xsd/v3/package.xml | 29 -------- xsd/v3/plugin.xml | 82 ---------------------- xsd/v3/templateDetails.xml | 29 -------- 8 files changed, 416 deletions(-) delete mode 100644 xsd/v3/README.md delete mode 100644 xsd/v3/component.xml delete mode 100644 xsd/v3/language.xml delete mode 100644 xsd/v3/library.xml delete mode 100644 xsd/v3/module.xml delete mode 100644 xsd/v3/package.xml delete mode 100644 xsd/v3/plugin.xml delete mode 100644 xsd/v3/templateDetails.xml diff --git a/xsd/v3/README.md b/xsd/v3/README.md deleted file mode 100644 index a84713a..0000000 --- a/xsd/v3/README.md +++ /dev/null @@ -1,12 +0,0 @@ -joomla-xsd -========== - -Schema Validation for Joomla 1.6/1.7/2.5/3.0/3.1 Extensions - -Without them, Joomla accept any entry in manifest xml and never complains about - -* Mistyping, like a valid xml but that the Joomla installer do not understand or only partially, -* Wrong constructs, xml tag child misplaced, -* Invalid data type, like a path not being a valid path, an expected integer being a text and so on… -Joomla just silently die during install or install only partially extensions. These days are over as developers with any -decent IDE will be able to validate while typing and enjoy auto completion. diff --git a/xsd/v3/component.xml b/xsd/v3/component.xml deleted file mode 100644 index 8050759..0000000 --- a/xsd/v3/component.xml +++ /dev/null @@ -1,137 +0,0 @@ - - - - - - com_alpha - John Doe - john.doe@example.org - http://www.example.org - (C) 2008 Copyright Info - License Info - 1.0 - March 2006 - COM_ALPHA_XML_DESCRIPTION - - - file.script.php - - - - - - sql/install.mysql.utf8.sql - - - - - sql/uninstall.mysql.utf8.sql - - - - - sql/updates/mysql - sql/updates/sqlsrv - - - - - - alpha.php - - - - - - - - com_alpha.jpg - - - - - Alpha - - Installer - Users - - - - admin.alpha.php - image.png - applications-internet.png - applications-internet-16.png - sql - - - - - - en-GB/en-GB.com_alpha.ini - en-GB/en-GB.com_alpha.sys.ini - - - - - - - http://jsitepoint.com/update/components/com_alpha/extension.xml - http://jsitepoint.com/update/update.xml - - - - - - #__alpha_install
- #__alpha_update
-
- - - - - - - - -
- - - - - - - - - - - -
-
- - - - - - - - - -
-
-
- -
diff --git a/xsd/v3/language.xml b/xsd/v3/language.xml deleted file mode 100644 index 3f541a5..0000000 --- a/xsd/v3/language.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - Examplish (Example) - en-US - 1.6.0 - 2008-03-15 - Joomla! Project - admin@joomla.org - www.joomla.org - Copyright (C) 2005 - 2011 Open Source Matters. All rights reserved. - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - - - Examplish (Example) - xx-XX - 0 - xx_XX.utf8, xx_XX.UTF-8, xx_XX, xx, examplish, examplish-example - iso-8859-1 - examplish - freesans - - - - diff --git a/xsd/v3/library.xml b/xsd/v3/library.xml deleted file mode 100644 index 610898a..0000000 --- a/xsd/v3/library.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - lib_alpha - alpha - LIB_ALPHA_XML_DESCRIPTION - July 2008 - John Doe - john.doe@example.org - http://www.example.org - (C) 2008 Copyright Info - License Info - 3.0.0 - Joomla! - http://www.joomla.org - http://update.joomla.org/libraries/alpha - - alpha.php - - \ No newline at end of file diff --git a/xsd/v3/module.xml b/xsd/v3/module.xml deleted file mode 100644 index 909ed93..0000000 --- a/xsd/v3/module.xml +++ /dev/null @@ -1,83 +0,0 @@ - - - - - Site Alpha - July 2008 - John Doe - john.doe@example.org - http://www.example.org - (C) 2008 Copyright Info - License Info - 1.6.0 - MOD_ALPHA_XML_DESCRIPTION - alpha.scriptfile.php - - - - - - - - sql/install.mysql.utf8.sql - - - - - - sql/uninstall.mysql.utf8.sql - - - - - - sql/updates/mysql - - - - - mod_alpha.php - any.php - sql - - - - com_alpha.jpg - - - - en-GB.mod_alpha.ini - fr-FR.mod_alpha.ini - - - - -
- - - - - - - - - - - -
-
- - - - - - - - - -
-
-
-
diff --git a/xsd/v3/package.xml b/xsd/v3/package.xml deleted file mode 100644 index c052a80..0000000 --- a/xsd/v3/package.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - Everything Demonstration - everything - 3.0.0 - http://www.joomla.org - Sam Moffatt - http://www.sammoffatt.com.au - Joomla! Installer Sample and Test Package. - http://update.joomla.org/update/packages/everything - - file.script.php - - - http://jsitepoint.com/update/package/everything/extension.xml - http://jsitepoint.com/update/update.xml - - - - lib_alpha.zip - com_alpha.zip - mod_alpha.zip - mod_alpha_admin.zip - plg_system_alpha.zip - tpl_simple.zip - lng_xx-XX.zip - lng_xx-XX_admin.zip - - \ No newline at end of file diff --git a/xsd/v3/plugin.xml b/xsd/v3/plugin.xml deleted file mode 100644 index fbb4739..0000000 --- a/xsd/v3/plugin.xml +++ /dev/null @@ -1,82 +0,0 @@ - - - System - Alpha - July 2008 - John Doe - john.doe@example.org - http://www.example.org - (C) 2008 Copyright Info - License Info - 1.6.0 - PLG_ALPHA_XML_DESCRIPTION - - alpha.scriptfile.php - - - - - - sql/install.mysql.utf8.sql - - - - - sql/uninstall.mysql.utf8.sql - - - - - sql/updates/mysql - - - - - alpha.php - sql - language - - - - com_alpha.jpg - - - - - - - -
- - - - - - - - - - - -
-
- - - - - - - - - -
-
-
-
diff --git a/xsd/v3/templateDetails.xml b/xsd/v3/templateDetails.xml deleted file mode 100644 index dafd533..0000000 --- a/xsd/v3/templateDetails.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - simple_template - July 2008 - John Doe - john.doe@example.org - http://www.example.org - (C) 2008 Copyright Info - License Info - 1.6.0 - TPL_TPL_SIMPLE_XML_DESCRIPTION - - index.php - - - - analytics - social - drawer - - - -
- -
-
-
-
From 8319655bfe5eb218cc0035e73d2943642c4981db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Walter?= Date: Tue, 30 Dec 2014 21:10:37 +0100 Subject: [PATCH 16/16] added jedupdate.xsd and unit test --- xsd/jed/README.md | 7 ++++ xsd/jed/jedupdate-sample.xml | 30 ++++++++++++++++ xsd/jed/jedupdate.xsd | 41 ++++++++++++++++++++++ xsd/jed/validate.php | 66 ++++++++++++++++++++++++++++++++++++ 4 files changed, 144 insertions(+) create mode 100644 xsd/jed/README.md create mode 100644 xsd/jed/jedupdate-sample.xml create mode 100644 xsd/jed/jedupdate.xsd create mode 100644 xsd/jed/validate.php diff --git a/xsd/jed/README.md b/xsd/jed/README.md new file mode 100644 index 0000000..1d0d05d --- /dev/null +++ b/xsd/jed/README.md @@ -0,0 +1,7 @@ + +call validate like this + +phpunit validate.php + + + diff --git a/xsd/jed/jedupdate-sample.xml b/xsd/jed/jedupdate-sample.xml new file mode 100644 index 0000000..d058eea --- /dev/null +++ b/xsd/jed/jedupdate-sample.xml @@ -0,0 +1,30 @@ + + + + + An introduction text. + + ### a title + * a list entry + * another list entry + + ### another title + Some text. + + + + http://www.acme.com + https://www.acme.com/download/ + https://www.acme.com/demo/ + https://www.acme.com/doc/ + https://www.acme.com/forums/ + https://www.acme.com/licence/ + + 1.0.0 + + + 25 + 30 + + \ No newline at end of file diff --git a/xsd/jed/jedupdate.xsd b/xsd/jed/jedupdate.xsd new file mode 100644 index 0000000..cc6fd8b --- /dev/null +++ b/xsd/jed/jedupdate.xsd @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This attribute describes the version. + + + + + + + + diff --git a/xsd/jed/validate.php b/xsd/jed/validate.php new file mode 100644 index 0000000..46678ed --- /dev/null +++ b/xsd/jed/validate.php @@ -0,0 +1,66 @@ +xml = new DOMDocument(); + libxml_use_internal_errors(true); + } + + public function testValidate_forFileJedUpdateSample_expectValidTrue() + { + // Arrange + $jedupdates = array(); + $jedupdates = dirname(__FILE__) . "/jedupdate-sample.xml"; + $schema = dirname(__FILE__) . "/jedupdate.xsd"; + + // Act + foreach ($jedupdates as $jedupdate) { + $this->xml->load($jedupdate); + $schemaValidate = $this->xml->schemaValidate($schema); + + // Assert + $this->libxml_display_errors(); + $this->assertEquals(TRUE, $schemaValidate); + } + } + + function libxml_display_error($error) + { + $return = "
\n"; + switch ($error->level) { + case LIBXML_ERR_WARNING: + $return .= "Warning $error->code: "; + break; + case LIBXML_ERR_ERROR: + $return .= "Error $error->code: "; + break; + case LIBXML_ERR_FATAL: + $return .= "Fatal Error $error->code: "; + break; + } + $return .= trim($error->message); + if ($error->file) { + $return .= " in $error->file"; + } + $return .= " on line $error->line\n"; + + return $return; + } + + private function libxml_display_errors() + { + $errors = libxml_get_errors(); + + self::$errors = self::$errors + sizeof($errors); + + foreach ($errors as $error) { + print $this->libxml_display_error($error); + } + libxml_clear_errors(); + } + +} \ No newline at end of file