Skip to content
Snippets Groups Projects
Commit 593e7f77 authored by Taddeus Kroes's avatar Taddeus Kroes
Browse files

Added some tests for array plugin.

parent 21f7f487
No related branches found
No related tags found
No related merge requests found
......@@ -30,6 +30,15 @@ class pQueryArray extends pQuery implements pQueryExtension {
return !$this->count();
}
/**
* Get the number of elementsin the array.
*
* @returns int The number of elements.
*/
function count() {
return count($this->variable);
}
/**
* Reverse the array.
*
......@@ -58,10 +67,7 @@ class pQueryArray extends pQuery implements pQueryExtension {
return call_user_func_array($function, $args);
}
if( in_array($method, array('count')) )
return $method($this->variable);
if( in_array($method, array('shuffle')) ) {
if( in_array($method, array('shuffle', 'sort')) ) {
$method($this->variable);
return $this;
}
......
......@@ -43,8 +43,14 @@ class pQueryArrayTest extends UnitTestCase {
$this->assertEqual($arr->reverse()->variable, $reverse, 'reverse is not really reverse...');
}
function test_call() {
function test_call_count() {
$this->assertEqual($this->arr->count(), count($this->variable));
}
function test_call_sort() {
$arr = range(1, 8);
shuffle($arr);
$this->assertEqual(_arr($arr)->sort()->variable, range(1, 8));
}
}
......
- Extend array plugin with stack/collection functions.
- Unit test array plugin
- Unit test base
- Unit test cache plugin
- Unit test css plugin
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment