From 163cf7ffd00d5ce2ec8cc9c3852c45b7591d1add Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20=C5=A0t=C3=ADpek?= Date: Sun, 27 Mar 2016 07:54:14 +0200 Subject: [PATCH] - Updated Symfony constraint to <2.7 - Added Symfony 2.6 to travis configuration - Support for IsFalse/IsTrue/IsNull - Testcase of multiplechoice less strict - valid filename of generated screenshot on Windows --- .travis.yml | 3 ++- Resources/public/js/constraints/False.js | 13 +---------- Resources/public/js/constraints/IsFalse.js | 18 +++++++++++++++ Resources/public/js/constraints/IsNull.js | 18 +++++++++++++++ Resources/public/js/constraints/IsTrue.js | 23 +++++++++++++++++++ Resources/public/js/constraints/Null.js | 13 +---------- Resources/public/js/constraints/True.js | 18 +-------------- Tests/BaseMinkTestCase.php | 9 +++----- .../Entity/BasicConstraintsEntity.php | 2 +- .../views/FunctionalTests/index.html.twig | 2 +- .../BasicConstraintsEntity_sf_2_3.php | 2 +- composer.json | 10 ++++---- 12 files changed, 75 insertions(+), 56 deletions(-) create mode 100644 Resources/public/js/constraints/IsFalse.js create mode 100644 Resources/public/js/constraints/IsNull.js create mode 100644 Resources/public/js/constraints/IsTrue.js diff --git a/.travis.yml b/.travis.yml index da40526..ed920c3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,8 @@ php: [5.3,5.4,5.5,5.6] env: - SF_VERSION='~2.3.0,>=2.3.19' - SF_VERSION='~2.4.0,>=2.4.9' - - SF_VERSION='~2.5.0,>=2.5.3,<=2.5.4' + - SF_VERSION='~2.5.0,>=2.5.3' + - SF_VERSION='~2.6.0,>=2.6.2' before_script: - export WEB_FIXTURES_HOST=http://localhost/index.php diff --git a/Resources/public/js/constraints/False.js b/Resources/public/js/constraints/False.js index cd54e9a..ad84b61 100644 --- a/Resources/public/js/constraints/False.js +++ b/Resources/public/js/constraints/False.js @@ -4,15 +4,4 @@ * @constructor * @author dev.ymalcev@gmail.com */ -function SymfonyComponentValidatorConstraintsFalse() { - this.message = ''; - - this.validate = function (value) { - var errors = []; - if ('' !== value && false !== value) { - errors.push(this.message.replace('{{ value }}', FpJsBaseConstraint.formatValue(value))); - } - - return errors; - } -} +var SymfonyComponentValidatorConstraintsFalse = SymfonyComponentValidatorConstraintsIsFalse; diff --git a/Resources/public/js/constraints/IsFalse.js b/Resources/public/js/constraints/IsFalse.js new file mode 100644 index 0000000..512f493 --- /dev/null +++ b/Resources/public/js/constraints/IsFalse.js @@ -0,0 +1,18 @@ +//noinspection JSUnusedGlobalSymbols +/** + * Checks if value is (bool) false + * @constructor + * @author dev.ymalcev@gmail.com + */ +function SymfonyComponentValidatorConstraintsIsFalse() { + this.message = ''; + + this.validate = function (value) { + var errors = []; + if ('' !== value && false !== value) { + errors.push(this.message.replace('{{ value }}', FpJsBaseConstraint.formatValue(value))); + } + + return errors; + } +} diff --git a/Resources/public/js/constraints/IsNull.js b/Resources/public/js/constraints/IsNull.js new file mode 100644 index 0000000..c630ecb --- /dev/null +++ b/Resources/public/js/constraints/IsNull.js @@ -0,0 +1,18 @@ +//noinspection JSUnusedGlobalSymbols +/** + * Checks if value is null + * @constructor + * @author dev.ymalcev@gmail.com + */ +function SymfonyComponentValidatorConstraintsIsNull() { + this.message = ''; + + this.validate = function(value) { + var errors = []; + if (null !== value) { + errors.push(this.message.replace('{{ value }}', FpJsBaseConstraint.formatValue(value))); + } + + return errors; + } +} diff --git a/Resources/public/js/constraints/IsTrue.js b/Resources/public/js/constraints/IsTrue.js new file mode 100644 index 0000000..322db60 --- /dev/null +++ b/Resources/public/js/constraints/IsTrue.js @@ -0,0 +1,23 @@ +//noinspection JSUnusedGlobalSymbols +/** + * Checks if value is (bool) true + * @constructor + * @author dev.ymalcev@gmail.com + */ +function SymfonyComponentValidatorConstraintsIsTrue() { + this.message = ''; + + this.validate = function(value) { + if ('' === value) { + return []; + } + + var errors = []; + if (true !== value) { + errors.push(this.message.replace('{{ value }}', FpJsBaseConstraint.formatValue(value))); + } + + return errors; + } +} + diff --git a/Resources/public/js/constraints/Null.js b/Resources/public/js/constraints/Null.js index b1113be..8e3bce0 100644 --- a/Resources/public/js/constraints/Null.js +++ b/Resources/public/js/constraints/Null.js @@ -4,15 +4,4 @@ * @constructor * @author dev.ymalcev@gmail.com */ -function SymfonyComponentValidatorConstraintsNull() { - this.message = ''; - - this.validate = function(value) { - var errors = []; - if (null !== value) { - errors.push(this.message.replace('{{ value }}', FpJsBaseConstraint.formatValue(value))); - } - - return errors; - } -} +var SymfonyComponentValidatorConstraintsNull = SymfonyComponentValidatorConstraintsIsNull; diff --git a/Resources/public/js/constraints/True.js b/Resources/public/js/constraints/True.js index 2441ce8..dd8ad53 100644 --- a/Resources/public/js/constraints/True.js +++ b/Resources/public/js/constraints/True.js @@ -4,20 +4,4 @@ * @constructor * @author dev.ymalcev@gmail.com */ -function SymfonyComponentValidatorConstraintsTrue() { - this.message = ''; - - this.validate = function(value) { - if ('' === value) { - return []; - } - - var errors = []; - if (true !== value) { - errors.push(this.message.replace('{{ value }}', FpJsBaseConstraint.formatValue(value))); - } - - return errors; - } -} - +var SymfonyComponentValidatorConstraintsTrue = SymfonyComponentValidatorConstraintsIsTrue; diff --git a/Tests/BaseMinkTestCase.php b/Tests/BaseMinkTestCase.php index a0e7345..b3ffe92 100644 --- a/Tests/BaseMinkTestCase.php +++ b/Tests/BaseMinkTestCase.php @@ -139,12 +139,9 @@ protected function makeScreenshot() } try { - $name = date('Y-m-d_H:i:s') . '.png'; - file_put_contents( - '/tmp/' . $name, - $this->session->getScreenshot() - ); - $imageUrl = $this->getUploader()->upload('/tmp/' . $name); + $path = sprintf('%s/%s.png', sys_get_temp_dir(), date('Y-m-d_H-i-s')); + file_put_contents($path, $this->session->getScreenshot()); + $imageUrl = $this->getUploader()->upload($path); } catch (\Exception $e) { $imageUrl = $e->getMessage(); } diff --git a/Tests/TestBundles/DefaultTestBundle/Entity/BasicConstraintsEntity.php b/Tests/TestBundles/DefaultTestBundle/Entity/BasicConstraintsEntity.php index 37313f5..729efbb 100644 --- a/Tests/TestBundles/DefaultTestBundle/Entity/BasicConstraintsEntity.php +++ b/Tests/TestBundles/DefaultTestBundle/Entity/BasicConstraintsEntity.php @@ -711,7 +711,7 @@ public function isValidSingleChoice() */ public function isValidMultipleChoice() { - return $this->_t_get(array('June', 'July'), array('June', 'May', 'September')); + return $this->_t_get(array('June', 'July'), array('June', 'May')); } /** diff --git a/Tests/TestBundles/DefaultTestBundle/Resources/views/FunctionalTests/index.html.twig b/Tests/TestBundles/DefaultTestBundle/Resources/views/FunctionalTests/index.html.twig index 5bc0b3e..c1dcc05 100644 --- a/Tests/TestBundles/DefaultTestBundle/Resources/views/FunctionalTests/index.html.twig +++ b/Tests/TestBundles/DefaultTestBundle/Resources/views/FunctionalTests/index.html.twig @@ -74,7 +74,7 @@ 'isTypeScalar': function() { return _t.get(1, [1,2,3]); }, 'isTypeString': function() { return _t.get('1', 1); }, 'isValidSingleChoice': function() { return _t.get('male', 'wrong_choice'); }, - 'isValidMultipleChoice': function() { return _t.get(['June', 'July'], ['June', 'May', 'September']); }, + 'isValidMultipleChoice': function() { return _t.get(['June', 'July'], ['June', 'May']); }, 'isMinMultipleChoice': function() { return _t.get(['June', 'July'], ['June']); }, 'isMaxMultipleChoice': function() { return _t.get(['June'], ['June', 'July']); }, diff --git a/Tests/app/Resources/BasicConstraintsEntity_sf_2_3.php b/Tests/app/Resources/BasicConstraintsEntity_sf_2_3.php index 24905d7..4e096d1 100644 --- a/Tests/app/Resources/BasicConstraintsEntity_sf_2_3.php +++ b/Tests/app/Resources/BasicConstraintsEntity_sf_2_3.php @@ -712,7 +712,7 @@ public function isValidSingleChoice() */ public function isValidMultipleChoice() { - return $this->_t_get(array('June', 'July'), array('June', 'May', 'September')); + return $this->_t_get(array('June', 'July'), array('June', 'May')); } /** diff --git a/composer.json b/composer.json index 6892948..feeee2d 100644 --- a/composer.json +++ b/composer.json @@ -19,15 +19,15 @@ "require": { "php": ">=5.3.2", - "symfony/form": ">=2.3,<=2.5.4", - "symfony/validator": "~2.3.0,>=2.3.19||~2.4.0,>=2.4.9||~2.5.0,>=2.5.3,<=2.5.4", - "symfony/symfony": "~2.3.0,>=2.3.19" + "symfony/form": ">=2.3,<2.7", + "symfony/validator": "~2.3.0,>=2.3.19||~2.4.0,>=2.4.9||>=2.5.3,<2.7", + "symfony/symfony": "~2.3.0,>=2.3.19||^2.4,<2.6||~2.6.2" }, "require-dev": { "doctrine/orm": ">=2.2.3", "doctrine/doctrine-bundle": "~1.2", - "symfony/assetic-bundle": ">=2.3,<=2.5.4", + "symfony/assetic-bundle": "^2.3", "phpunit/phpunit": "3.7.*", "behat/mink-bundle": "dev-master", "behat/mink-selenium2-driver": "1.1.0", @@ -51,7 +51,7 @@ "extra": { "branch-alias": { - "dev-master": "1.1-dev" + "dev-master": "1.2-dev" } } }