public function testBuyStock() { $market = new Market($this->markets['nasdaq']); $this->assertEquals('you purchased GOOG stock', $market->buyStock('GOOG')); $market->setGateway($this->markets['spx500']); $this->assertEquals('you purchased AMZN stock', $market->buyStock('AMZN')); }
<?php require 'stocksmarket.php'; $markets = array('nasdaq' => new NasdaqGateway(), 'spx500' => new SPX500Gateway()); $market = new Market($markets['nasdaq']); echo $market->buyStock('GOOG'); echo '<br>'; $market->setGateway($markets['spx500']); echo $market->buyStock('AMZN');