Browse Source

Merge branch 'master' into 3.next

Mark Story 6 years ago
parent
commit
c68210faa2
2 changed files with 31 additions and 2 deletions
  1. 2 2
      tests/TestCase/Mailer/EmailTest.php
  2. 29 0
      tests/TestCase/Validation/ValidatorTest.php

+ 2 - 2
tests/TestCase/Mailer/EmailTest.php

@@ -1603,8 +1603,8 @@ class EmailTest extends TestCase
         $this->Email->setAttachments([
             'gâteau.png' => [
                 'file' => CORE_PATH . 'VERSION.txt',
-                'contentId' => 'abc123'
-            ]
+                'contentId' => 'abc123',
+            ],
         ]);
         $result = $this->Email->send('Hello');
 

+ 29 - 0
tests/TestCase/Validation/ValidatorTest.php

@@ -833,6 +833,35 @@ class ValidatorTest extends TestCase
     }
 
     /**
+     * Test allowEmptyString with callback
+     *
+     */
+    public function testAllowEmptyStringCallbackWhen()
+    {
+        $validator = new Validator();
+        $validator->allowEmptyString(
+            'title',
+            'very required',
+            function ($context) {
+                return $context['data']['otherField'] === true;
+            }
+        )
+            ->scalar('title');
+
+        $data = [
+            'title' => '',
+            'otherField' => false,
+        ];
+        $this->assertNotEmpty($validator->errors($data));
+
+        $data = [
+            'title' => '',
+            'otherField' => true,
+        ];
+        $this->assertEmpty($validator->errors($data));
+    }
+
+    /**
      * Same as testAllowEmptyDateUpdateDeprecatedArguments but without message
      *
      * @return void