Browse Source

Merge pull request #5527 from cakephp/3.0-deprecations

Remove deprecated methods from Validation class.
José Lorenzo Rodríguez 11 years ago
parent
commit
ea19e9c0b5
2 changed files with 0 additions and 194 deletions
  1. 0 85
      src/Validation/Validation.php
  2. 0 109
      tests/TestCase/Validation/ValidationTest.php

+ 0 - 85
src/Validation/Validation.php

@@ -655,91 +655,6 @@ class Validation
     }
 
     /**
-     * Checks that a value is a valid phone number.
-     *
-     * @param string|array $check Value to check (string or array)
-     * @param string|null $regex Regular expression to use
-     * @param string $country Country code (defaults to 'all')
-     * @return bool Success
-     * @deprecated 3.0.0 Will be removed in 3.0.0. Please use the Localized plugin instead.
-     */
-    public static function phone($check, $regex = null, $country = 'all')
-    {
-        if (is_array($check)) {
-            extract(static::_defaults($check));
-        }
-
-        if ($regex === null) {
-            switch ($country) {
-                case 'us':
-                case 'ca':
-                case 'all':
-                    // includes all NANPA members.
-                    // see http://en.wikipedia.org/wiki/North_American_Numbering_Plan#List_of_NANPA_countries_and_territories
-                    $regex = '/^(?:(?:\+?1\s*(?:[.-]\s*)?)?';
-
-                    // Area code 555, X11 is not allowed.
-                    $areaCode = '(?![2-9]11)(?!555)([2-9][0-8][0-9])';
-                    $regex .= '(?:\(\s*' . $areaCode . '\s*\)|' . $areaCode . ')';
-                    $regex .= '\s*(?:[.-]\s*)?)';
-
-                    // Exchange and 555-XXXX numbers
-                    $regex .= '(?!(555(?:\s*(?:[.\-\s]\s*))(01([0-9][0-9])|1212)))';
-                    $regex .= '(?!(555(01([0-9][0-9])|1212)))';
-                    $regex .= '([2-9]1[02-9]|[2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)';
-
-                    // Local number and extension
-                    $regex .= '?([0-9]{4})';
-                    $regex .= '(?:\s*(?:#|x\.?|ext\.?|extension)\s*(\d+))?$/';
-                    break;
-            }
-        }
-
-        return static::_check($check, $regex);
-    }
-
-    /**
-     * Checks that a given value is a valid postal code.
-     *
-     * @param string|array $check Value to check
-     * @param string|null $regex Regular expression to use
-     * @param string $country Country to use for formatting
-     * @return bool Success
-     * @deprecated 3.0.0 Will be removed in 3.0.0. Please use the Localized plugin instead.
-     */
-    public static function postal($check, $regex = null, $country = 'us')
-    {
-        if (is_array($check)) {
-            extract(static::_defaults($check));
-        }
-
-        if ($regex === null) {
-            switch ($country) {
-                case 'uk':
-                    $regex = '/\\A\\b[A-Z]{1,2}[0-9][A-Z0-9]? [0-9][ABD-HJLNP-UW-Z]{2}\\b\\z/i';
-                    break;
-                case 'ca':
-                    $district = '[ABCEGHJKLMNPRSTVYX]';
-                    $letters = '[ABCEGHJKLMNPRSTVWXYZ]';
-                    $regex = "/\\A\\b{$district}[0-9]{$letters} [0-9]{$letters}[0-9]\\b\\z/i";
-                    break;
-                case 'it':
-                case 'de':
-                    $regex = '/^[0-9]{5}$/i';
-                    break;
-                case 'be':
-                    $regex = '/^[1-9]{1}[0-9]{3}$/i';
-                    break;
-                case 'us':
-                    $regex = '/\\A\\b[0-9]{5}(?:-[0-9]{4})?\\b\\z/i';
-                    break;
-            }
-        }
-
-        return static::_check($check, $regex);
-    }
-
-    /**
      * Validates that a number is in specified range.
      *
      * If $lower and $upper are set, the range is inclusive.

+ 0 - 109
tests/TestCase/Validation/ValidationTest.php

@@ -2207,115 +2207,6 @@ class ValidationTest extends TestCase
     }
 
     /**
-     * testPhone method
-     *
-     * @return void
-     */
-    public function testPhone()
-    {
-        $this->assertFalse(Validation::phone('teststring'));
-        $this->assertFalse(Validation::phone('1-(33)-(333)-(4444)'));
-        $this->assertFalse(Validation::phone('1-(33)-3333-4444'));
-        $this->assertFalse(Validation::phone('1-(33)-33-4444'));
-        $this->assertFalse(Validation::phone('1-(33)-3-44444'));
-        $this->assertFalse(Validation::phone('1-(33)-3-444'));
-        $this->assertFalse(Validation::phone('1-(33)-3-44'));
-
-        $this->assertFalse(Validation::phone('(055) 999-9999'));
-        $this->assertFalse(Validation::phone('(155) 999-9999'));
-        $this->assertFalse(Validation::phone('(595) 999-9999'));
-        $this->assertFalse(Validation::phone('(213) 099-9999'));
-        $this->assertFalse(Validation::phone('(213) 199-9999'));
-
-        // invalid area-codes
-        $this->assertFalse(Validation::phone('1-(511)-999-9999'));
-        $this->assertFalse(Validation::phone('1-(555)-999-9999'));
-
-        // invalid exhange
-        $this->assertFalse(Validation::phone('1-(222)-511-9999'));
-
-        // invalid phone number
-        $this->assertFalse(Validation::phone('1-(222)-555-0199'));
-        $this->assertFalse(Validation::phone('1-(222)-555-0122'));
-
-        // valid phone numbers
-        $this->assertTrue(Validation::phone('416-428-1234'));
-        $this->assertTrue(Validation::phone('1-(369)-333-4444'));
-        $this->assertTrue(Validation::phone('1-(973)-333-4444'));
-        $this->assertTrue(Validation::phone('1-(313)-555-9999'));
-        $this->assertTrue(Validation::phone('1-(222)-555-0299'));
-        $this->assertTrue(Validation::phone('508-428-1234'));
-        $this->assertTrue(Validation::phone('1-(508)-232-9651'));
-
-        $this->assertTrue(Validation::phone('1 (222) 333 4444'));
-        $this->assertTrue(Validation::phone('+1 (222) 333 4444'));
-        $this->assertTrue(Validation::phone('(222) 333 4444'));
-
-        $this->assertTrue(Validation::phone('1-(333)-333-4444'));
-        $this->assertTrue(Validation::phone('1.(333)-333-4444'));
-        $this->assertTrue(Validation::phone('1.(333).333-4444'));
-        $this->assertTrue(Validation::phone('1.(333).333.4444'));
-        $this->assertTrue(Validation::phone('1-333-333-4444'));
-    }
-
-    /**
-     * testPostal method
-     *
-     * @return void
-     */
-    public function testPostal()
-    {
-        $this->assertFalse(Validation::postal('111', null, 'de'));
-        $this->assertFalse(Validation::postal('1111', null, 'de'));
-        $this->assertTrue(Validation::postal('13089', null, 'de'));
-
-        $this->assertFalse(Validation::postal('111', null, 'be'));
-        $this->assertFalse(Validation::postal('0123', null, 'be'));
-        $this->assertTrue(Validation::postal('1204', null, 'be'));
-
-        $this->assertFalse(Validation::postal('111', null, 'it'));
-        $this->assertFalse(Validation::postal('1111', null, 'it'));
-        $this->assertTrue(Validation::postal('13089', null, 'it'));
-
-        $this->assertFalse(Validation::postal('111', null, 'uk'));
-        $this->assertFalse(Validation::postal('1111', null, 'uk'));
-        $this->assertFalse(Validation::postal('AZA 0AB', null, 'uk'));
-        $this->assertFalse(Validation::postal('X0A 0ABC', null, 'uk'));
-        $this->assertTrue(Validation::postal('X0A 0AB', null, 'uk'));
-        $this->assertTrue(Validation::postal('AZ0A 0AA', null, 'uk'));
-        $this->assertTrue(Validation::postal('A89 2DD', null, 'uk'));
-
-        $this->assertFalse(Validation::postal('111', null, 'ca'));
-        $this->assertFalse(Validation::postal('1111', null, 'ca'));
-        $this->assertFalse(Validation::postal('D2A 0A0', null, 'ca'));
-        $this->assertFalse(Validation::postal('BAA 0ABC', null, 'ca'));
-        $this->assertFalse(Validation::postal('B2A AABC', null, 'ca'));
-        $this->assertFalse(Validation::postal('B2A 2AB', null, 'ca'));
-        $this->assertFalse(Validation::postal('K1A 1D1', null, 'ca'));
-        $this->assertFalse(Validation::postal('K1O 1Q1', null, 'ca'));
-        $this->assertFalse(Validation::postal('A1A 1U1', null, 'ca'));
-        $this->assertFalse(Validation::postal('A1F 1B1', null, 'ca'));
-        $this->assertTrue(Validation::postal('X0A 0A2', null, 'ca'));
-        $this->assertTrue(Validation::postal('G4V 4C3', null, 'ca'));
-
-        $this->assertFalse(Validation::postal('111', null, 'us'));
-        $this->assertFalse(Validation::postal('1111', null, 'us'));
-        $this->assertFalse(Validation::postal('130896', null, 'us'));
-        $this->assertFalse(Validation::postal('13089-33333', null, 'us'));
-        $this->assertFalse(Validation::postal('13089-333', null, 'us'));
-        $this->assertFalse(Validation::postal('13A89-4333', null, 'us'));
-        $this->assertTrue(Validation::postal('13089-3333', null, 'us'));
-
-        $this->assertFalse(Validation::postal('111'));
-        $this->assertFalse(Validation::postal('1111'));
-        $this->assertFalse(Validation::postal('130896'));
-        $this->assertFalse(Validation::postal('13089-33333'));
-        $this->assertFalse(Validation::postal('13089-333'));
-        $this->assertFalse(Validation::postal('13A89-4333'));
-        $this->assertTrue(Validation::postal('13089-3333'));
-    }
-
-    /**
      * testUserDefined method
      *
      * @return void