blob: fd306cee8bfac358a6eb67bb09975f0946499cbb [file] [log] [blame]
Pascal Kriete69c97a72011-04-20 21:44:54 -04001<?php
2
3// OLD TEST FORMAT: DO NOT COPY
4
5require_once(BASEPATH.'helpers/array_helper.php');
6
Greg Akerb4d93db2011-04-21 14:42:33 -05007class Array_helper_test extends CI_TestCase
Pascal Kriete69c97a72011-04-20 21:44:54 -04008{
9 public function setUp()
10 {
11 $this->my_array = array(
12 'foo' => 'bar',
13 'sally' => 'jim',
14 'maggie' => 'bessie',
15 'herb' => 'cook'
16 );
17 }
18
19 // ------------------------------------------------------------------------
20
21 public function testElementWithExistingItem()
22 {
23 $this->assertEquals(FALSE, element('testing', $this->my_array));
24
25 $this->assertEquals('not set', element('testing', $this->my_array, 'not set'));
26
27 $this->assertEquals('bar', element('foo', $this->my_array));
28 }
29
30 // ------------------------------------------------------------------------
31
32 public function testRandomElement()
33 {
34 // Send a string, not an array to random_element
35 $this->assertEquals('my string', random_element('my string'));
36
37 // Test sending an array
38 $this->assertEquals(TRUE, in_array(random_element($this->my_array), $this->my_array));
39 }
40
41 // ------------------------------------------------------------------------
42
43 public function testElements()
44 {
45 $this->assertEquals(TRUE, is_array(elements('test', $this->my_array)));
46 $this->assertEquals(TRUE, is_array(elements('foo', $this->my_array)));
47 }
48
49}