2005-07-04 01:07:14 +00:00
|
|
|
<?php
|
2005-06-20 23:08:59 +00:00
|
|
|
|
2005-07-04 01:39:06 +00:00
|
|
|
uses('neat_array');
|
2005-06-20 23:08:59 +00:00
|
|
|
|
2005-07-04 01:39:06 +00:00
|
|
|
class NeatArrayTest extends UnitTestCase
|
2005-06-20 23:08:59 +00:00
|
|
|
{
|
2005-07-04 01:39:06 +00:00
|
|
|
var $neatArray;
|
2005-06-20 23:08:59 +00:00
|
|
|
|
|
|
|
// constructor of the test suite
|
2005-07-04 01:39:06 +00:00
|
|
|
function NeatArrayTest()
|
2005-06-20 23:08:59 +00:00
|
|
|
{
|
2005-07-04 01:39:06 +00:00
|
|
|
$this->UnitTestCase('NeatArray test');
|
2005-06-20 23:08:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// called before the test functions will be executed
|
|
|
|
// this function is defined in PHPUnit_TestCase and overwritten
|
|
|
|
// here
|
|
|
|
function setUp()
|
|
|
|
{
|
2005-07-04 01:39:06 +00:00
|
|
|
$this->neatArray = new NeatArray();
|
2005-06-20 23:08:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// called after the test functions are executed
|
|
|
|
// this function is defined in PHPUnit_TestCase and overwritten
|
|
|
|
// here
|
|
|
|
function tearDown()
|
|
|
|
{
|
2005-07-04 01:39:06 +00:00
|
|
|
unset($this->neatArray);
|
2005-06-20 23:08:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function testInArray()
|
|
|
|
{
|
|
|
|
$a = array('foo'=>' bar ', 'i-am'=>'a');
|
|
|
|
$b = array('foo'=>'bar ', 'i-am'=>'b');
|
|
|
|
$c = array('foo'=>' bar', 'i-am'=>'c');
|
|
|
|
$d = array('foo'=>'bar', 'i-am'=>'d');
|
|
|
|
|
2005-07-04 01:39:06 +00:00
|
|
|
$n = new NeatArray(array($a, $b, $c, $d));
|
2005-06-20 23:08:59 +00:00
|
|
|
|
|
|
|
$result = $n->findIn('foo', ' bar ');
|
|
|
|
$expected = array(0=>$a);
|
|
|
|
$this->assertEqual($result, $expected);
|
|
|
|
|
|
|
|
$result = $n->findIn('foo', 'bar ');
|
|
|
|
$expected = array(1=>$b);
|
|
|
|
$this->assertEqual($result, $expected);
|
|
|
|
|
|
|
|
$result = $n->findIn('foo', ' bar');
|
|
|
|
$expected = array(2=>$c);
|
|
|
|
$this->assertEqual($result, $expected);
|
|
|
|
|
|
|
|
$result = $n->findIn('foo', 'bar');
|
|
|
|
$expected = array(3=>$d);
|
|
|
|
$this->assertEqual($result, $expected);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|