Add is_array_assoc() and array indexed and associative tests

This commit is contained in:
Zach Borboa
2013-12-11 21:18:57 -08:00
parent 7b8fd042d0
commit db0ddc4b36
2 changed files with 20 additions and 0 deletions
+4
View File
@@ -168,6 +168,10 @@ class Curl {
public $response = NULL;
}
function is_array_assoc($array) {
return (bool)count(array_filter(array_keys($array), 'is_string'));
}
function is_array_multidim($array) {
if (!is_array($array)) {
return FALSE;
+16
View File
@@ -10,6 +10,22 @@ class CurlTest extends PHPUnit_Framework_TestCase {
$this->assertTrue(extension_loaded('curl'));
}
public function testArrayAssociative() {
$this->assertTrue(is_array_assoc(array(
'foo' => 'wibble',
'bar' => 'wubble',
'baz' => 'wobble',
)));
}
public function testArrayIndexed() {
$this->assertFalse(is_array_assoc(array(
'wibble',
'wubble',
'wobble',
)));
}
public function testUserAgent() {
$test = new Test();
$test->curl->setUserAgent(Curl::USER_AGENT);