public static function makeRequiredEntities()
 {
     $useExistingOrMakeNew = function ($entityClass, $model) {
         $name = $model->name;
         try {
             if ($entityClass === Bf_ProductRatePlan::getClassName()) {
                 $existing = Bf_ProductRatePlan::getByProductAndRatePlanID($model->productID, $name);
             } else {
                 $existing = $entityClass::getByID($name);
             }
             if ($existing) {
                 return $existing;
             }
         } catch (Bf_NoMatchingEntityException $e) {
             return $entityClass::create($model);
         }
     };
     $models = array('uom' => array(Models::UnitOfMeasure(), Models::UnitOfMeasure2(), Models::UnitOfMeasure2()), 'product' => Models::MonthlyRecurringProduct(), 'pricingComponentTierLists' => array(Models::PricingComponentTiers(), Models::PricingComponentTiers2(), Models::PricingComponentTiers2()));
     $created = array('uom' => array($useExistingOrMakeNew(Bf_UnitOfMeasure::getClassName(), $models['uom'][0]), $useExistingOrMakeNew(Bf_UnitOfMeasure::getClassName(), $models['uom'][1])), 'product' => $useExistingOrMakeNew(Bf_Product::getClassName(), $models['product']));
     // having created product, make rate plan for it
     $models['pricingComponents'] = array(Models::PricingComponent($created['uom'][0], $models['pricingComponentTierLists'][0]), Models::PricingComponent2($created['uom'][1], $models['pricingComponentTierLists'][1]), Models::PricingComponent3($created['uom'][1], $models['pricingComponentTierLists'][1]));
     $models['ratePlan'] = Models::ProductRatePlan($created['product'], $models['pricingComponents']);
     $created['ratePlan'] = $useExistingOrMakeNew(Bf_ProductRatePlan::getClassName(), $models['ratePlan']);
     self::$models = $models;
     self::$created = $created;
 }
Example #2
0
 public function testCreateWithProfileAndAddress()
 {
     $account = Models::Account();
     $createdAccount = Bf_Account::create($account);
     $actual = $createdAccount;
     $this->assertNotNull($actual, "Nested entity created correctly.");
 }
Example #3
0
 /**
  * @depends testEnsureGatewayExists
  */
 public function testCreateWithProfile()
 {
     $createdAccount = Bf_Account::create(Models::Account());
     $actual = $createdAccount->profile;
     $this->assertNotNull($actual, "Nested entity introduced correctly.");
     self::$createdAccount = $createdAccount;
 }
Example #4
0
 public static function makeRequiredEntities()
 {
     $models = array('account' => Models::AccountWithJustProfile());
     $created = array('account' => Bf_Account::create($models['account']));
     self::$models = $models;
     self::$created = $created;
 }
Example #5
0
 public function testCreate()
 {
     $product = Models::MonthlyNonRecurringProduct();
     self::$productDescription = $product->description;
     $uniqueString = time();
     $name = "TEST_{$uniqueString}";
     $product->name = $name;
     self::$createdProduct = Bf_Product::create($product);
     $expected = self::$productDescription;
     $actual = self::$createdProduct->description;
     $this->assertEquals($expected, $actual, "Entity has expected field with known value.");
     $expected = Bf_Product::getResourcePath()->getEntityName();
     $actual = self::$createdProduct['@type'];
     $this->assertEquals($expected, $actual, "Type of any returned entity matches known value.");
 }