|
|
@@ -1422,23 +1422,33 @@ class HashTest extends TestCase
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Test extracting value-zero contained data based on attributes with string
|
|
|
+ * Test extracting attributes with string
|
|
|
*
|
|
|
* @return void
|
|
|
*/
|
|
|
- public function testExtractAttributeStringWithDataContainsZero()
|
|
|
+ public function testExtractAttributeString()
|
|
|
{
|
|
|
$data = [
|
|
|
- ['value' => '0'],
|
|
|
['value' => 0],
|
|
|
+ ['value' => 3],
|
|
|
['value' => 'string-value'],
|
|
|
+ ['value' => new Time('2010-01-05 01:23:45')],
|
|
|
];
|
|
|
|
|
|
- $expected = [
|
|
|
- ['value' => 'string-value'],
|
|
|
- ];
|
|
|
+ // check _matches does not work as `0 == 'string-value'`
|
|
|
+ $expected = [$data[2]];
|
|
|
$result = Hash::extract($data, '{n}[value=string-value]');
|
|
|
$this->assertSame($expected, $result);
|
|
|
+
|
|
|
+ // check _matches work with object implements __toString()
|
|
|
+ $expected = [$data[3]];
|
|
|
+ $result = Hash::extract($data, sprintf('{n}[value=%s]', $data[3]['value']));
|
|
|
+ $this->assertSame($expected, $result);
|
|
|
+
|
|
|
+ // check _matches does not work as `3 == '3 people'`
|
|
|
+ $unexpected = $data[1];
|
|
|
+ $result = Hash::extract($data, '{n}[value=3people]');
|
|
|
+ $this->assertNotContains($unexpected, $result);
|
|
|
}
|
|
|
|
|
|
/**
|