diff --git a/.gitignore b/.gitignore index 7d31117..2f5790c 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ /bin/ /3.0/ /3.1/ +/3.2/ diff --git a/.travis.yml b/.travis.yml index eaaf440..bf9e932 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,10 +5,10 @@ php: - 7.1 install: - - php composer.phar install --dev --no-interaction --prefer-source + - composer install --dev --no-interaction --prefer-source script: - - bin/phpunit + - vendor/phpunit/phpunit/phpunit matrix: allow_failures: diff --git a/README.md b/README.md index dde7033..5964382 100644 --- a/README.md +++ b/README.md @@ -1,36 +1,57 @@ -# phpBB Translation Validator Extension +# phpBB Translation Validator -Allows to validate **phpBB** language packages. +This console application allows you to validate [phpBB](https://www.phpbb.com) language packages. -## Requirement +## Requirements -This extension requires PHP 5.6 to 7.1 to be set up. +This extension requires PHP 5.5.9 or above. -## Installation for validating a language package locally +### Installation -*Note:* the validator only works when you have the source language pack in your directory (default source language is `en`). +Firstly, download the latest British English (`en`) [language pack from phpBB.com](http://www.phpbb.com/customise/db/translation/british_english/) as this is the default source language. Then clone this repository and download the dependencies: -1. [Download](https://github.com/nickvergessen/phpbb-translation-validator/archive/master.zip) the package. -2. Run `php composer.phar install` to download the dependencies -3. Run `php src/Phpbb/TranslationValidator/PhpbbTranslationValidator.php` to get information how to run the validator + git clone https://github.com/phpbb/phpbb-translation-validator.git + composer.phar install -## Installation for validating a language package on TravisCI +For the easiest results, create a directory called `3.2` in the root of the Translation Validator. Upload the `en` language page into this directory, along with the languages you wish to test. Which leads e.g. to: -1. Add the TranslationValidator as a dependecy: + phpbb-translation-validator/3.2/en/ + phpbb-translation-validator/3.2/fr/ + phpbb-translation-validator/translation.php + +The simplest way to validate is to then run this command (the final argument is the language you wish to test and that has already been uploaded to the `3.2` directory; eg. `fr` for French): + + php translation.php validate fr + +There are more arguments that can be supplied. For example, suppose you wanted to have your `3.2` directory in a different location, you wanted to explicitly specify phpBB version 3.2, you wanted to run in safe mode and you wanted to see all notices displayed - you would run this command: + + php translation.php validate fr + --package-dir=/path/to/your/3.2 + --phpbb-version=3.2 + --safe-mode + --display-notices + +The `--safe-mode` flag indicates that you want to parse files instead of directly including them. This is useful if you want to run validations on a web server. + +## Tests + +[![Build Status](https://travis-ci.org/phpbb/phpbb-translation-validator.png?branch=master)](https://travis-ci.org/phpbb/phpbb-translation-validator) + +Add the TranslationValidator as a dependency: { "require-dev": { - "phpbb/translation-validator": "1.4.*" + "phpbb/translation-validator": "1.5.*" } } -2. Add the `php vendor/bin/PhpbbTranslationValidator.php` call you run locally to your `.travis.yml` +Then add the `php translation.php` call you run locally to your `.travis.yml` file. -## Tests and Continuous Intergration +We use Travis-CI as a continous intergtation server and phpunit for our unit testing. See more information on the [phpBB development wiki](https://wiki.phpbb.com/Unit_Tests). -[![Build Status](https://travis-ci.org/phpbb/phpbb-translation-validator.png?branch=master)](https://travis-ci.org/phpbb/phpbb-translation-validator) +To run the unit tests locally, use this command: -We use Travis-CI as a continous intergtation server and phpunit for our unit testing. See more information on the [phpBB development wiki](https://wiki.phpbb.com/Unit_Tests). + php vendor/phpunit/phpunit/phpunit tests/ ## License diff --git a/composer.json b/composer.json index c93f426..b9e2486 100644 --- a/composer.json +++ b/composer.json @@ -2,35 +2,37 @@ "name": "phpbb/translation-validator", "description": "A language package validator for phpBB language packs. Language packs are required to pass the validator when submitted to the language pack database.", "homepage": "https://github.com/phpbb/phpbb-translation-validator", - "version": "1.4.1", - "license": "GPL-2.0", + "version": "1.5.0", + "license": "GPL-2.0-only", "authors": [ { "name": "Joas Schilling", "email": "nickvergessen@phpbb.com", "homepage": "http://www.phpbb.com/", "role": "Developer" + }, + { + "name": "Battye", + "email": "battye@phpbb.com", + "homepage": "https://www.phpbb.com", + "role": "Developer" } ], "minimum-stability": "stable", "require": { - "php": ">=5.6", - "symfony/yaml": "2.6.*", - "symfony/console": "2.6.*", - "symfony/finder": "2.6.*" + "php": ">=5.5.9", + "symfony/yaml": "~3.0", + "symfony/console": "~3.0", + "symfony/finder": "~3.0", + "battye/php-array-parser": "~1.0" }, "require-dev": { "phpunit/phpunit": "~5.7" }, - "bin": [ - "src/Phpbb/TranslationValidator/PhpbbTranslationValidator.php" - ], - "config": { - "bin-dir": "bin" - }, "autoload": { "classmap": [ - "src/" + "src/", + "tests/" ] } } diff --git a/composer.lock b/composer.lock index 35f1de6..44944f4 100644 --- a/composer.lock +++ b/composer.lock @@ -1,50 +1,149 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "5789b1d4a880dbc2a2bf12c64102108a", + "content-hash": "2a3135e3613bc965ac1d7866893c1b3d", "packages": [ + { + "name": "battye/php-array-parser", + "version": "v1.0.4", + "source": { + "type": "git", + "url": "https://github.com/battye/php-array-parser.git", + "reference": "51338002233f0cae30a6aadcd4f45819e1329d19" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/battye/php-array-parser/zipball/51338002233f0cae30a6aadcd4f45819e1329d19", + "reference": "51338002233f0cae30a6aadcd4f45819e1329d19", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "symfony/phpunit-bridge": "^4.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "battye\\array_parser\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Parse text representation of a PHP array into an actual PHP array.", + "keywords": [ + "array", + "parser", + "php" + ], + "time": "2019-04-13T11:53:09+00:00" + }, + { + "name": "psr/log", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd", + "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "time": "2018-11-20T15:27:04+00:00" + }, { "name": "symfony/console", - "version": "v2.6.13", - "target-dir": "Symfony/Component/Console", + "version": "v3.4.24", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "0e5e18ae09d3f5c06367759be940e9ed3f568359" + "reference": "98ae3cdc4bec48fe7ee24afc81dbb4a242186c9e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/0e5e18ae09d3f5c06367759be940e9ed3f568359", - "reference": "0e5e18ae09d3f5c06367759be940e9ed3f568359", + "url": "https://api.github.com/repos/symfony/console/zipball/98ae3cdc4bec48fe7ee24afc81dbb4a242186c9e", + "reference": "98ae3cdc4bec48fe7ee24afc81dbb4a242186c9e", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^5.5.9|>=7.0.8", + "symfony/debug": "~2.8|~3.0|~4.0", + "symfony/polyfill-mbstring": "~1.0" + }, + "conflict": { + "symfony/dependency-injection": "<3.4", + "symfony/process": "<3.3" + }, + "provide": { + "psr/log-implementation": "1.0" }, "require-dev": { "psr/log": "~1.0", - "symfony/event-dispatcher": "~2.1", - "symfony/phpunit-bridge": "~2.7", - "symfony/process": "~2.1" + "symfony/config": "~3.3|~4.0", + "symfony/dependency-injection": "~3.4|~4.0", + "symfony/event-dispatcher": "~2.8|~3.0|~4.0", + "symfony/lock": "~3.4|~4.0", + "symfony/process": "~3.3|~4.0" }, "suggest": { "psr/log": "For using the console logger", "symfony/event-dispatcher": "", + "symfony/lock": "", "symfony/process": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.6-dev" + "dev-master": "3.4-dev" } }, "autoload": { - "psr-0": { + "psr-4": { "Symfony\\Component\\Console\\": "" - } + }, + "exclude-from-classmap": [ + "/Tests/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -62,40 +161,95 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2015-07-26T09:08:40+00:00" + "time": "2019-03-31T11:33:18+00:00" }, { - "name": "symfony/finder", - "version": "v2.6.13", - "target-dir": "Symfony/Component/Finder", + "name": "symfony/debug", + "version": "v3.4.24", "source": { "type": "git", - "url": "https://github.com/symfony/finder.git", - "reference": "203a10f928ae30176deeba33512999233181dd28" + "url": "https://github.com/symfony/debug.git", + "reference": "adbdd5d66342fb0a0bce7422ba68181842b6610d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/203a10f928ae30176deeba33512999233181dd28", - "reference": "203a10f928ae30176deeba33512999233181dd28", + "url": "https://api.github.com/repos/symfony/debug/zipball/adbdd5d66342fb0a0bce7422ba68181842b6610d", + "reference": "adbdd5d66342fb0a0bce7422ba68181842b6610d", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^5.5.9|>=7.0.8", + "psr/log": "~1.0" + }, + "conflict": { + "symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2" }, "require-dev": { - "symfony/phpunit-bridge": "~2.7" + "symfony/http-kernel": "~2.8|~3.0|~4.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.6-dev" + "dev-master": "3.4-dev" } }, "autoload": { - "psr-0": { - "Symfony\\Component\\Finder\\": "" + "psr-4": { + "Symfony\\Component\\Debug\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Debug Component", + "homepage": "https://symfony.com", + "time": "2019-03-10T17:07:42+00:00" + }, + { + "name": "symfony/finder", + "version": "v3.4.24", + "source": { + "type": "git", + "url": "https://github.com/symfony/finder.git", + "reference": "fcdde4aa38f48190ce70d782c166f23930084f9b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/finder/zipball/fcdde4aa38f48190ce70d782c166f23930084f9b", + "reference": "fcdde4aa38f48190ce70d782c166f23930084f9b", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4-dev" } }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Finder\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" @@ -112,39 +266,165 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2015-07-09T16:02:48+00:00" + "time": "2019-02-22T14:44:53+00:00" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.11.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "82ebae02209c21113908c229e9883c419720738a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/82ebae02209c21113908c229e9883c419720738a", + "reference": "82ebae02209c21113908c229e9883c419720738a", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.11-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + }, + { + "name": "Gert de Pagter", + "email": "backendtea@gmail.com" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "time": "2019-02-06T07:57:58+00:00" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.11.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "fe5e94c604826c35a32fa832f35bd036b6799609" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/fe5e94c604826c35a32fa832f35bd036b6799609", + "reference": "fe5e94c604826c35a32fa832f35bd036b6799609", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.11-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "time": "2019-02-06T07:57:58+00:00" }, { "name": "symfony/yaml", - "version": "v2.6.13", - "target-dir": "Symfony/Component/Yaml", + "version": "v3.4.24", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "c044d1744b8e91aaaa0d9bac683ab87ec7cbf359" + "reference": "212a27b731e5bfb735679d1ffaac82bd6a1dc996" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/c044d1744b8e91aaaa0d9bac683ab87ec7cbf359", - "reference": "c044d1744b8e91aaaa0d9bac683ab87ec7cbf359", + "url": "https://api.github.com/repos/symfony/yaml/zipball/212a27b731e5bfb735679d1ffaac82bd6a1dc996", + "reference": "212a27b731e5bfb735679d1ffaac82bd6a1dc996", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^5.5.9|>=7.0.8", + "symfony/polyfill-ctype": "~1.8" + }, + "conflict": { + "symfony/console": "<3.4" }, "require-dev": { - "symfony/phpunit-bridge": "~2.7" + "symfony/console": "~3.4|~4.0" + }, + "suggest": { + "symfony/console": "For validating YAML files using the lint command" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.6-dev" + "dev-master": "3.4-dev" } }, "autoload": { - "psr-0": { + "psr-4": { "Symfony\\Component\\Yaml\\": "" - } + }, + "exclude-from-classmap": [ + "/Tests/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -162,7 +442,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2015-07-26T08:59:42+00:00" + "time": "2019-03-25T07:48:46+00:00" } ], "packages-dev": [ @@ -413,33 +693,33 @@ }, { "name": "phpspec/prophecy", - "version": "1.7.3", + "version": "1.8.0", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "e4ed002c67da8eceb0eb8ddb8b3847bb53c5c2bf" + "reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/e4ed002c67da8eceb0eb8ddb8b3847bb53c5c2bf", - "reference": "e4ed002c67da8eceb0eb8ddb8b3847bb53c5c2bf", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/4ba436b55987b4bf311cb7c6ba82aa528aac0a06", + "reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.2", "php": "^5.3|^7.0", "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0", - "sebastian/comparator": "^1.1|^2.0", + "sebastian/comparator": "^1.1|^2.0|^3.0", "sebastian/recursion-context": "^1.0|^2.0|^3.0" }, "require-dev": { "phpspec/phpspec": "^2.5|^3.2", - "phpunit/phpunit": "^4.8.35 || ^5.7" + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.7.x-dev" + "dev-master": "1.8.x-dev" } }, "autoload": { @@ -472,7 +752,7 @@ "spy", "stub" ], - "time": "2017-11-24T13:59:53+00:00" + "time": "2018-08-05T17:53:17+00:00" }, { "name": "phpunit/php-code-coverage", @@ -725,16 +1005,16 @@ }, { "name": "phpunit/phpunit", - "version": "5.7.26", + "version": "5.7.27", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "7fbc25c13309de0c4c9bb48b7361f1eca34c7fbd" + "reference": "b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/7fbc25c13309de0c4c9bb48b7361f1eca34c7fbd", - "reference": "7fbc25c13309de0c4c9bb48b7361f1eca34c7fbd", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c", + "reference": "b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c", "shasum": "" }, "require": { @@ -758,7 +1038,7 @@ "sebastian/global-state": "^1.1", "sebastian/object-enumerator": "~2.0", "sebastian/resource-operations": "~1.0", - "sebastian/version": "~1.0.3|~2.0", + "sebastian/version": "^1.0.6|^2.0.1", "symfony/yaml": "~2.1|~3.0|~4.0" }, "conflict": { @@ -803,7 +1083,7 @@ "testing", "xunit" ], - "time": "2017-12-17T06:14:38+00:00" + "time": "2018-02-01T05:50:59+00:00" }, { "name": "phpunit/phpunit-mock-objects", @@ -862,6 +1142,7 @@ "mock", "xunit" ], + "abandoned": true, "time": "2017-06-30T09:13:00+00:00" }, { @@ -1379,20 +1660,21 @@ }, { "name": "webmozart/assert", - "version": "1.2.0", + "version": "1.4.0", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f" + "reference": "83e253c8e0be5b0257b881e1827274667c5c17a9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/2db61e59ff05fe5126d152bd0655c9ea113e550f", - "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f", + "url": "https://api.github.com/repos/webmozart/assert/zipball/83e253c8e0be5b0257b881e1827274667c5c17a9", + "reference": "83e253c8e0be5b0257b881e1827274667c5c17a9", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0" + "php": "^5.3.3 || ^7.0", + "symfony/polyfill-ctype": "^1.8" }, "require-dev": { "phpunit/phpunit": "^4.6", @@ -1425,7 +1707,7 @@ "check", "validate" ], - "time": "2016-11-23T20:04:58+00:00" + "time": "2018-12-25T11:19:39+00:00" } ], "aliases": [], @@ -1434,7 +1716,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=5.3.3" + "php": ">=5.5.9" }, "platform-dev": [] } diff --git a/composer.phar b/composer.phar deleted file mode 100644 index 3f7693b..0000000 Binary files a/composer.phar and /dev/null differ diff --git a/phpunit.xml b/phpunit.xml index 2dec67a..3c3930e 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -14,7 +14,7 @@ > - ./src/Phpbb/TranslationValidator/Tests/ + ./tests/ diff --git a/src/Phpbb/TranslationValidator/Command/ValidateCommand.php b/src/Phpbb/TranslationValidator/Command/ValidateCommand.php index 12e3609..9a65e23 100644 --- a/src/Phpbb/TranslationValidator/Command/ValidateCommand.php +++ b/src/Phpbb/TranslationValidator/Command/ValidateCommand.php @@ -25,12 +25,13 @@ protected function configure() ->setName('validate') ->setDescription('Run the validator on your language pack.') ->addArgument('origin-iso', InputArgument::REQUIRED, 'The ISO of the language to validate') - ->addOption('phpbb-version', null, InputOption::VALUE_OPTIONAL, 'The phpBB Version to validate against (3.0|3.1|3.2)', '3.1') + ->addOption('phpbb-version', null, InputOption::VALUE_OPTIONAL, 'The phpBB Version to validate against', '3.2') ->addOption('source-iso', null, InputOption::VALUE_OPTIONAL, 'The ISO of the language to validate against', 'en') ->addOption('package-dir', null, InputOption::VALUE_OPTIONAL, 'The path to the directory with the language packages', null) ->addOption('language-dir', null, InputOption::VALUE_OPTIONAL, 'The path to the directory with the language folders', null) ->addOption('debug', null, InputOption::VALUE_NONE, 'Run in debug') - ->addOption('display-notices', 'dn', InputOption::VALUE_NONE, 'Display notices in report') + ->addOption('display-notices', null, InputOption::VALUE_NONE, 'Display notices in report') + ->addOption('safe-mode', 's', InputOption::VALUE_NONE, 'Run in web safe mode to parse files instead of including them') ; } @@ -49,20 +50,29 @@ protected function execute(InputInterface $input, OutputInterface $output) $languageDir = $input->getOption('language-dir'); $debug = $input->getOption('debug'); $displayNotices = $input->getOption('display-notices'); + $safeMode = $input->getOption('safe-mode'); - if (!in_array($phpbbVersion, array('3.0', '3.1', '3.2'))) + if (!in_array($phpbbVersion, array('3.2'))) { - throw new \RuntimeException('Invalid phpbb-version, allowed versions: 3.0, 3.1 and 3.2'); + throw new \RuntimeException('Invalid phpbb-version, allowed versions: 3.2'); } $output = new Output($output, $debug); $output->setFormatter(new OutputFormatter($output->isDecorated())); $output->writeln("Running Language Pack Validator on language $originIso."); + + // If it's safe mode, just put a note so the person running knows it is not as thorough as running it manually + if ($safeMode) + { + $output->writeln('[Safe Mode] Running in web safe mode; it is recommended to still run the script manually for completeness.'); + } + $output->writeln(''); $runner = new ValidatorRunner($input, $output); $runner->setPhpbbVersion($phpbbVersion) - ->setDebug($debug); + ->setDebug($debug) + ->setSafeMode($safeMode); if ($packageDir !== null) { diff --git a/src/Phpbb/TranslationValidator/Output/Output.php b/src/Phpbb/TranslationValidator/Output/Output.php index 4b3c8e5..67b9332 100644 --- a/src/Phpbb/TranslationValidator/Output/Output.php +++ b/src/Phpbb/TranslationValidator/Output/Output.php @@ -31,7 +31,7 @@ class Output implements \Phpbb\TranslationValidator\Output\OutputInterface /** @var bool */ protected $debug; - public function __construct(\Symfony\Component\Console\Output\OutputInterface $output, $debug) + public function __construct(OutputInterface $output, $debug) { $this->output = $output; $this->debug = $debug; @@ -213,4 +213,44 @@ public function getMessageCount($type) } return 0; } + + /** + * Returns whether verbosity is quiet (-q). + * + * @return bool true if verbosity is set to VERBOSITY_QUIET, false otherwise + */ + public function isQuiet() + { + // TODO: Implement isQuiet() method. + } + + /** + * Returns whether verbosity is verbose (-v). + * + * @return bool true if verbosity is set to VERBOSITY_VERBOSE, false otherwise + */ + public function isVerbose() + { + // TODO: Implement isVerbose() method. + } + + /** + * Returns whether verbosity is very verbose (-vv). + * + * @return bool true if verbosity is set to VERBOSITY_VERY_VERBOSE, false otherwise + */ + public function isVeryVerbose() + { + // TODO: Implement isVeryVerbose() method. + } + + /** + * Returns whether verbosity is debug (-vvv). + * + * @return bool true if verbosity is set to VERBOSITY_DEBUG, false otherwise + */ + public function isDebug() + { + // TODO: Implement isDebug() method. + } } diff --git a/src/Phpbb/TranslationValidator/Output/OutputInterface.php b/src/Phpbb/TranslationValidator/Output/OutputInterface.php index 63c5424..26879bb 100644 --- a/src/Phpbb/TranslationValidator/Output/OutputInterface.php +++ b/src/Phpbb/TranslationValidator/Output/OutputInterface.php @@ -8,7 +8,9 @@ */ namespace Phpbb\TranslationValidator\Output; -interface OutputInterface extends \Symfony\Component\Console\Output\OutputInterface +use Symfony\Component\Console\Output\OutputInterface as SymfonyOutputInterface; + +interface OutputInterface extends SymfonyOutputInterface { const FATAL = 4; const WARNING = 3; diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/FileListTest.php b/src/Phpbb/TranslationValidator/Tests/FileListValidator/FileListTest.php deleted file mode 100644 index 4e1c6ad..0000000 --- a/src/Phpbb/TranslationValidator/Tests/FileListValidator/FileListTest.php +++ /dev/null @@ -1,113 +0,0 @@ -validator = new \Phpbb\TranslationValidator\Validator\FileListValidator($this->getMock('Symfony\Component\Console\Input\InputInterface'), $this->output); - } - - public function validateFileListData() - { - return array( - array( - '3.0', - array( - Output::FATAL . '-Missing required file-missing.php-', - Output::FATAL . '-Missing required file-missing.txt-', - Output::FATAL . '-Missing required file-subdir/missing.php-', - Output::FATAL . '-Missing required file-language/origin/LICENSE-', - Output::FATAL . '-Missing required file-styles/subsilver2/nosubsilver.txt-', - Output::FATAL . '-Found additional file-additional.php-', - Output::FATAL . '-Found additional file-subdir/additional.php-', - Output::FATAL . '-Found additional file-additional.txt-', - - Output::NOTICE . '-Found additional file-language/origin/AUTHORS.md-', - Output::NOTICE . '-Found additional file-language/origin/CHANGELOG.md-', - Output::NOTICE . '-Found additional file-language/origin/README.md-', - Output::NOTICE . '-Found additional file-language/origin/VERSION.md-', - Output::NOTICE . '-Found additional file-language/origin/AUTHORS-', - Output::NOTICE . '-Found additional file-language/origin/CHANGELOG-', - Output::NOTICE . '-Found additional file-language/origin/README-', - Output::NOTICE . '-Found additional file-language/origin/VERSION-', - Output::NOTICE . '-Found additional file-language/origin/index.htm-', - ), - ), - array( - '3.1', - array( - Output::FATAL . '-Missing required file-missing.php-', - Output::FATAL . '-Missing required file-missing.txt-', - Output::FATAL . '-Missing required file-subdir/missing.php-', - Output::FATAL . '-Missing required file-language/origin/LICENSE-', - Output::FATAL . '-Found additional file-additional.php-', - Output::FATAL . '-Found additional file-subdir/additional.php-', - Output::FATAL . '-Found additional file-additional.txt-', - - Output::WARNING . '-Missing subsilver2 files--', - - Output::NOTICE . '-Found additional file-language/origin/AUTHORS.md-', - Output::NOTICE . '-Found additional file-language/origin/CHANGELOG.md-', - Output::NOTICE . '-Found additional file-language/origin/README.md-', - Output::NOTICE . '-Found additional file-language/origin/VERSION.md-', - Output::NOTICE . '-Found additional file-language/origin/AUTHORS-', - Output::NOTICE . '-Found additional file-language/origin/CHANGELOG-', - Output::NOTICE . '-Found additional file-language/origin/README-', - Output::NOTICE . '-Found additional file-language/origin/VERSION-', - Output::NOTICE . '-Found additional file-language/origin/index.htm-', - ), - ), - array( - '3.2', - array( - Output::FATAL . '-Missing required file-missing.php-', - Output::FATAL . '-Missing required file-missing.txt-', - Output::FATAL . '-Missing required file-subdir/missing.php-', - Output::FATAL . '-Missing required file-language/origin/LICENSE-', - Output::FATAL . '-Found additional file-additional.php-', - Output::FATAL . '-Found additional file-subdir/additional.php-', - Output::FATAL . '-Found additional file-additional.txt-', - Output::FATAL . '-Found additional file-language/origin/AUTHORS-', - Output::FATAL . '-Found additional file-language/origin/CHANGELOG-', - Output::FATAL . '-Found additional file-language/origin/README-', - Output::FATAL . '-Found additional file-language/origin/VERSION-', - - Output::NOTICE . '-Found additional file-language/origin/AUTHORS.md-', - Output::NOTICE . '-Found additional file-language/origin/CHANGELOG.md-', - Output::NOTICE . '-Found additional file-language/origin/README.md-', - Output::NOTICE . '-Found additional file-language/origin/VERSION.md-', - Output::NOTICE . '-Found additional file-language/origin/index.htm-', - ), - ), - ); - } - - /** - * @dataProvider validateFileListData - */ - public function testValidateFileList($phpbbVersion, $expected) - { - $this->validator->setOrigin('origin', dirname(__FILE__) . '/fixtures/'. $phpbbVersion . '/origin', 'language/origin/') - ->setSource('source', dirname(__FILE__) . '/fixtures/'. $phpbbVersion . '/source', 'language/source/'); - - $this->validator - ->setPhpbbVersion($phpbbVersion) - ->validate(); - $this->assertOutputMessages($expected); - } -} diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.0/source/styles/subsilver2/nosubsilver.txt b/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.0/source/styles/subsilver2/nosubsilver.txt deleted file mode 100644 index e69de29..0000000 diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.1/origin/additional.php b/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.1/origin/additional.php deleted file mode 100644 index e69de29..0000000 diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.1/origin/additional.txt b/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.1/origin/additional.txt deleted file mode 100644 index e69de29..0000000 diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.1/origin/file.php b/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.1/origin/file.php deleted file mode 100644 index e69de29..0000000 diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.1/origin/language/origin/AUTHORS b/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.1/origin/language/origin/AUTHORS deleted file mode 100644 index e69de29..0000000 diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.1/origin/language/origin/AUTHORS.md b/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.1/origin/language/origin/AUTHORS.md deleted file mode 100644 index e69de29..0000000 diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.1/origin/language/origin/CHANGELOG b/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.1/origin/language/origin/CHANGELOG deleted file mode 100644 index e69de29..0000000 diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.1/origin/language/origin/CHANGELOG.md b/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.1/origin/language/origin/CHANGELOG.md deleted file mode 100644 index e69de29..0000000 diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.1/origin/language/origin/README b/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.1/origin/language/origin/README deleted file mode 100644 index e69de29..0000000 diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.1/origin/language/origin/README.md b/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.1/origin/language/origin/README.md deleted file mode 100644 index e69de29..0000000 diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.1/origin/language/origin/VERSION b/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.1/origin/language/origin/VERSION deleted file mode 100644 index e69de29..0000000 diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.1/origin/language/origin/VERSION.md b/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.1/origin/language/origin/VERSION.md deleted file mode 100644 index e69de29..0000000 diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.1/origin/language/origin/index.htm b/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.1/origin/language/origin/index.htm deleted file mode 100644 index e69de29..0000000 diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.1/origin/subdir/additional.php b/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.1/origin/subdir/additional.php deleted file mode 100644 index e69de29..0000000 diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.1/origin/subdir/file.php b/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.1/origin/subdir/file.php deleted file mode 100644 index e69de29..0000000 diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.1/source/file.php b/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.1/source/file.php deleted file mode 100644 index e69de29..0000000 diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.1/source/missing.php b/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.1/source/missing.php deleted file mode 100644 index e69de29..0000000 diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.1/source/missing.txt b/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.1/source/missing.txt deleted file mode 100644 index e69de29..0000000 diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.1/source/styles/subsilver2/nosubsilver.txt b/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.1/source/styles/subsilver2/nosubsilver.txt deleted file mode 100644 index e69de29..0000000 diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.1/source/subdir/file.php b/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.1/source/subdir/file.php deleted file mode 100644 index e69de29..0000000 diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.1/source/subdir/missing.php b/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.1/source/subdir/missing.php deleted file mode 100644 index e69de29..0000000 diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.2/origin/additional.php b/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.2/origin/additional.php deleted file mode 100644 index e69de29..0000000 diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.2/origin/additional.txt b/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.2/origin/additional.txt deleted file mode 100644 index e69de29..0000000 diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.2/origin/file.php b/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.2/origin/file.php deleted file mode 100644 index e69de29..0000000 diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.2/origin/language/origin/AUTHORS b/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.2/origin/language/origin/AUTHORS deleted file mode 100644 index e69de29..0000000 diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.2/origin/language/origin/AUTHORS.md b/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.2/origin/language/origin/AUTHORS.md deleted file mode 100644 index e69de29..0000000 diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.2/origin/language/origin/CHANGELOG b/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.2/origin/language/origin/CHANGELOG deleted file mode 100644 index e69de29..0000000 diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.2/origin/language/origin/CHANGELOG.md b/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.2/origin/language/origin/CHANGELOG.md deleted file mode 100644 index e69de29..0000000 diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.2/origin/language/origin/README b/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.2/origin/language/origin/README deleted file mode 100644 index e69de29..0000000 diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.2/origin/language/origin/README.md b/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.2/origin/language/origin/README.md deleted file mode 100644 index e69de29..0000000 diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.2/origin/language/origin/VERSION b/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.2/origin/language/origin/VERSION deleted file mode 100644 index e69de29..0000000 diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.2/origin/language/origin/VERSION.md b/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.2/origin/language/origin/VERSION.md deleted file mode 100644 index e69de29..0000000 diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.2/origin/language/origin/index.htm b/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.2/origin/language/origin/index.htm deleted file mode 100644 index e69de29..0000000 diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.2/origin/subdir/additional.php b/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.2/origin/subdir/additional.php deleted file mode 100644 index e69de29..0000000 diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.2/origin/subdir/file.php b/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.2/origin/subdir/file.php deleted file mode 100644 index e69de29..0000000 diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.2/source/file.php b/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.2/source/file.php deleted file mode 100644 index e69de29..0000000 diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.2/source/missing.php b/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.2/source/missing.php deleted file mode 100644 index e69de29..0000000 diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.2/source/missing.txt b/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.2/source/missing.txt deleted file mode 100644 index e69de29..0000000 diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.2/source/subdir/file.php b/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.2/source/subdir/file.php deleted file mode 100644 index e69de29..0000000 diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.2/source/subdir/missing.php b/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.2/source/subdir/missing.php deleted file mode 100644 index e69de29..0000000 diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/origin/language/origin/common.php b/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/origin/language/origin/common.php deleted file mode 100644 index dbbdd34..0000000 --- a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/origin/language/origin/common.php +++ /dev/null @@ -1,45 +0,0 @@ - -* @license GNU General Public License, version 2 (GPL-2.0) -* -* For full copyright and license information, please see -* the docs/CREDITS.txt file. -* -*/ - -/** -* DO NOT CHANGE -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - -if (empty($lang) || !is_array($lang)) -{ - $lang = array(); -} - -// DEVELOPERS PLEASE NOTE -// -// All language files should use UTF-8 as their encoding and the files must not contain a BOM. -// -// Placeholders can now contain order information, e.g. instead of -// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows -// translators to re-order the output of data while ensuring it remains correct -// -// You do not need this where single placeholders are used, e.g. 'Message %d' is fine -// equally where a string contains only two placeholders which are used to wrap text -// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine -// -// Some characters you may want to copy&paste: -// ’ » “ ” … -// - -$lang = array_merge($lang, array( - 'DIRECTION' => 'ltr', -)); diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/ValidateNoPhpClosingTagTest.php b/src/Phpbb/TranslationValidator/Tests/FileValidator/ValidateNoPhpClosingTagTest.php deleted file mode 100644 index ccbb57c..0000000 --- a/src/Phpbb/TranslationValidator/Tests/FileValidator/ValidateNoPhpClosingTagTest.php +++ /dev/null @@ -1,48 +0,0 @@ -validator->setPhpbbVersion($phpbbVersion); - $this->validator->validateNoPhpClosingTag($file); - $this->assertOutputMessages($expected); - } -} diff --git a/src/Phpbb/TranslationValidator/Validator/FileListValidator.php b/src/Phpbb/TranslationValidator/Validator/FileListValidator.php index adc5492..2c5c5d2 100644 --- a/src/Phpbb/TranslationValidator/Validator/FileListValidator.php +++ b/src/Phpbb/TranslationValidator/Validator/FileListValidator.php @@ -32,6 +32,8 @@ class FileListValidator /** @var bool */ protected $debug; + /** @var bool */ + protected $safeMode; /** @var \Symfony\Component\Console\Input\InputInterface */ protected $input; @@ -83,7 +85,7 @@ public function setSource($sourceIso, $sourcePath, $sourceLanguagePath) /** * Set phpBB Version * - * @param string $phpbbVersion The phpBB Version to validate against (3.0|3.1|3.2) + * @param string $phpbbVersion The phpBB Version to validate against * @return $this */ public function setPhpbbVersion($phpbbVersion) @@ -104,6 +106,18 @@ public function setDebug($debug) return $this; } + /** + * Set safe mode + * + * @param $safeMode + * @return $this + */ + public function setSafeMode($safeMode) + { + $this->safeMode = $safeMode; + return $this; + } + /** * Validates the directories * @@ -120,8 +134,19 @@ public function validate() $sourceFiles[] = $this->sourceLanguagePath . 'LICENSE'; $sourceFiles = array_unique($sourceFiles); - //Get $lang['direction'] of translation to allow additional rtl-files for rtl-translations - include($this->originPath . '/' . $this->originLanguagePath . 'common.php'); + // Get $lang['direction'] of translation to allow additional rtl-files for rtl-translations + $filePath = $this->originPath . '/' . $this->originLanguagePath . 'common.php'; + + if ($this->safeMode) + { + $lang = ValidatorRunner::langParser($filePath); + } + + else + { + include($filePath); + } + $direction = $lang['DIRECTION']; // Throw error, if invalid direction is used if (!in_array($direction, array('rtl', 'ltr'))) @@ -138,54 +163,20 @@ public function validate() $testOriginFile = str_replace('/' . $this->sourceIso . '/', '/' . $this->originIso . '/', $sourceFile); if (!in_array($testOriginFile, $originFiles)) { - if ($this->phpbbVersion === '3.1' && strpos($testOriginFile, 'styles/subsilver2/') === 0) - { - $missingSubsilver2Files[] = $testOriginFile; - } - else - { - $this->output->addMessage(Output::FATAL, 'Missing required file', $testOriginFile); - } + $this->output->addMessage(Output::FATAL, 'Missing required file', $testOriginFile); } else if (substr($sourceFile, -4) != '.gif' && substr($sourceFile, -12) != 'imageset.cfg') { - if ($this->phpbbVersion === '3.1' && strpos($testOriginFile, 'styles/subsilver2/') === 0) - { - $availableSubsilver2Files[] = $testOriginFile; - } $validFiles[$sourceFile] = $testOriginFile; } } - if ($this->phpbbVersion === '3.1' && !empty($availableSubsilver2Files) && !empty($missingSubsilver2Files)) - { - // Either subsilver2 has to be completly there, or not at all - foreach ($missingSubsilver2Files as $testOriginFile) - { - $this->output->addMessage(Output::FATAL, 'Missing required file', $testOriginFile); - } - } - else if ($this->phpbbVersion === '3.1' && empty($availableSubsilver2Files) && !empty($missingSubsilver2Files)) - { - // If subsilver2 is not there at all, we throw a little warning - $this->output->addMessage(Output::WARNING, 'Missing subsilver2 files'); - } - foreach ($originFiles as $origin_file) { $testSourceFile = str_replace('/' . $this->originIso . '/', '/' . $this->sourceIso . '/', $origin_file); if (!in_array($testSourceFile, $sourceFiles)) { - if (($this->phpbbVersion == '3.0' || $this->phpbbVersion == '3.1') && in_array($origin_file, array( - $this->originLanguagePath . 'AUTHORS', - $this->originLanguagePath . 'CHANGELOG', - $this->originLanguagePath . 'README', - $this->originLanguagePath . 'VERSION', - ))) - { - $this->output->addMessage(Output::NOTICE, 'Found additional file', $origin_file); - } - else if (in_array($origin_file, array( + if (in_array($origin_file, array( $this->originLanguagePath . 'AUTHORS.md', $this->originLanguagePath . 'CHANGELOG.md', $this->originLanguagePath . 'README.md', diff --git a/src/Phpbb/TranslationValidator/Validator/FileValidator.php b/src/Phpbb/TranslationValidator/Validator/FileValidator.php index 0e34eec..fbc2823 100644 --- a/src/Phpbb/TranslationValidator/Validator/FileValidator.php +++ b/src/Phpbb/TranslationValidator/Validator/FileValidator.php @@ -9,7 +9,6 @@ namespace Phpbb\TranslationValidator\Validator; use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Finder\Finder; use Phpbb\TranslationValidator\Output\Output; use Phpbb\TranslationValidator\Output\OutputInterface; @@ -32,6 +31,8 @@ class FileValidator /** @var bool */ protected $debug; + /** @var bool */ + protected $safeMode; /** @var \Symfony\Component\Console\Input\InputInterface */ protected $input; @@ -86,7 +87,7 @@ public function setSource($sourceIso, $sourcePath, $sourceLanguagePath) /** * Set phpBB Version * - * @param string $phpbbVersion The phpBB Version to validate against (3.0|3.1|3.2) + * @param string $phpbbVersion The phpBB Version to validate against * @return $this */ public function setPhpbbVersion($phpbbVersion) @@ -122,6 +123,18 @@ public function setDebug($debug) return $this; } + /** + * Set safe mode + * + * @param $safeMode + * @return $this + */ + public function setSafeMode($safeMode) + { + $this->safeMode = $safeMode; + return $this; + } + /** * Decides which validation function to use * @@ -171,7 +184,7 @@ public function validate($sourceFile, $originFile) { $this->validateIsoFile($originFile); } - else if ($this->phpbbVersion !== '3.0' && substr($originFile, -4) === '.css') + else if (substr($originFile, -4) === '.css') { $this->validateUtf8withoutbom($originFile); $this->validateCSSFile($sourceFile, $originFile); @@ -196,33 +209,57 @@ public function validate($sourceFile, $originFile) */ public function validateLangFile($sourceFile, $originFile) { - ob_start(); - /** @var $lang */ - include($this->originPath . '/' . $originFile); + $originFilePath = $this->originPath . '/' . $originFile; + $sourceFilePath = $this->sourcePath . '/' . $sourceFile; - $defined_variables = get_defined_vars(); - if (sizeof($defined_variables) != 3 || !isset($defined_variables['lang']) || gettype($defined_variables['lang']) != 'array') + if (!$this->safeMode) { - $this->output->addMessage(Output::FATAL, 'Must only contain the lang-array', $originFile); - if (!isset($defined_variables['lang']) || gettype($defined_variables['lang']) != 'array') + ob_start(); + + /** @var $lang */ + include($originFilePath); + + $defined_variables = get_defined_vars(); + if (sizeof($defined_variables) != 5 || !isset($defined_variables['lang']) || gettype($defined_variables['lang']) != 'array') { - return; + $this->output->addMessage(Output::FATAL, 'Must only contain the lang-array', $originFile); + if (!isset($defined_variables['lang']) || gettype($defined_variables['lang']) != 'array') + { + return; + } } - } - $output = ob_get_contents(); - ob_end_clean(); + $output = ob_get_contents(); + ob_end_clean(); + + if ($output !== '') + { + $this->output->addMessage(Output::FATAL, 'Must not produces output: ' . htmlspecialchars($output), $originFile); + } + } - if ($output !== '') + else { - $this->output->addMessage(Output::FATAL, 'Must not produces output: ' . htmlspecialchars($output), $originFile); + /** @var $lang */ + $lang = ValidatorRunner::langParser($originFilePath); + $this->output->addMessage(Output::NOTICE, '[Safe Mode] Manually run the translation validator to check for disallowed output.', $originFile); } $validate = $lang; unset($lang); - /** @var $lang */ - include($this->sourcePath . '/' . $sourceFile); + if (!$this->safeMode) + { + /** @var $lang */ + include($sourceFilePath); + } + + else + { + /** @var $lang */ + $lang = ValidatorRunner::langParser($sourceFilePath); + } + $against = $lang; unset($lang); @@ -340,8 +377,7 @@ public function validateEmail($sourceFile, $originFile) // Check for new liens at the end of the file if (end($originContent) !== '') { - $level = ($this->phpbbVersion !== '3.0') ? Output::FATAL : Output::NOTICE; - $this->output->addMessage($level, 'Missing new line at the end of the file', $originFile); + $this->output->addMessage(Output::FATAL, 'Missing new line at the end of the file', $originFile); } } @@ -365,21 +401,44 @@ public function validateEmail($sourceFile, $originFile) */ public function validateHelpFile($sourceFile, $originFile) { - /** @var $help */ - include($this->originPath . '/' . $originFile); + $originFilePath = $this->originPath . '/' . $originFile; + $sourceFilePath = $this->sourcePath . '/' . $sourceFile; - $defined_variables = get_defined_vars(); - if (sizeof($defined_variables) != 3 || !isset($defined_variables['help']) || gettype($defined_variables['help']) != 'array') + if (!$this->safeMode) { - $this->output->addMessage(Output::FATAL, 'Should only contain the help-array', $originFile); - return; + /** @var $help */ + include($originFilePath); + + $defined_variables = get_defined_vars(); + if (sizeof($defined_variables) != 5 || !isset($defined_variables['help']) || gettype($defined_variables['help']) != 'array') + { + $this->output->addMessage(Output::FATAL, 'Should only contain the help-array', $originFile); + return; + } + } + + else + { + /** @var $help */ + $help = ValidatorRunner::langParser($originFilePath); + $this->output->addMessage(Output::NOTICE, '[Safe Mode] Manually run the translation validator to check help variables.', $originFile); } $validate = $help; unset($help); - /** @var $help */ - include($this->sourcePath . '/' . $sourceFile); + if (!$this->safeMode) + { + /** @var $help */ + include($sourceFilePath); + } + + else + { + /** @var $help */ + $help = ValidatorRunner::langParser($sourceFilePath); + } + $against = $help; unset($help); @@ -429,14 +488,26 @@ public function validateHelpFile($sourceFile, $originFile) */ public function validateSearchSynonymsFile($originFile) { - /** @var $synonyms */ - include($this->originPath . '/' . $originFile); + $originFilePath = $this->originPath . '/' . $originFile; - $defined_variables = get_defined_vars(); - if (sizeof($defined_variables) != 2 || !isset($defined_variables['synonyms']) || gettype($defined_variables['synonyms']) != 'array') + if (!$this->safeMode) { - $this->output->addMessage(Output::FATAL, 'Must only contain the synonyms-array', $originFile); - return; + /** @var $synonyms */ + include($originFilePath); + + $defined_variables = get_defined_vars(); + if (sizeof($defined_variables) != 3 || !isset($defined_variables['synonyms']) || gettype($defined_variables['synonyms']) != 'array') + { + $this->output->addMessage(Output::FATAL, 'Must only contain the synonyms-array', $originFile); + return; + } + } + + else + { + /** @var $synonyms */ + $synonyms = ValidatorRunner::langParser($originFilePath); + $this->output->addMessage(Output::NOTICE, '[Safe Mode] Manually run the translation validator to check synonym variables.', $originFile); } foreach ($synonyms as $synonym1 => $synonym2) @@ -461,14 +532,26 @@ public function validateSearchSynonymsFile($originFile) */ public function validateSearchIgnoreWordsFile($originFile) { - /** @var $words */ - include($this->originPath . '/' . $originFile); + $originFilePath = $this->originPath . '/' . $originFile; - $defined_variables = get_defined_vars(); - if (sizeof($defined_variables) != 2 || !isset($defined_variables['words']) || gettype($defined_variables['words']) != 'array') + if (!$this->safeMode) { - $this->output->addMessage(Output::FATAL, 'Must only contain the words-array', $originFile); - return; + /** @var $words */ + include($originFilePath); + + $defined_variables = get_defined_vars(); + if (sizeof($defined_variables) != 3 || !isset($defined_variables['words']) || gettype($defined_variables['words']) != 'array') + { + $this->output->addMessage(Output::FATAL, 'Must only contain the words-array', $originFile); + return; + } + } + + else + { + /** @var $words */ + $words = ValidatorRunner::langParser($originFilePath); + $this->output->addMessage(Output::NOTICE, '[Safe Mode] Manually run the translation validator to check word variables.', $originFile); } foreach ($words as $word) @@ -584,11 +667,6 @@ public function validateUtf8withoutbom($originFile) */ public function validateNoPhpClosingTag($originFile) { - if ($this->phpbbVersion === '3.0') - { - return; - } - $fileContents = (string) file_get_contents($this->originPath . '/' . $originFile); $fileContents = str_replace("\r\n", "\n", $fileContents); $fileContents = str_replace("\r", "\n", $fileContents); @@ -600,10 +678,6 @@ public function validateNoPhpClosingTag($originFile) { $this->output->addMessage(Output::FATAL, 'File must not contain a PHP closing tag, but end with one new line', $originFile); } - else if ($this->phpbbVersion === '3.1') - { - $this->output->addMessage(OUTPUT::FATAL, 'File must not contain short array syntax for any version prior to 3.2', $originFile); - } } } diff --git a/src/Phpbb/TranslationValidator/Validator/LangKeyValidator.php b/src/Phpbb/TranslationValidator/Validator/LangKeyValidator.php index 6db07fd..827d5ef 100644 --- a/src/Phpbb/TranslationValidator/Validator/LangKeyValidator.php +++ b/src/Phpbb/TranslationValidator/Validator/LangKeyValidator.php @@ -96,7 +96,7 @@ public function setSource($sourceIso, $sourcePath, $sourceLanguagePath) /** * Set phpBB Version * - * @param string $phpbbVersion The phpBB Version to validate against (3.0|3.1|3.2) + * @param string $phpbbVersion The phpBB Version to validate against * @return $this */ public function setPhpbbVersion($phpbbVersion) @@ -146,7 +146,7 @@ public function validate($file, $key, $against_language, $validate_language) return; } - if ($this->phpbbVersion !== '3.0' && $key === 'PLURAL_RULE') + if ($key === 'PLURAL_RULE') { if ($validate_language < 0 || $validate_language > 15) { @@ -216,25 +216,6 @@ public function validateArray($file, $key, $against_language, $validate_language { $this->validateArrayKey($file, $key, $against_language, $validate_language); } - // ACL array in 3.0, removed in 3.1 - else if ($this->phpbbVersion === '3.0' && strpos($key, 'acl_') === 0) - { - $this->validateAcl($file, $key, $against_language, $validate_language); - } - // Some special arrays in 3.0, removed in 3.1 - else if ($this->phpbbVersion === '3.0' && ( - $key === 'permission_cat' || - $key === 'permission_type' || - $key === 'tz' || - $key === 'tz_zones')) - { - $this->validateArrayKey($file, $key, $against_language, $validate_language); - } - // Some special plurals in 3.0 - else if ($this->phpbbVersion === '3.0' && ($key === 'datetime.AGO' || $key === 'NUM_POSTS_IN_QUEUE' || $key === 'USER_LAST_REMINDED')) - { - $this->validateArrayKey($file, $key, $against_language, $validate_language); - } else { $against_keys = array_keys($against_language); @@ -255,15 +236,10 @@ public function validateArray($file, $key, $against_language, $validate_language { $this->validateArrayKey($file, $key, $against_language, $validate_language); } - else if ($this->phpbbVersion !== '3.0' && isset($key_types['integer'])) + else if (isset($key_types['integer'])) { $this->validatePluralKeys($file, $key, $against_language, $validate_language); } - else if ($this->phpbbVersion === '3.0' && isset($key_types['integer'])) - { - // For 3.0 this should not happen - $this->output->addMessage(Output::NOTICE, 'Array has unsupported type integer', $file, $key); - } else { $this->output->addMessage(Output::NOTICE, 'Array has mixed types: ' . implode(', ', array_keys($key_types)), $file, $key); @@ -284,11 +260,12 @@ public function validateArray($file, $key, $against_language, $validate_language * There must not be an additional case * There might be less cases then possible * - * @param string $file File to validate - * @param string $key Key to validate - * @param array $against_language Original language - * @param array $validate_language Translated language - * @return null + * @param string $file File to validate + * @param string $key Key to validate + * @param array $against_language Original language + * @param array $validate_language Translated language + * @return null + * @throws \Exception */ public function validatePluralKeys($file, $key, $against_language, $validate_language) { @@ -494,11 +471,6 @@ public function validateArrayKey($file, $key, $against_language, $validate_langu { $this->output->addMessage(Output::FATAL, 'Array has invalid key: ' . $array_key, $file, $key); } - else if ($this->phpbbVersion === '3.0' && ($key === 'datetime.AGO' || $key === 'NUM_POSTS_IN_QUEUE' || $key === 'USER_LAST_REMINDED')) - { - // 3.0 plurals - $this->output->addMessage(Output::WARNING, 'Array has additional key: ' . $array_key, $file, $key); - } else { // Strangly used plural? @@ -573,15 +545,7 @@ public function validateString($file, $key, $against_language, $validate_languag { if (!$is_plural || ($is_plural && abs($against_integers - $validate_integers) !== 1)) { - $level = Output::FATAL; - // phpBB 3.0 Plural workarounds - if ($this->phpbbVersion === '3.0' && abs($against_integers - $validate_integers) === 1 && - ($this->originLanguagePath . 'common.php' === $file && $key === 'VIEW_ONLINE_TIME') - ) - { - $level = Output::WARNING; - } - $this->output->addMessage($level, sprintf('Should have %1$s integer arguments, but has %2$s', $against_integers, $validate_integers), $file, $key); + $this->output->addMessage(Output::FATAL, sprintf('Should have %1$s integer arguments, but has %2$s', $against_integers, $validate_integers), $file, $key); } else if ($is_plural) { diff --git a/src/Phpbb/TranslationValidator/Validator/ValidatorRunner.php b/src/Phpbb/TranslationValidator/Validator/ValidatorRunner.php index df4dfd3..7f71be0 100644 --- a/src/Phpbb/TranslationValidator/Validator/ValidatorRunner.php +++ b/src/Phpbb/TranslationValidator/Validator/ValidatorRunner.php @@ -8,6 +8,7 @@ */ namespace Phpbb\TranslationValidator\Validator; +use battye\array_parser\parser; use Symfony\Component\Console\Input\InputInterface; use Phpbb\TranslationValidator\Output\Output; use Phpbb\TranslationValidator\Output\OutputInterface; @@ -31,6 +32,8 @@ class ValidatorRunner /** @var bool */ protected $debug; + /** @var bool */ + protected $safeMode; /** @var int */ protected $numFatal = 0; @@ -94,10 +97,22 @@ public function setSource($sourceIso, $sourcePath, $sourceLanguagePath) return $this; } + /** + * Set safe mode (if true, don't include any PHP files) + * + * @param $safeMode + * @return $this + */ + public function setSafeMode($safeMode) + { + $this->safeMode = $safeMode; + return $this; + } + /** * Set phpBB Version * - * @param string $phpbbVersion The phpBB Version to validate against (3.0|3.1|3.2) + * @param string $phpbbVersion The phpBB Version to validate against * @return $this */ public function setPhpbbVersion($phpbbVersion) @@ -129,6 +144,7 @@ public function runValidators() ->setOrigin($this->originIso, $this->originPath, $this->originLanguagePath) ->setPhpbbVersion($this->phpbbVersion) ->setDebug($this->debug) + ->setSafeMode($this->safeMode) ->validate(); if (empty($validateFiles)) @@ -153,7 +169,8 @@ public function runValidators() ->setOrigin($this->originIso, $this->originPath, $this->originLanguagePath) ->setPhpbbVersion($this->phpbbVersion) ->setPluralRule($pluralRule) - ->setDebug($this->debug); + ->setDebug($this->debug) + ->setSafeMode($this->safeMode); foreach ($validateFiles as $sourceFile => $originFile) { @@ -215,9 +232,19 @@ protected function printErrorLevel(Output $output) */ protected function guessPluralRule() { - if (file_exists($this->originPath . '/' . $this->originLanguagePath . 'common.php')) + $filePath = $this->originPath . '/' . $this->originLanguagePath . 'common.php'; + + if (file_exists($filePath)) { - include($this->originPath . '/' . $this->originLanguagePath . 'common.php'); + if ($this->safeMode) + { + $lang = self::langParser($filePath); + } + + else + { + include($filePath); + } if (!isset($lang['PLURAL_RULE'])) { @@ -231,4 +258,35 @@ protected function guessPluralRule() return isset($lang['PLURAL_RULE']) ? $lang['PLURAL_RULE'] : 1; } + + /** + * Parse language files for lang arrays + * @param $file + * @return array|null + */ + public static function arrayParser($file) + { + // Parse language files that use new or old array formats + $regex = '/\$lang\s*=\s*array_merge\s*\(\$lang,\s*(?|array\s*\((.*?)\)|\[(.*?)\])\);/s'; + return parser::parse_regex($regex, $file); + } + + /** + * Merge parsed language entries into a single array + * @param $filePath + * @param string $relativePath + * @return array + */ + public static function langParser($filePath, $relativePath = '') + { + $lang = []; + $parsed = self::arrayParser($relativePath . $filePath); + + foreach ($parsed as $parse) + { + $lang = array_merge($lang, $parse); + } + + return $lang; + } } diff --git a/tests/FileListValidator/FileListTest.php b/tests/FileListValidator/FileListTest.php new file mode 100644 index 0000000..c4e07a5 --- /dev/null +++ b/tests/FileListValidator/FileListTest.php @@ -0,0 +1,66 @@ +validator = new \Phpbb\TranslationValidator\Validator\FileListValidator($this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock(), $this->output); + } + + public function validateFileListData() + { + return array( + array( + '3.2', + array( + Output::FATAL . '-Missing required file-missing.php-', + Output::FATAL . '-Missing required file-missing.txt-', + Output::FATAL . '-Missing required file-subdir/missing.php-', + Output::FATAL . '-Missing required file-language/origin/LICENSE-', + Output::FATAL . '-Found additional file-additional.php-', + Output::FATAL . '-Found additional file-subdir/additional.php-', + Output::FATAL . '-Found additional file-additional.txt-', + Output::FATAL . '-Found additional file-language/origin/AUTHORS-', + Output::FATAL . '-Found additional file-language/origin/CHANGELOG-', + Output::FATAL . '-Found additional file-language/origin/README-', + Output::FATAL . '-Found additional file-language/origin/VERSION-', + + Output::NOTICE . '-Found additional file-language/origin/AUTHORS.md-', + Output::NOTICE . '-Found additional file-language/origin/CHANGELOG.md-', + Output::NOTICE . '-Found additional file-language/origin/README.md-', + Output::NOTICE . '-Found additional file-language/origin/VERSION.md-', + Output::NOTICE . '-Found additional file-language/origin/index.htm-', + ), + ), + ); + } + + /** + * @dataProvider validateFileListData + */ + public function testValidateFileList($phpbbVersion, $expected) + { + $this->validator->setOrigin('origin', dirname(__FILE__) . '/fixtures/'. $phpbbVersion . '/origin', 'language/origin/') + ->setSource('source', dirname(__FILE__) . '/fixtures/'. $phpbbVersion . '/source', 'language/source/'); + + $this->validator + ->setPhpbbVersion($phpbbVersion) + ->validate(); + $this->assertOutputMessages($expected); + } +} diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.0/origin/additional.php b/tests/FileListValidator/fixtures/3.2/origin/additional.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.0/origin/additional.php rename to tests/FileListValidator/fixtures/3.2/origin/additional.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.0/origin/additional.txt b/tests/FileListValidator/fixtures/3.2/origin/additional.txt similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.0/origin/additional.txt rename to tests/FileListValidator/fixtures/3.2/origin/additional.txt diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.0/origin/file.php b/tests/FileListValidator/fixtures/3.2/origin/file.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.0/origin/file.php rename to tests/FileListValidator/fixtures/3.2/origin/file.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.0/origin/language/origin/AUTHORS b/tests/FileListValidator/fixtures/3.2/origin/language/origin/AUTHORS similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.0/origin/language/origin/AUTHORS rename to tests/FileListValidator/fixtures/3.2/origin/language/origin/AUTHORS diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.0/origin/language/origin/AUTHORS.md b/tests/FileListValidator/fixtures/3.2/origin/language/origin/AUTHORS.md similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.0/origin/language/origin/AUTHORS.md rename to tests/FileListValidator/fixtures/3.2/origin/language/origin/AUTHORS.md diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.0/origin/language/origin/CHANGELOG b/tests/FileListValidator/fixtures/3.2/origin/language/origin/CHANGELOG similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.0/origin/language/origin/CHANGELOG rename to tests/FileListValidator/fixtures/3.2/origin/language/origin/CHANGELOG diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.0/origin/language/origin/CHANGELOG.md b/tests/FileListValidator/fixtures/3.2/origin/language/origin/CHANGELOG.md similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.0/origin/language/origin/CHANGELOG.md rename to tests/FileListValidator/fixtures/3.2/origin/language/origin/CHANGELOG.md diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.0/origin/language/origin/README b/tests/FileListValidator/fixtures/3.2/origin/language/origin/README similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.0/origin/language/origin/README rename to tests/FileListValidator/fixtures/3.2/origin/language/origin/README diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.0/origin/language/origin/README.md b/tests/FileListValidator/fixtures/3.2/origin/language/origin/README.md similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.0/origin/language/origin/README.md rename to tests/FileListValidator/fixtures/3.2/origin/language/origin/README.md diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.0/origin/language/origin/VERSION b/tests/FileListValidator/fixtures/3.2/origin/language/origin/VERSION similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.0/origin/language/origin/VERSION rename to tests/FileListValidator/fixtures/3.2/origin/language/origin/VERSION diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.0/origin/language/origin/VERSION.md b/tests/FileListValidator/fixtures/3.2/origin/language/origin/VERSION.md similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.0/origin/language/origin/VERSION.md rename to tests/FileListValidator/fixtures/3.2/origin/language/origin/VERSION.md diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.1/origin/language/origin/common.php b/tests/FileListValidator/fixtures/3.2/origin/language/origin/common.php similarity index 94% rename from src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.1/origin/language/origin/common.php rename to tests/FileListValidator/fixtures/3.2/origin/language/origin/common.php index dbbdd34..9175202 100644 --- a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.1/origin/language/origin/common.php +++ b/tests/FileListValidator/fixtures/3.2/origin/language/origin/common.php @@ -11,14 +11,6 @@ * */ -/** -* DO NOT CHANGE -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - if (empty($lang) || !is_array($lang)) { $lang = array(); diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.0/origin/language/origin/index.htm b/tests/FileListValidator/fixtures/3.2/origin/language/origin/index.htm similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.0/origin/language/origin/index.htm rename to tests/FileListValidator/fixtures/3.2/origin/language/origin/index.htm diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.0/origin/subdir/additional.php b/tests/FileListValidator/fixtures/3.2/origin/subdir/additional.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.0/origin/subdir/additional.php rename to tests/FileListValidator/fixtures/3.2/origin/subdir/additional.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.0/origin/subdir/file.php b/tests/FileListValidator/fixtures/3.2/origin/subdir/file.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.0/origin/subdir/file.php rename to tests/FileListValidator/fixtures/3.2/origin/subdir/file.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.0/source/file.php b/tests/FileListValidator/fixtures/3.2/source/file.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.0/source/file.php rename to tests/FileListValidator/fixtures/3.2/source/file.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.2/origin/language/origin/common.php b/tests/FileListValidator/fixtures/3.2/source/language/source/common.php similarity index 94% rename from src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.2/origin/language/origin/common.php rename to tests/FileListValidator/fixtures/3.2/source/language/source/common.php index dbbdd34..9175202 100644 --- a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.2/origin/language/origin/common.php +++ b/tests/FileListValidator/fixtures/3.2/source/language/source/common.php @@ -11,14 +11,6 @@ * */ -/** -* DO NOT CHANGE -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - if (empty($lang) || !is_array($lang)) { $lang = array(); diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.0/source/missing.php b/tests/FileListValidator/fixtures/3.2/source/missing.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.0/source/missing.php rename to tests/FileListValidator/fixtures/3.2/source/missing.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.0/source/missing.txt b/tests/FileListValidator/fixtures/3.2/source/missing.txt similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.0/source/missing.txt rename to tests/FileListValidator/fixtures/3.2/source/missing.txt diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.0/source/subdir/file.php b/tests/FileListValidator/fixtures/3.2/source/subdir/file.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.0/source/subdir/file.php rename to tests/FileListValidator/fixtures/3.2/source/subdir/file.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.0/source/subdir/missing.php b/tests/FileListValidator/fixtures/3.2/source/subdir/missing.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.0/source/subdir/missing.php rename to tests/FileListValidator/fixtures/3.2/source/subdir/missing.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.0/origin/language/origin/common.php b/tests/FileListValidator/fixtures/origin/language/origin/common.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileListValidator/fixtures/3.0/origin/language/origin/common.php rename to tests/FileListValidator/fixtures/origin/language/origin/common.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/TestBase.php b/tests/FileValidator/TestBase.php similarity index 85% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/TestBase.php rename to tests/FileValidator/TestBase.php index c8c5d72..999fb38 100644 --- a/src/Phpbb/TranslationValidator/Tests/FileValidator/TestBase.php +++ b/tests/FileValidator/TestBase.php @@ -23,9 +23,9 @@ public function setUp() define('IN_PHPBB', true); } - $this->validator = new \Phpbb\TranslationValidator\Validator\FileValidator($this->getMock('Symfony\Component\Console\Input\InputInterface'), $this->output); + $this->validator = new \Phpbb\TranslationValidator\Validator\FileValidator($this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock(), $this->output); $this->validator->setOrigin('origin', dirname(__FILE__) . '/fixtures/origin', 'language/origin/') ->setSource('source', dirname(__FILE__) . '/fixtures/source', 'language/source/') - ->setPhpbbVersion('3.0'); + ->setPhpbbVersion('3.2'); } } diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/ValidateCSSFileTest.php b/tests/FileValidator/ValidateCSSFileTest.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/ValidateCSSFileTest.php rename to tests/FileValidator/ValidateCSSFileTest.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/ValidateDefinedInPhpbbTest.php b/tests/FileValidator/ValidateDefinedInPhpbbTest.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/ValidateDefinedInPhpbbTest.php rename to tests/FileValidator/ValidateDefinedInPhpbbTest.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/ValidateEmailTest.php b/tests/FileValidator/ValidateEmailTest.php similarity index 61% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/ValidateEmailTest.php rename to tests/FileValidator/ValidateEmailTest.php index dadf3a7..8717985 100644 --- a/src/Phpbb/TranslationValidator/Tests/FileValidator/ValidateEmailTest.php +++ b/tests/FileValidator/ValidateEmailTest.php @@ -22,7 +22,7 @@ public function validateEmailData() Output::ERROR . '-Is not using variables: {U_ACTIVATE}-email/email.txt-', Output::FATAL . '-Using additional HTML: <a href="localhost">-email/email.txt-', Output::FATAL . '-Using additional HTML: </a>-email/email.txt-', - Output::NOTICE . '-Missing new line at the end of the file-email/email.txt-', + Output::FATAL . '-Missing new line at the end of the file-email/email.txt-', )), array('email/invalid_sig.txt', array( Output::FATAL . '-File must be encoded using UTF8 without BOM-email/invalid_sig.txt-', @@ -41,29 +41,4 @@ public function testValidateEmail($file, $expected) $this->validator->validateEmail($file, $file); $this->assertOutputMessages($expected); } - - public function validateEmailAscraeusData() - { - return array( - array('email/email.txt', array( - Output::FATAL . '-Must have a "Subject: "-line-email/email.txt-', - Output::FATAL . '-Must have the signature appended-email/email.txt-', - Output::FATAL . '-Is using additional variables: {TEMPLATE_VAR_DOES_NOT_EXIST}, {U_ACTIVATE*NOT_USING_NORMAL_VAR*}-email/email.txt-', - Output::ERROR . '-Is not using variables: {U_ACTIVATE}-email/email.txt-', - Output::FATAL . '-Using additional HTML: <a href="localhost">-email/email.txt-', - Output::FATAL . '-Using additional HTML: </a>-email/email.txt-', - Output::FATAL . '-Missing new line at the end of the file-email/email.txt-', - )), - ); - } - - /** - * @dataProvider validateEmailAscraeusData - */ - public function testValidateEmailAscraeus($file, $expected) - { - $this->validator->setPhpbbVersion('3.1'); - $this->validator->validateEmail($file, $file); - $this->assertOutputMessages($expected); - } } diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/ValidateHelpTest.php b/tests/FileValidator/ValidateHelpTest.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/ValidateHelpTest.php rename to tests/FileValidator/ValidateHelpTest.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/ValidateIndexTest.php b/tests/FileValidator/ValidateIndexTest.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/ValidateIndexTest.php rename to tests/FileValidator/ValidateIndexTest.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/ValidateIsoTest.php b/tests/FileValidator/ValidateIsoTest.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/ValidateIsoTest.php rename to tests/FileValidator/ValidateIsoTest.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/ValidateLangTest.php b/tests/FileValidator/ValidateLangTest.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/ValidateLangTest.php rename to tests/FileValidator/ValidateLangTest.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/ValidateLicenseTest.php b/tests/FileValidator/ValidateLicenseTest.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/ValidateLicenseTest.php rename to tests/FileValidator/ValidateLicenseTest.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/ValidateLineEndingsTest.php b/tests/FileValidator/ValidateLineEndingsTest.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/ValidateLineEndingsTest.php rename to tests/FileValidator/ValidateLineEndingsTest.php diff --git a/tests/FileValidator/ValidateNoPhpClosingTagTest.php b/tests/FileValidator/ValidateNoPhpClosingTagTest.php new file mode 100644 index 0000000..60f73d7 --- /dev/null +++ b/tests/FileValidator/ValidateNoPhpClosingTagTest.php @@ -0,0 +1,31 @@ +validator->setPhpbbVersion($phpbbVersion); + $this->validator->validateNoPhpClosingTag($file); + $this->assertOutputMessages($expected); + } +} diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/ValidateSearchTest.php b/tests/FileValidator/ValidateSearchTest.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/ValidateSearchTest.php rename to tests/FileValidator/ValidateSearchTest.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/ValidateUtf8withoutbomTest.php b/tests/FileValidator/ValidateUtf8withoutbomTest.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/ValidateUtf8withoutbomTest.php rename to tests/FileValidator/ValidateUtf8withoutbomTest.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/css/invalid.css b/tests/FileValidator/fixtures/origin/css/invalid.css similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/css/invalid.css rename to tests/FileValidator/fixtures/origin/css/invalid.css diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/css/invalid2.css b/tests/FileValidator/fixtures/origin/css/invalid2.css similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/css/invalid2.css rename to tests/FileValidator/fixtures/origin/css/invalid2.css diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/css/valid.css b/tests/FileValidator/fixtures/origin/css/valid.css similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/css/valid.css rename to tests/FileValidator/fixtures/origin/css/valid.css diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/email/crlf_sig.txt b/tests/FileValidator/fixtures/origin/email/crlf_sig.txt similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/email/crlf_sig.txt rename to tests/FileValidator/fixtures/origin/email/crlf_sig.txt diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/email/email.txt b/tests/FileValidator/fixtures/origin/email/email.txt similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/email/email.txt rename to tests/FileValidator/fixtures/origin/email/email.txt diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/email/invalid_sig.txt b/tests/FileValidator/fixtures/origin/email/invalid_sig.txt similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/email/invalid_sig.txt rename to tests/FileValidator/fixtures/origin/email/invalid_sig.txt diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/help/additional_variable.php b/tests/FileValidator/fixtures/origin/help/additional_variable.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/help/additional_variable.php rename to tests/FileValidator/fixtures/origin/help/additional_variable.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/help/invalid_help.php b/tests/FileValidator/fixtures/origin/help/invalid_help.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/help/invalid_help.php rename to tests/FileValidator/fixtures/origin/help/invalid_help.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/help/invalid_help_var.php b/tests/FileValidator/fixtures/origin/help/invalid_help_var.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/help/invalid_help_var.php rename to tests/FileValidator/fixtures/origin/help/invalid_help_var.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/help/no_help.php b/tests/FileValidator/fixtures/origin/help/no_help.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/help/no_help.php rename to tests/FileValidator/fixtures/origin/help/no_help.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/help/valid.php b/tests/FileValidator/fixtures/origin/help/valid.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/help/valid.php rename to tests/FileValidator/fixtures/origin/help/valid.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/in_phpbb/invalid.php b/tests/FileValidator/fixtures/origin/in_phpbb/invalid.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/in_phpbb/invalid.php rename to tests/FileValidator/fixtures/origin/in_phpbb/invalid.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/in_phpbb/valid.php b/tests/FileValidator/fixtures/origin/in_phpbb/valid.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/in_phpbb/valid.php rename to tests/FileValidator/fixtures/origin/in_phpbb/valid.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/index/default_index.htm b/tests/FileValidator/fixtures/origin/index/default_index.htm similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/index/default_index.htm rename to tests/FileValidator/fixtures/origin/index/default_index.htm diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/index/empty_index.htm b/tests/FileValidator/fixtures/origin/index/empty_index.htm similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/index/empty_index.htm rename to tests/FileValidator/fixtures/origin/index/empty_index.htm diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/index/invalid_index.htm b/tests/FileValidator/fixtures/origin/index/invalid_index.htm similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/index/invalid_index.htm rename to tests/FileValidator/fixtures/origin/index/invalid_index.htm diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/iso/fewer_iso.txt b/tests/FileValidator/fixtures/origin/iso/fewer_iso.txt similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/iso/fewer_iso.txt rename to tests/FileValidator/fixtures/origin/iso/fewer_iso.txt diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/iso/more_iso.txt b/tests/FileValidator/fixtures/origin/iso/more_iso.txt similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/iso/more_iso.txt rename to tests/FileValidator/fixtures/origin/iso/more_iso.txt diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/iso/valid_iso.txt b/tests/FileValidator/fixtures/origin/iso/valid_iso.txt similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/iso/valid_iso.txt rename to tests/FileValidator/fixtures/origin/iso/valid_iso.txt diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/language/lang.php b/tests/FileValidator/fixtures/origin/language/lang.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/language/lang.php rename to tests/FileValidator/fixtures/origin/language/lang.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/language/lang2.php b/tests/FileValidator/fixtures/origin/language/lang2.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/language/lang2.php rename to tests/FileValidator/fixtures/origin/language/lang2.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/language/lang_output.php b/tests/FileValidator/fixtures/origin/language/lang_output.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/language/lang_output.php rename to tests/FileValidator/fixtures/origin/language/lang_output.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/license/invalid1.txt b/tests/FileValidator/fixtures/origin/license/invalid1.txt similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/license/invalid1.txt rename to tests/FileValidator/fixtures/origin/license/invalid1.txt diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/license/valid_gnu_gplv2.txt b/tests/FileValidator/fixtures/origin/license/valid_gnu_gplv2.txt similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/license/valid_gnu_gplv2.txt rename to tests/FileValidator/fixtures/origin/license/valid_gnu_gplv2.txt diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/line_endings/invalid.php b/tests/FileValidator/fixtures/origin/line_endings/invalid.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/line_endings/invalid.php rename to tests/FileValidator/fixtures/origin/line_endings/invalid.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/line_endings/valid.php b/tests/FileValidator/fixtures/origin/line_endings/valid.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/line_endings/valid.php rename to tests/FileValidator/fixtures/origin/line_endings/valid.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/nophpclosingtag/shortarraysyntax.php b/tests/FileValidator/fixtures/origin/nophpclosingtag/shortarraysyntax.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/nophpclosingtag/shortarraysyntax.php rename to tests/FileValidator/fixtures/origin/nophpclosingtag/shortarraysyntax.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/nophpclosingtag/withcrlf.php b/tests/FileValidator/fixtures/origin/nophpclosingtag/withcrlf.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/nophpclosingtag/withcrlf.php rename to tests/FileValidator/fixtures/origin/nophpclosingtag/withcrlf.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/nophpclosingtag/withoutnewline.php b/tests/FileValidator/fixtures/origin/nophpclosingtag/withoutnewline.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/nophpclosingtag/withoutnewline.php rename to tests/FileValidator/fixtures/origin/nophpclosingtag/withoutnewline.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/nophpclosingtag/withouttag.php b/tests/FileValidator/fixtures/origin/nophpclosingtag/withouttag.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/nophpclosingtag/withouttag.php rename to tests/FileValidator/fixtures/origin/nophpclosingtag/withouttag.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/nophpclosingtag/withtag.php b/tests/FileValidator/fixtures/origin/nophpclosingtag/withtag.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/nophpclosingtag/withtag.php rename to tests/FileValidator/fixtures/origin/nophpclosingtag/withtag.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/search_ignore_words/additional_variable.php b/tests/FileValidator/fixtures/origin/search_ignore_words/additional_variable.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/search_ignore_words/additional_variable.php rename to tests/FileValidator/fixtures/origin/search_ignore_words/additional_variable.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/search_ignore_words/invalid_word.php b/tests/FileValidator/fixtures/origin/search_ignore_words/invalid_word.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/search_ignore_words/invalid_word.php rename to tests/FileValidator/fixtures/origin/search_ignore_words/invalid_word.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/search_ignore_words/invalid_words.php b/tests/FileValidator/fixtures/origin/search_ignore_words/invalid_words.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/search_ignore_words/invalid_words.php rename to tests/FileValidator/fixtures/origin/search_ignore_words/invalid_words.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/search_ignore_words/no_words.php b/tests/FileValidator/fixtures/origin/search_ignore_words/no_words.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/search_ignore_words/no_words.php rename to tests/FileValidator/fixtures/origin/search_ignore_words/no_words.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/search_ignore_words/valid.php b/tests/FileValidator/fixtures/origin/search_ignore_words/valid.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/search_ignore_words/valid.php rename to tests/FileValidator/fixtures/origin/search_ignore_words/valid.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/search_synonyms/additional_variable.php b/tests/FileValidator/fixtures/origin/search_synonyms/additional_variable.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/search_synonyms/additional_variable.php rename to tests/FileValidator/fixtures/origin/search_synonyms/additional_variable.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/search_synonyms/invalid_synonym.php b/tests/FileValidator/fixtures/origin/search_synonyms/invalid_synonym.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/search_synonyms/invalid_synonym.php rename to tests/FileValidator/fixtures/origin/search_synonyms/invalid_synonym.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/search_synonyms/invalid_synonyms.php b/tests/FileValidator/fixtures/origin/search_synonyms/invalid_synonyms.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/search_synonyms/invalid_synonyms.php rename to tests/FileValidator/fixtures/origin/search_synonyms/invalid_synonyms.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/search_synonyms/no_synonyms.php b/tests/FileValidator/fixtures/origin/search_synonyms/no_synonyms.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/search_synonyms/no_synonyms.php rename to tests/FileValidator/fixtures/origin/search_synonyms/no_synonyms.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/search_synonyms/valid.php b/tests/FileValidator/fixtures/origin/search_synonyms/valid.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/search_synonyms/valid.php rename to tests/FileValidator/fixtures/origin/search_synonyms/valid.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/utf8withoutbom/with.php b/tests/FileValidator/fixtures/origin/utf8withoutbom/with.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/utf8withoutbom/with.php rename to tests/FileValidator/fixtures/origin/utf8withoutbom/with.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/utf8withoutbom/without.php b/tests/FileValidator/fixtures/origin/utf8withoutbom/without.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/origin/utf8withoutbom/without.php rename to tests/FileValidator/fixtures/origin/utf8withoutbom/without.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/source/css/invalid.css b/tests/FileValidator/fixtures/source/css/invalid.css similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/source/css/invalid.css rename to tests/FileValidator/fixtures/source/css/invalid.css diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/source/css/invalid2.css b/tests/FileValidator/fixtures/source/css/invalid2.css similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/source/css/invalid2.css rename to tests/FileValidator/fixtures/source/css/invalid2.css diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/source/css/valid.css b/tests/FileValidator/fixtures/source/css/valid.css similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/source/css/valid.css rename to tests/FileValidator/fixtures/source/css/valid.css diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/source/email/crlf_sig.txt b/tests/FileValidator/fixtures/source/email/crlf_sig.txt similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/source/email/crlf_sig.txt rename to tests/FileValidator/fixtures/source/email/crlf_sig.txt diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/source/email/email.txt b/tests/FileValidator/fixtures/source/email/email.txt similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/source/email/email.txt rename to tests/FileValidator/fixtures/source/email/email.txt diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/source/email/invalid_sig.txt b/tests/FileValidator/fixtures/source/email/invalid_sig.txt similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/source/email/invalid_sig.txt rename to tests/FileValidator/fixtures/source/email/invalid_sig.txt diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/source/help/invalid_help.php b/tests/FileValidator/fixtures/source/help/invalid_help.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/source/help/invalid_help.php rename to tests/FileValidator/fixtures/source/help/invalid_help.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/source/help/valid.php b/tests/FileValidator/fixtures/source/help/valid.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/source/help/valid.php rename to tests/FileValidator/fixtures/source/help/valid.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/source/keep.txt b/tests/FileValidator/fixtures/source/keep.txt similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/source/keep.txt rename to tests/FileValidator/fixtures/source/keep.txt diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/source/language/lang.php b/tests/FileValidator/fixtures/source/language/lang.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/source/language/lang.php rename to tests/FileValidator/fixtures/source/language/lang.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/source/language/lang2.php b/tests/FileValidator/fixtures/source/language/lang2.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/source/language/lang2.php rename to tests/FileValidator/fixtures/source/language/lang2.php diff --git a/src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/source/language/lang_output.php b/tests/FileValidator/fixtures/source/language/lang_output.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/FileValidator/fixtures/source/language/lang_output.php rename to tests/FileValidator/fixtures/source/language/lang_output.php diff --git a/src/Phpbb/TranslationValidator/Tests/LangKeyValidator/TestBase.php b/tests/LangKeyValidator/TestBase.php similarity index 83% rename from src/Phpbb/TranslationValidator/Tests/LangKeyValidator/TestBase.php rename to tests/LangKeyValidator/TestBase.php index 3001ea0..2f0bd85 100644 --- a/src/Phpbb/TranslationValidator/Tests/LangKeyValidator/TestBase.php +++ b/tests/LangKeyValidator/TestBase.php @@ -17,10 +17,10 @@ public function setUp() { parent::setUp(); - $this->validator = new \Phpbb\TranslationValidator\Validator\LangKeyValidator($this->getMock('Symfony\Component\Console\Input\InputInterface'), $this->output); + $this->validator = new \Phpbb\TranslationValidator\Validator\LangKeyValidator($this->getMockBuilder('Symfony\Component\Console\Input\InputInterface')->getMock(), $this->output); $this->validator->setOrigin('origin', dirname(__FILE__) . '/fixtures/origin', 'language/origin/') ->setSource('source', dirname(__FILE__) . '/fixtures/source', 'language/source/') - ->setPhpbbVersion('3.0') + ->setPhpbbVersion('3.2') ->setPluralRule(1); } } diff --git a/src/Phpbb/TranslationValidator/Tests/LangKeyValidator/ValidateAclTest.php b/tests/LangKeyValidator/ValidateAclTest.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/LangKeyValidator/ValidateAclTest.php rename to tests/LangKeyValidator/ValidateAclTest.php diff --git a/src/Phpbb/TranslationValidator/Tests/LangKeyValidator/ValidateArrayKeyTest.php b/tests/LangKeyValidator/ValidateArrayKeyTest.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/LangKeyValidator/ValidateArrayKeyTest.php rename to tests/LangKeyValidator/ValidateArrayKeyTest.php diff --git a/src/Phpbb/TranslationValidator/Tests/LangKeyValidator/ValidateDateformatsTest.php b/tests/LangKeyValidator/ValidateDateformatsTest.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/LangKeyValidator/ValidateDateformatsTest.php rename to tests/LangKeyValidator/ValidateDateformatsTest.php diff --git a/src/Phpbb/TranslationValidator/Tests/LangKeyValidator/ValidateHtmlTest.php b/tests/LangKeyValidator/ValidateHtmlTest.php similarity index 95% rename from src/Phpbb/TranslationValidator/Tests/LangKeyValidator/ValidateHtmlTest.php rename to tests/LangKeyValidator/ValidateHtmlTest.php index 688c58b..39cd79d 100644 --- a/src/Phpbb/TranslationValidator/Tests/LangKeyValidator/ValidateHtmlTest.php +++ b/tests/LangKeyValidator/ValidateHtmlTest.php @@ -63,7 +63,7 @@ public function validateHtmlData() 'Additional link in help page', 'foobar', 'bar foo', array( - Output::WARNING . '-String is using additional html: -language/origin/help_faq.php-Additional link in help page', + Output::ERROR . '-String is using additional html: -language/origin/help_faq.php-Additional link in help page', ), 'language/origin/help_faq.php', ), diff --git a/src/Phpbb/TranslationValidator/Tests/LangKeyValidator/ValidatePluralKeysTest.php b/tests/LangKeyValidator/ValidatePluralKeysTest.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/LangKeyValidator/ValidatePluralKeysTest.php rename to tests/LangKeyValidator/ValidatePluralKeysTest.php diff --git a/src/Phpbb/TranslationValidator/Tests/LangKeyValidator/ValidateStringTest.php b/tests/LangKeyValidator/ValidateStringTest.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/LangKeyValidator/ValidateStringTest.php rename to tests/LangKeyValidator/ValidateStringTest.php diff --git a/src/Phpbb/TranslationValidator/Tests/LangKeyValidator/ValidateTest.php b/tests/LangKeyValidator/ValidateTest.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/LangKeyValidator/ValidateTest.php rename to tests/LangKeyValidator/ValidateTest.php diff --git a/src/Phpbb/TranslationValidator/Tests/Mock/Output.php b/tests/Mock/Output.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/Mock/Output.php rename to tests/Mock/Output.php diff --git a/src/Phpbb/TranslationValidator/Tests/TestBase.php b/tests/TestBase.php similarity index 100% rename from src/Phpbb/TranslationValidator/Tests/TestBase.php rename to tests/TestBase.php diff --git a/src/Phpbb/TranslationValidator/PhpbbTranslationValidator.php b/translation.php similarity index 62% rename from src/Phpbb/TranslationValidator/PhpbbTranslationValidator.php rename to translation.php index e182b65..f6ec6fc 100644 --- a/src/Phpbb/TranslationValidator/PhpbbTranslationValidator.php +++ b/translation.php @@ -7,9 +7,11 @@ * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ -namespace Phpbb\TranslationValidator; -require 'vendor/autoload.php'; +require __DIR__ . '/vendor/autoload.php'; +use Phpbb\TranslationValidator\Cli; + +// Run the command line script for the Translation Validator $app = new Cli(); $app->run();