예제 #1
0
 public function testShopPurchaseHandlesNoItemNoQuantity()
 {
     // Inject post request.
     RequestWrapper::inject(new Request([], []));
     $shop = new ShopController();
     $shop_outcome = $shop->buy();
     $this->assertNotEmpty($shop_outcome);
 }
예제 #2
0
 public function testShopCannotBuyInvalidItem()
 {
     $pc = Player::findPlayable($this->account->id());
     $pc->gold = $pc->gold + 9999;
     $pc->save();
     $request = new Request([], ['quantity' => 4, 'item' => 'zigzigX']);
     RequestWrapper::inject($request);
     $shop = new ShopController();
     $response = $shop->buy();
     $this->assertNotEmpty($response);
     $reflection = new \ReflectionProperty(get_class($response), 'data');
     $reflection->setAccessible(true);
     $response_data = $reflection->getValue($response);
     $this->assertFalse($response_data['valid']);
 }