blob: 62559de838a13ac315984aa5fadfffa23349fda9 [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{
Eric Barnes68286a42011-04-21 22:00:33 -04009 public function set_up()
Pascal Kriete69c97a72011-04-20 21:44:54 -040010 {
11 $this->my_array = array(
12 'foo' => 'bar',
13 'sally' => 'jim',
14 'maggie' => 'bessie',
15 'herb' => 'cook'
16 );
17 }
18
19 // ------------------------------------------------------------------------
20
Eric Barnes68286a42011-04-21 22:00:33 -040021 public function test_element_with_existing_item()
Pascal Kriete69c97a72011-04-20 21:44:54 -040022 {
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
Eric Barnes68286a42011-04-21 22:00:33 -040032 public function test_random_element()
Pascal Kriete69c97a72011-04-20 21:44:54 -040033 {
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
Eric Barnes68286a42011-04-21 22:00:33 -040043 public function test_elements()
Pascal Kriete69c97a72011-04-20 21:44:54 -040044 {
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}