/** * @spec */ public function testPeek() { when: $this->stack->peek(); then: thrown('Example\\Stack\\EmptyStackException'); }
/** * sets the value of state * * @param string $newState * @throws UnexpectedValueException if not a string */ public function setState($newState) { //trim the string $newState = trim($newState); //sanitize the string if ($newState = filter_var($newState, FILTER_SANITIZE_STRING) == false) { thrown(new UnexpectedValueException("state {$newState} is not a string")); } //remove from quarantine and assign $this->state = $newState; }
/** * @spec */ public function testExceptionCombination() { when: 1 == 1; then: notThrown("RuntimeException"); _when: throw new \RuntimeException("test"); _then: thrown("RuntimeException"); }