-
Notifications
You must be signed in to change notification settings - Fork 0
/
bubblertest.php
38 lines (34 loc) · 911 Bytes
/
bubblertest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
require_once ('bubbler.php');
class BubblerTest extends PHPUnit_Framework_TestCase
{
public function testCreateBubbler(){
$testData = array(12, 48, 99, 15000, -50, 1, 0, 3, 7, 88, 11, 33, 13, 20, 5, 6);
return new Bubbler($testData);
}
/**
* @depends testCreateBubbler
* Test to make sure the array is not sorted already.
*/
public function testBubblerAlreadySorted(Bubbler $aBubbler)
{
$sortedArray = $aBubbler->getArray();
sort($sortedArray);
if($sortedArray == $aBubbler->getArray())
{
$this->fail('The Bubbler array is already sorted');
}
return $aBubbler;
}
/**
* @depends testBubblerAlreadySorted
* Test to see if the sort fucntion works.
*/
public function testBubblerSorting(Bubbler $aBubbler)
{
$sortedArray = $aBubbler->getArray();
sort($sortedArray);
$aBubbler->bubbleSort();
$this->assertEquals($sortedArray, $aBubbler->getArray());
}
}