Ejemplo n.º 1
0
 /**
  * @depends testGetByFamily
  */
 public function testCreateProduct()
 {
     $controller = Factory::build('product', $GLOBALS['chargify_domain'], $GLOBALS['chargify_api_key']);
     $products = $controller->getAll();
     $data = array('product' => array('name' => 'Basic Plan 123', 'handle' => 'basic', 'description' => 'This is our basic plan.', 'accounting_code' => '123', 'request_credit_card' => true, 'price_in_cents' => 1000, 'interval' => 1, 'interval_unit' => 'month'));
     $response = $controller->create($products[0]->product_family->id, $data);
     $this->assertNotNull($response);
     $this->assertInstanceOf('Chargify\\Resource\\ProductResource', $response);
 }
Ejemplo n.º 2
0
 /**
  * @depends testDomainIsSet
  * @depends testApiKeyIsSet
  */
 public function testCanCreateController()
 {
     $resource_types = ['component', 'coupon', 'customer', 'product', 'subscription', 'transaction'];
     foreach ($resource_types as $type) {
         // Just take product as they are all the same.
         $controller = Factory::build($type, $GLOBALS['chargify_domain'], $GLOBALS['chargify_api_key']);
         $this->assertInstanceOf('Chargify\\Controller\\' . ucfirst($type), $controller, 'Can not initialize controller.');
     }
 }
Ejemplo n.º 3
0
 /**
  * @depends testGetByFamily
  */
 public function testCreateProduct()
 {
     $controller = Factory::build('product', $GLOBALS['chargify_domain'], $GLOBALS['chargify_api_key']);
     $products = $controller->getAll();
     $response = null;
     // Check if this test product already exists.
     try {
         $response = $controller->getByHandle('basic');
     } catch (\Guzzle\Http\Exception\ClientErrorResponseException $e) {
     }
     // Doesn't exist, so let's create it.
     if ($response == null) {
         $data = ['product' => ['name' => 'Test Basic Plan', 'handle' => 'basic', 'description' => 'This is our basic plan description.', 'accounting_code' => '123', 'request_credit_card' => true, 'price_in_cents' => 1000, 'interval' => 1, 'interval_unit' => 'month']];
         $response = $controller->create($products[0]->product_family->id, $data);
     }
     $this->assertNotNull($response, 'Response is empty');
     $this->assertInstanceOf('Chargify\\Resource\\ProductResource', $response, 'Response is not a product resource.');
 }