Pārlūkot izejas kodu

[Validator] fixed unit tests when intl is not installed

Fabien Potencier 14 gadi atpakaļ
vecāks
revīzija
e42a2dede1

+ 3 - 1
tests/Symfony/Tests/Component/Validator/Constraints/CountryValidatorTest.php

@@ -14,12 +14,14 @@ namespace Symfony\Tests\Component\Validator\Constraints;
 use Symfony\Component\Validator\Constraints\Country;
 use Symfony\Component\Validator\Constraints\CountryValidator;
 
-class CountryValidatorTest extends \PHPUnit_Framework_TestCase
+class CountryValidatorTest extends LocalizedTestCase
 {
     protected $validator;
 
     protected function setUp()
     {
+        parent::setUp();
+
         $this->validator = new CountryValidator();
     }
 

+ 3 - 1
tests/Symfony/Tests/Component/Validator/Constraints/LanguageValidatorTest.php

@@ -14,12 +14,14 @@ namespace Symfony\Tests\Component\Validator\Constraints;
 use Symfony\Component\Validator\Constraints\Language;
 use Symfony\Component\Validator\Constraints\LanguageValidator;
 
-class LanguageValidatorTest extends \PHPUnit_Framework_TestCase
+class LanguageValidatorTest extends LocalizedTestCase
 {
     protected $validator;
 
     protected function setUp()
     {
+        parent::setUp();
+
         $this->validator = new LanguageValidator();
     }
 

+ 3 - 1
tests/Symfony/Tests/Component/Validator/Constraints/LocaleValidatorTest.php

@@ -14,12 +14,14 @@ namespace Symfony\Tests\Component\Validator\Constraints;
 use Symfony\Component\Validator\Constraints\Locale;
 use Symfony\Component\Validator\Constraints\LocaleValidator;
 
-class LocaleValidatorTest extends \PHPUnit_Framework_TestCase
+class LocaleValidatorTest extends LocalizedTestCase
 {
     protected $validator;
 
     protected function setUp()
     {
+        parent::setUp();
+
         $this->validator = new LocaleValidator();
     }
 

+ 22 - 0
tests/Symfony/Tests/Component/Validator/Constraints/LocalizedTestCase.php

@@ -0,0 +1,22 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Tests\Component\Validator\Constraints;
+
+abstract class LocalizedTestCase extends \PHPUnit_Framework_TestCase
+{
+    protected function setUp()
+    {
+        if (!extension_loaded('intl')) {
+            $this->markTestSkipped('The "intl" extension is not available');
+        }
+    }
+}