コード例 #1
0
 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'));
 }
コード例 #2
0
<?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');