I want to write a unit test for a class handling a stack of positive integers.
There are 4 methods in such class: push($x), pop(), getSize(), purge()
.
Please help me.
Class looks like :-
class Stack {
private $stack = array();
public function __construct() {
}
public function push($data) {
array_push($this->stack, $data);
}
public function pop() {
return array_pop($this->stack);
}
public function getSize() {
return count($this->stack);
}
public function purge($element) {
unset $this->stack[$element];
}
}
$s = new Stack();