コード例 #1
0
 public function testGetCompanyInfo()
 {
     $ready2order = new ready2orderAPI(getenv('R2O_USER_TOKEN'));
     $ready2order->setApiEndpoint(getenv('R2O_API'));
     $info = $ready2order->get('company');
     $this->assertArrayHasKey('company_name', $info);
 }
コード例 #2
0
 public function testInsertProduct()
 {
     $ready2order = new ready2orderAPI(getenv('R2O_USER_TOKEN'));
     $ready2order->setApiEndpoint(getenv('R2O_API'));
     // INSERT PRODUCTGROUP
     $productGroup = $ready2order->put('productgroups', array("productgroup_name" => "PHPUnit Testproductgroup"));
     $this->assertArrayHasKey("productgroup_name", $productGroup);
     // INSERT PRODUCT
     $product = $ready2order->put('products', array("product_name" => "PHPUnit Testproduct", "product_price" => 20.09, "product_vat" => 20, "productgroup" => array("productgroup_id" => $productGroup["productgroup_id"])));
     $this->assertArrayHasKey("product_name", $product);
     // UPDATE PRODUCT
     // TEST FOR NORMAL VALUES
     $testValues = array();
     $testValues["product_vat"] = 10;
     $testValues["product_price"] = 2009.91;
     $testValues["product_stock_value"] = 12.5;
     $testValues["product_stock_enabled"] = 1;
     $testValues["product_description"] = "ready2order API tested successfully!";
     $testValues["product_itemnumber"] = "PHP15XX";
     $testValues["product_barcode"] = "1234567890";
     // START TEST
     $product = $ready2order->post("products/{$product["product_id"]}", array("product_price" => $testValues["product_price"], "product_vat" => $testValues["product_vat"], "product_stock_enabled" => $testValues["product_stock_enabled"], "product_stock_value" => $testValues["product_stock_value"]));
     $this->assertArrayHasKey("product_name", $product);
     $this->assertEquals($testValues["product_price"], $product["product_price"]);
     $this->assertEquals($testValues["product_vat"], $product["product_vat"]);
     $this->assertEquals($testValues["product_stock_value"], $product["product_stock_value"]);
     $this->assertEquals($testValues["product_stock_enabled"], $product["product_stock_enabled"]);
     // UPDATE PRODUCT
     // TEST FOR BAD VALUES
     $product = $ready2order->post("products/{$product["product_id"]}", array("product_price" => "bad price", "product_vat" => "bad value", "product_stock_enabled" => 5, "product_stock_value" => "bad value"));
     $this->assertArrayHasKey("product_name", $product);
     $this->assertEquals($testValues["product_price"], $product["product_price"]);
     $this->assertEquals($testValues["product_vat"], $product["product_vat"]);
     $this->assertEquals($testValues["product_stock_value"], $product["product_stock_value"]);
     $this->assertEquals($testValues["product_stock_enabled"], $product["product_stock_enabled"]);
     // TESTING AGAIN GOOD VALUES
     $product = $ready2order->post("products/{$product["product_id"]}", array("product_description" => $testValues["product_description"], "product_itemnumber" => $testValues["product_itemnumber"], "product_barcode" => $testValues["product_barcode"]));
     $this->assertArrayHasKey("product_name", $product);
     $this->assertEquals($testValues["product_description"], $product["product_description"]);
     $this->assertEquals($testValues["product_itemnumber"], $product["product_itemnumber"]);
     $this->assertEquals($testValues["product_barcode"], $product["product_barcode"]);
     // DELETE PRODUCT
     $deleted = $ready2order->delete("products/{$product["product_id"]}");
     $this->assertEquals(true, $deleted["success"]);
     // DELETE PRODUCTGROUP
     $deleted = $ready2order->delete("productgroups/{$productGroup["productgroup_id"]}");
     $this->assertEquals(true, $deleted["success"]);
 }
コード例 #3
0
 public function testInstantiation()
 {
     $ready2order = new ready2orderAPI(getenv('R2O_USER_TOKEN'));
     $ready2order->setApiEndpoint(getenv('R2O_API'));
     $this->assertInstanceOf('\\ready2order\\ready2orderAPI', $ready2order);
 }