Browse Source

Test: Hash::extract handling numeric value condition

Hideki Kinjyo 8 years ago
parent
commit
1dd631ba72
1 changed files with 20 additions and 0 deletions
  1. 20 0
      tests/TestCase/Utility/HashTest.php

+ 20 - 0
tests/TestCase/Utility/HashTest.php

@@ -1422,6 +1422,26 @@ class HashTest extends TestCase
     }
 
     /**
+     * Test extracting value-zero contained data based on attributes with string
+     *
+     * @return void
+     */
+    public function testExtractAttributeStringWithDataContainsZero()
+    {
+        $data = [
+            ['value' => '0'],
+            ['value' => 0],
+            ['value' => 'string-value'],
+        ];
+
+        $expected = [
+            ['value' => 'string-value'],
+        ];
+        $result = Hash::extract($data, '{n}[value=string-value]');
+        $this->assertSame($expected, $result);
+    }
+
+    /**
      * Test that uneven keys are handled correctly.
      *
      * @return void