Browse Source

Merge branch 'master' into 3.2

Jose Lorenzo Rodriguez 10 years ago
parent
commit
75b221eba2
2 changed files with 12 additions and 14 deletions
  1. 5 6
      src/Validation/Validation.php
  2. 7 8
      tests/TestCase/Database/QueryTest.php

+ 5 - 6
src/Validation/Validation.php

@@ -166,7 +166,7 @@ class Validation
 
         if ($regex !== null) {
             if (static::_check($check, $regex)) {
-                return !$deep || static::luhn($check, $deep);
+                return !$deep || static::luhn($check);
             }
         }
         $cards = [
@@ -193,7 +193,7 @@ class Validation
                 $regex = $cards['all'][strtolower($value)];
 
                 if (static::_check($check, $regex)) {
-                    return static::luhn($check, $deep);
+                    return static::luhn($check);
                 }
             }
         } elseif ($type === 'all') {
@@ -201,14 +201,14 @@ class Validation
                 $regex = $value;
 
                 if (static::_check($check, $regex)) {
-                    return static::luhn($check, $deep);
+                    return static::luhn($check);
                 }
             }
         } else {
             $regex = $cards['fast'];
 
             if (static::_check($check, $regex)) {
-                return static::luhn($check, $deep);
+                return static::luhn($check);
             }
         }
         return false;
@@ -844,11 +844,10 @@ class Validation
      * Luhn algorithm
      *
      * @param string|array $check Value to check.
-     * @param bool $deep If true performs deep check.
      * @return bool Success
      * @see http://en.wikipedia.org/wiki/Luhn_algorithm
      */
-    public static function luhn($check, $deep = false)
+    public static function luhn($check)
     {
         if (!is_scalar($check) || (int)$check === 0) {
             return false;

+ 7 - 8
tests/TestCase/Database/QueryTest.php

@@ -2796,25 +2796,24 @@ class QueryTest extends TestCase
         $query = new Query($this->connection);
         $result = $query->select(
             function ($q) {
-                    return ['total' => $q->func()->count('*')];
+                return ['total' => $q->func()->count('*')];
             }
         )
-            ->from('articles')
+            ->from('comments')
             ->execute();
-        $expected = [['total' => 3]];
+        $expected = [['total' => 6]];
         $this->assertEquals($expected, $result->fetchAll('assoc'));
 
         $query = new Query($this->connection);
         $result = $query->select([
-                'c' => $query->func()->concat(['title' => 'literal', ' is appended'])
+                'c' => $query->func()->concat(['comment' => 'literal', ' is appended'])
             ])
-            ->from('articles')
+            ->from('comments')
             ->order(['c' => 'ASC'])
+            ->limit(1)
             ->execute();
         $expected = [
-            ['c' => 'First Article is appended'],
-            ['c' => 'Second Article is appended'],
-            ['c' => 'Third Article is appended']
+            ['c' => 'First Comment for First Article is appended'],
         ];
         $this->assertEquals($expected, $result->fetchAll('assoc'));