public function testDispenseToSoldOutState() { $machine = new GumballMachine(1); $state = new SoldState($machine); $expected = "A gumball comes rolling out the slot...\nOops, out of gumballs!\n"; $this->assertEquals($expected, $state->dispense()); $this->assertInstanceOf('Kondrat\\DesignPatterns\\State\\ConcreteState\\SoldOutState', $machine->getState()); }
public function testDispenseToSoldOutStateTwoBalls() { $machine = new GumballMachine(2); $state = new WinnerState($machine); $expected = "You are a winner! You get two gumballs for your quarter\nA gumball comes rolling out the slot...\nA gumball comes rolling out the slot...\nOops, out of gumballs!"; $this->assertEquals($expected, $state->dispense()); $this->assertInstanceOf('Kondrat\\DesignPatterns\\State\\ConcreteState\\SoldOutState', $machine->getState()); }
public function testInitialState() { $this->assertInstanceOf('Kondrat\\DesignPatterns\\State\\ConcreteState\\NoQuarterState', $this->machine->getState()); $machine = new GumballMachine(0); $this->assertInstanceOf('Kondrat\\DesignPatterns\\State\\ConcreteState\\SoldOutState', $machine->getState()); }