Skip to content

Commit

Permalink
added test for float column key
Browse files Browse the repository at this point in the history
  • Loading branch information
xemlock committed Sep 29, 2015
1 parent ad3afe5 commit 4a3b88a
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/ArrayColumnTest.php
Expand Up @@ -417,6 +417,34 @@ public function testFunctionWithFourArgsReturnValue()
$this->assertNull($result);
}

public function testFunctionWithColumnKeyAsFloat()
{
// float column key should be coerced to integer
$columnKey = 12.4;
$records = array(
array(
// 12 should match the column key coerced to integer
12 => 1,
),
array(
// 12.4 will automatically be coerced to 12 by PHP internals,
// as such it should match the column key coerced to integer
12.4 => 2,
),
array(
// this item should be ignored because column key value '12.4'
// is a string, not an integer (or float)
'12.4' => 3,
),
);
$expected = array(
0 => 1,
1 => 2,
);

$this->assertEquals($expected, array_column($records, $columnKey));
}

public function testFunctionWithIndexKeyAsFloat()
{
$columnKey = 'value';
Expand Down

0 comments on commit 4a3b88a

Please sign in to comment.