示例#1
0
 public static function initialize(Config $config)
 {
     ItemGroupTrait::initialize($config);
     TimestampsTrait::initialize($config);
     RandomKeyTrait::initialize($config);
     $config->setTable('StorePurchase')->addRels([new Rel\BelongsTo('purchase', $config, Purchase::getRepo()), new Rel\BelongsTo('store', $config, Store::getRepo()), new Rel\HasMany('items', $config, PurchaseItem::getRepo(), ['inverseOf' => 'storePurchase']), new Rel\HasMany('refunds', $config, Refund::getRepo(), ['inverseOf' => 'storePurchase'])]);
 }
示例#2
0
 public function testStorePurchase()
 {
     $purchase = new Purchase();
     $address = Address::find(1);
     $product1 = Product::find(5);
     $product2 = Product::find(6);
     $product3 = Product::find(7);
     $purchase->setBilling($address);
     $purchase->addProduct($product1, 4)->addProduct($product2)->addProduct($product3)->addProduct($product1);
     Purchase::save($purchase);
     $gateway = Omnipay::getFactory()->create('Dummy');
     $parameters = ['card' => ['number' => '4242424242424242', 'expiryMonth' => 12, 'expiryYear' => date('Y'), 'cvv' => 123], 'clientIp' => '192.168.0.1'];
     $response = $purchase->purchase($gateway, $parameters);
     $this->assertTrue($response->isSuccessful());
     $this->assertEquals('Success', $response->getMessage());
 }
示例#3
0
 public static function initialize(Config $config)
 {
     ItemTrait::initialize($config);
     InheritedTrait::initialize($config);
     TimestampsTrait::initialize($config);
     $config->addRels([new Rel\BelongsTo('purchase', $config, Purchase::getRepo()), new Rel\BelongsTo('storePurchase', $config, StorePurchase::getRepo())]);
 }
示例#4
0
 /**
  * @coversNothing
  */
 public function testIntegration()
 {
     $purchaseItem = PurchaseItem::find(1);
     $order = Purchase::find(1);
     $purchase = StorePurchase::find(1);
     $this->assertSame($order, $purchaseItem->getPurchase());
     $this->assertSame($purchase, $purchaseItem->getStorePurchase());
 }
示例#5
0
 /**
  * @coversNothing
  */
 public function testIntegration()
 {
     $address = Address::find(1);
     $purchase = Purchase::find(1);
     $country = Country::find(1);
     $city = City::find(2);
     $this->assertSame($purchase, $address->getPurchase());
     $this->assertSame($city, $address->getCity());
     $this->assertSame($country, $address->getCountry());
 }
示例#6
0
 /**
  * @covers ::getRequestParameters
  */
 public function testGetRequestParameters()
 {
     $purchase = Purchase::find(1);
     $data = $purchase->getRequestParameters(array());
     $expected = array('amount' => 100.0, 'currency' => 'GBP', 'transactionReference' => 1, 'items' => [0 => ['name' => 1, 'description' => 'Items from Store 1', 'price' => 60.0, 'quantity' => 1], 1 => ['name' => 2, 'description' => 'Items from Store 1', 'price' => 40.0, 'quantity' => 1]], 'card' => ['firstName' => 'John', 'lastName' => 'Doe', 'address1' => 'Moskovska', 'address2' => '132', 'city' => 'Sofia', 'country' => 'BG', 'postcode' => '1000', 'phone' => '123123', 'email' => '*****@*****.**']);
     $this->assertSame($expected, $data);
 }
示例#7
0
 public static function initialize(Config $config)
 {
     SoftDeleteTrait::initialize($config);
     $config->addRels([new Rel\BelongsTo('city', $config, City::getRepo()), new Rel\BelongsTo('country', $config, Country::getRepo()), new Rel\HasOne('purchase', $config, Purchase::getRepo(), ['foreignKey' => 'billingId'])])->addAsserts([new Assert\Present('firstName'), new Assert\Present('lastName'), new Assert\Present('email'), new Assert\Present('phone'), new Assert\Present('postCode'), new Assert\Present('line1'), new Assert\Email('email')]);
 }