Browse Source

fix not throwing deprecation warning

1)removing `testAllowEmptyDateTimeDeprecated`:

deprecated argument order was in cake 3.x , not cake4
also this testCase was deplicated with
`testAllowEmptyDateTimeCondition`

2) throwing deprecation warning in testArrayPropertyMerge and
testArrayProperties

second Argument of setHelpers deprecated in cake +4.3
and in cake5 should use addHelper()/addHelpers() instead.
saeid 4 years ago
parent
commit
4447bf5c68
2 changed files with 12 additions and 26 deletions
  1. 0 22
      tests/TestCase/Validation/ValidatorTest.php
  2. 12 4
      tests/TestCase/View/ViewBuilderTest.php

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

@@ -1301,28 +1301,6 @@ class ValidatorTest extends TestCase
     }
 
     /**
-     * test allowEmptyDateTime with deprecated argument order
-     */
-    public function testAllowEmptyDateTimeDeprecated(): void
-    {
-        $validator = new Validator();
-        $this->deprecated(function () use ($validator): void {
-            $validator->allowEmptyDateTime('published', 'datetime required', 'update');
-        });
-        $this->assertFalse($validator->isEmptyAllowed('published', true));
-        $this->assertTrue($validator->isEmptyAllowed('published', false));
-
-        $data = [
-            'published' => null,
-        ];
-        $expected = [
-            'published' => ['_empty' => 'datetime required'],
-        ];
-        $this->assertSame($expected, $validator->validate($data, true));
-        $this->assertEmpty($validator->validate($data, false));
-    }
-
-    /**
      * Tests the notEmptyDateTime method
      */
     public function testNotEmptyDateTime(): void

+ 12 - 4
tests/TestCase/View/ViewBuilderTest.php

@@ -159,12 +159,16 @@ class ViewBuilderTest extends TestCase
         $get = 'get' . ucfirst($property);
         $set = 'set' . ucfirst($property);
 
-        $this->deprecated(function () use ($get, $set, $value) {
-            $builder = new ViewBuilder();
-            $this->assertSame([], $builder->{$get}(), 'Default value should be empty list');
+        $builder = new ViewBuilder();
+        $this->assertSame([], $builder->{$get}(), 'Default value should be empty list');
+        $this->deprecated(function () use ($set, $value, $builder) {
+            // only deprecated wrapper should remove in cake 5, assert should kept
+            if ($set !== 'setHelpers') {
+                trigger_error('Only setHelpers has deprecation warning in cake +4.x', E_USER_DEPRECATED);
+            }
             $this->assertSame($builder, $builder->{$set}($value), 'Setter returns this');
-            $this->assertSame($value, $builder->{$get}(), 'Getter gets value.');
         });
+        $this->assertSame($value, $builder->{$get}(), 'Getter gets value.');
     }
 
     /**
@@ -178,6 +182,10 @@ class ViewBuilderTest extends TestCase
         $set = 'set' . ucfirst($property);
 
         $this->deprecated(function () use ($get, $set, $value) {
+            // only deprecated wrapper and setHelpers testing should remove in cake 5, other asserts should kept
+            if ($set !== 'setHelpers') {
+                trigger_error('Only setHelpers has deprecation warning in cake 4.x', E_USER_DEPRECATED);
+            }
             $builder = new ViewBuilder();
             $builder->{$set}($value);