Array unit tests #873

Merged
merged 8 commits into from Mar 22, 2012

Projects

None yet

3 participants

@devsmt
devsmt commented Mar 15, 2012

fixed and tested 2 simple edge cases in core array functions (sorry people, this is my first pull request!)

@frankdejonge frankdejonge commented on an outdated diff Mar 16, 2012
tests/arr.php
@@ -492,6 +492,13 @@ public function test_sort_invalid_direction($data, $expected)
$this->assertEquals(Arr::sort($data, 'info.pet.type', 'downer'), $expected);
}
+ public function test_sort_empty()
+ {
+ $expected = array();
+ $output = Arr::Sort(array(), 'test', 'test');
@frankdejonge
frankdejonge Mar 16, 2012

This should be lowercase 'sort'.

devsmt added some commits Mar 16, 2012
@devsmt devsmt handle empty input array in Arr::sort() e4327e5
@devsmt devsmt conflict resolved 9e10903
@devsmt devsmt Merge branch '1.1/develop' of github.com:devsmt/core into 1.1/develop
* '1.1/develop' of github.com:devsmt/core:
  handle empty input array in Arr::sort()

Conflicts:
	tests/arr.php
2cd0488
@devsmt devsmt Merge remote-tracking branch 'fuel-core/1.1/develop' into 1.1/develop
* fuel-core/1.1/develop:
  fixed a Migration flow error and a notice...
  added individual migration tracking to Migrations. Closes #843
  fixed loading config files by FQFN. Closes #825
  Changed if statement and added exception for invalid input to bring inline with coding standards.
  Fixed backslash issue in asset paths on Windows
  Added layout template and partial support to Theme
  Added ability to add and drop foreign keys after a table has been created
571100a
@devsmt
devsmt commented Mar 17, 2012

resolved

@frankdejonge frankdejonge and 2 others commented on an outdated diff Mar 17, 2012
tests/arr.php
@@ -492,6 +492,17 @@ public function test_sort_invalid_direction($data, $expected)
$this->assertEquals(Arr::sort($data, 'info.pet.type', 'downer'), $expected);
}
+ public function test_sort_empty()
+ {
+ $expected = array();
+<<<<<<< HEAD
+ $output = Arr::sort(array(), 'test', 'test');
+=======
+ $output = Arr::Sort(array(), 'test', 'test');
+>>>>>>> 85988a20a4cdc8acfaa251be68aac253939f0aed
@devsmt
devsmt Mar 18, 2012

yes... any suggestion to clean it up?

@jschreuder
jschreuder Mar 18, 2012

It's a Git merge conflict, you need to decide which to use... (the lowercase one obviously)

@frankdejonge frankdejonge commented on an outdated diff Mar 22, 2012
classes/arr.php
@@ -481,6 +481,11 @@ public static function sort($array, $key, $order = 'asc', $sort_flags = SORT_REG
throw new \InvalidArgumentException('Arr::sort() - $array must be an array.');
}
+ if( empty($array) )
@frankdejonge
frankdejonge Mar 22, 2012

small style fix -> if (empty))
The rest seems to be correct

@frankdejonge frankdejonge and 1 other commented on an outdated diff Mar 22, 2012
tests/format.php
@@ -151,4 +151,10 @@ public function test__from_xml()
$this->assertEquals(Format::forge($expected)->to_php(), Format::forge($xml, 'xml')->to_php());
}
+
+ function test_to_array_empty(){
@frankdejonge
frankdejonge Mar 22, 2012

and the opening bracket needs to be on a new line

@devsmt
devsmt Mar 22, 2012

do you use an automated tool to enforce formatting? any help with formatting issues will benefit the project of more occasional contributions from casual users used to different conventions (like me...)

@frankdejonge
frankdejonge Mar 22, 2012

I don't maybe others do. But it's just following our style guide: http://docs.fuelphp.com/general/coding_standards.html

@frankdejonge frankdejonge merged commit 85c2140 into fuel:1.1/develop Mar 22, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment