From 03b78b0e000b9010cfcd832ac9409c885964ca4c Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Sat, 16 Mar 2013 01:38:07 +0100 Subject: [PATCH] [Validator] Improved tests to use the IntlTestHelper class --- .../Constraints/CountryValidatorTest.php | 5 +-- .../Constraints/LanguageValidatorTest.php | 5 +-- .../Tests/Constraints/LocaleValidatorTest.php | 5 +-- .../Tests/Constraints/LocalizedTestCase.php | 34 ------------------- 4 files changed, 9 insertions(+), 40 deletions(-) delete mode 100644 src/Symfony/Component/Validator/Tests/Constraints/LocalizedTestCase.php diff --git a/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php index 2ff89aa718..3eedaa3264 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/CountryValidatorTest.php @@ -11,17 +11,18 @@ namespace Symfony\Component\Validator\Tests\Constraints; +use Symfony\Component\Intl\Util\IntlTestHelper; use Symfony\Component\Validator\Constraints\Country; use Symfony\Component\Validator\Constraints\CountryValidator; -class CountryValidatorTest extends LocalizedTestCase +class CountryValidatorTest extends \PHPUnit_Framework_TestCase { protected $context; protected $validator; protected function setUp() { - parent::setUp(); + IntlTestHelper::requireIntl($this); $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); $this->validator = new CountryValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php index bd36da0bb1..1230e3f322 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LanguageValidatorTest.php @@ -11,17 +11,18 @@ namespace Symfony\Component\Validator\Tests\Constraints; +use Symfony\Component\Intl\Util\IntlTestHelper; use Symfony\Component\Validator\Constraints\Language; use Symfony\Component\Validator\Constraints\LanguageValidator; -class LanguageValidatorTest extends LocalizedTestCase +class LanguageValidatorTest extends \PHPUnit_Framework_TestCase { protected $context; protected $validator; protected function setUp() { - parent::setUp(); + IntlTestHelper::requireIntl($this); $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); $this->validator = new LanguageValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php index 0a4285a504..41feba0c71 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php @@ -11,17 +11,18 @@ namespace Symfony\Component\Validator\Tests\Constraints; +use Symfony\Component\Intl\Util\IntlTestHelper; use Symfony\Component\Validator\Constraints\Locale; use Symfony\Component\Validator\Constraints\LocaleValidator; -class LocaleValidatorTest extends LocalizedTestCase +class LocaleValidatorTest extends \PHPUnit_Framework_TestCase { protected $context; protected $validator; protected function setUp() { - parent::setUp(); + IntlTestHelper::requireIntl($this); $this->context = $this->getMock('Symfony\Component\Validator\ExecutionContext', array(), array(), '', false); $this->validator = new LocaleValidator(); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LocalizedTestCase.php b/src/Symfony/Component/Validator/Tests/Constraints/LocalizedTestCase.php deleted file mode 100644 index b6fe3f58c2..0000000000 --- a/src/Symfony/Component/Validator/Tests/Constraints/LocalizedTestCase.php +++ /dev/null @@ -1,34 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Validator\Tests\Constraints; - -use Symfony\Component\Intl\Intl; - -abstract class LocalizedTestCase extends \PHPUnit_Framework_TestCase -{ - protected function setUp() - { - parent::setUp(); - - if (!class_exists('Symfony\Component\Intl\Intl')) { - $this->markTestSkipped('The "Intl" component is not available'); - } - - if (!Intl::isExtensionLoaded()) { - $this->markTestSkipped('The "intl" extension is not available'); - } - - Intl::setDataSource(Intl::STUB); - - \Locale::setDefault('en'); - } -}