Fix assigment order issues
This commit is contained in:
@@ -16,10 +16,10 @@ class Wiaas_Package_Addon_Test extends Wiaas_Unit_Test_Case {
|
||||
* @covers Wiaas_Package_Addon::get_package_addons()
|
||||
*/
|
||||
function test_adding_package_addons() {
|
||||
$package = $this->create_new_package();
|
||||
$package = $this->factory->product->create_product_bundle();
|
||||
|
||||
$addon1 = $this->create_new_package();
|
||||
$addon2 = $this->create_new_package();
|
||||
$addon1 = $this->factory->product->create_product_bundle();
|
||||
$addon2 = $this->factory->product->create_product_bundle();
|
||||
$addons_ids = array(
|
||||
$addon1->get_id(),
|
||||
$addon2->get_id()
|
||||
|
||||
@@ -16,12 +16,12 @@ class Wiaas_Package_Option_Groups_Test extends Wiaas_Unit_Test_Case {
|
||||
* @covers Wiaas_Package_Option_Groups::get_package_option_groups()
|
||||
*/
|
||||
function test_adding_package_option_group() {
|
||||
$package = $this->create_new_package();
|
||||
$package = $this->factory->product->create_product_bundle();
|
||||
|
||||
$option_package1 = $this->create_new_package();
|
||||
$option_package1 = $this->factory->product->create_product_bundle();
|
||||
Wiaas_Package_Type::set_package_type($option_package1->get_id(), 'option');
|
||||
|
||||
$option_package2 = $this->create_new_package();
|
||||
$option_package2 = $this->factory->product->create_product_bundle();
|
||||
Wiaas_Package_Type::set_package_type($option_package2->get_id(), 'option');
|
||||
|
||||
$option_group1 = array(
|
||||
@@ -79,9 +79,9 @@ class Wiaas_Package_Option_Groups_Test extends Wiaas_Unit_Test_Case {
|
||||
* @covers Wiaas_Package_Option_Groups::get_group_name_for_package_option()
|
||||
*/
|
||||
function test_get_group_name_for_package_option() {
|
||||
$package = $this->create_new_package();
|
||||
$package = $this->factory->product->create_product_bundle();
|
||||
|
||||
$option_package = $this->create_new_package();
|
||||
$option_package = $this->factory->product->create_product_bundle();
|
||||
Wiaas_Package_Type::set_package_type($option_package->get_id(), 'option');
|
||||
|
||||
$option_group = array(
|
||||
|
||||
@@ -16,6 +16,7 @@ class Wiaas__Package_Status_Test extends Wiaas_Unit_Test_Case {
|
||||
$this->assertNotEmpty($package_statuses);
|
||||
|
||||
$this->assertContains(Wiaas_Package_Status::AVAILABLE, $package_statuses);
|
||||
$this->assertContains(Wiaas_Package_Status::INVALID_MARGIN, $package_statuses);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -23,7 +24,7 @@ class Wiaas__Package_Status_Test extends Wiaas_Unit_Test_Case {
|
||||
* @covers Wiaas_Package_Type::get_package_status()
|
||||
*/
|
||||
function test_adding_package_status() {
|
||||
$package = $this->create_new_package();
|
||||
$package = $this->factory->product->create_product_bundle();
|
||||
|
||||
Wiaas_Package_Status::set_package_status($package->get_id(), Wiaas_Package_Status::AVAILABLE);
|
||||
|
||||
@@ -37,15 +38,15 @@ class Wiaas__Package_Status_Test extends Wiaas_Unit_Test_Case {
|
||||
* Test package status update on simple product price update
|
||||
*/
|
||||
function test_package_status_update_on_simple_product_price_update() {
|
||||
$product1 = $this->create_new_product(20);
|
||||
$this->add_product_category($product1, 'hardware');
|
||||
|
||||
$product2 = $this->create_new_product(20);
|
||||
$this->add_product_category($product2, 'software');
|
||||
$product1 = $this->factory->product->create_simple_product(array( 'price' => 20, 'category' => 'hardware' ));
|
||||
|
||||
$package = $this->create_new_package();
|
||||
|
||||
$this->add_products_to_package($package, array( $product1, $product2));
|
||||
$package = $this->factory->product->create_product_bundle(array(
|
||||
'products' => array(
|
||||
$product1,
|
||||
$this->factory->product->create_simple_product(array( 'price' => 20, 'category' => 'software' ))
|
||||
)
|
||||
));
|
||||
|
||||
$pricing_rules = array(
|
||||
'purchase' => array(
|
||||
@@ -68,10 +69,13 @@ class Wiaas__Package_Status_Test extends Wiaas_Unit_Test_Case {
|
||||
$cost_margin = 100;
|
||||
|
||||
Wiaas_Package_Pricing::set_package_prices($package, $pricing_rules, $commision, $cost_margin);
|
||||
$this->assertEquals(Wiaas_Package_Status::get_package_status($package)->get_id(), Wiaas_Package_Status::AVAILABLE);
|
||||
$this->assertEquals(Wiaas_Package_Status::get_package_status($package->get_id()), Wiaas_Package_Status::AVAILABLE);
|
||||
|
||||
$product1->set_price(1000);
|
||||
$this->assertEquals(Wiaas_Package_Status::get_package_status($package)->get_id(), Wiaas_Package_Status::MARGIN_EXCEEDED);
|
||||
$this->factory->product->set_product_price($product1, 1000);
|
||||
|
||||
Wiaas_Package_Pricing::on_product_update($product1->get_id());
|
||||
|
||||
$this->assertEquals(Wiaas_Package_Status::get_package_status($package->get_id()), Wiaas_Package_Status::INVALID_MARGIN);
|
||||
|
||||
}
|
||||
|
||||
@@ -79,15 +83,12 @@ class Wiaas__Package_Status_Test extends Wiaas_Unit_Test_Case {
|
||||
* Test package status update on cost margin update
|
||||
*/
|
||||
function test_package_status_update_on_margin_cost_update() {
|
||||
$product1 = $this->create_new_product(20);
|
||||
$this->add_product_category($product1, 'hardware');
|
||||
|
||||
$product2 = $this->create_new_product(20);
|
||||
$this->add_product_category($product2, 'software');
|
||||
|
||||
$package = $this->create_new_package();
|
||||
|
||||
$this->add_products_to_package($package, array( $product1, $product2));
|
||||
$package = $this->factory->product->create_product_bundle(array(
|
||||
'products' => array(
|
||||
$this->factory->product->create_simple_product(array( 'price' => 20, 'category' => 'hardware' )),
|
||||
$this->factory->product->create_simple_product(array( 'price' => 20, 'category' => 'software' ))
|
||||
)
|
||||
));
|
||||
|
||||
$pricing_rules = array(
|
||||
'purchase' => array(
|
||||
@@ -108,13 +109,14 @@ class Wiaas__Package_Status_Test extends Wiaas_Unit_Test_Case {
|
||||
);
|
||||
$commision = 50;
|
||||
$cost_margin = 0;
|
||||
|
||||
|
||||
Wiaas_Package_Pricing::set_package_prices($package, $pricing_rules, $commision, $cost_margin);
|
||||
$this->assertEquals(Wiaas_Package_Status::get_package_status($package)->get_id(), Wiaas_Package_Status::AVAILABLE);
|
||||
$this->assertEquals(Wiaas_Package_Status::get_package_status($package->get_id()), Wiaas_Package_Status::AVAILABLE);
|
||||
|
||||
$cost_margin = 1;
|
||||
Wiaas_Package_Pricing::set_package_prices($package, $pricing_rules, $commision, $cost_margin);
|
||||
$this->assertEquals(Wiaas_Package_Status::get_package_status($package)->get_id(), Wiaas_Package_Status::MARGIN_EXCEEDED);
|
||||
|
||||
$this->assertEquals(Wiaas_Package_Status::get_package_status($package->get_id()), Wiaas_Package_Status::INVALID_MARGIN);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ class Wiaas__Package_Type_Test extends Wiaas_Unit_Test_Case {
|
||||
* @covers Wiaas_Package_Type::get_package_type()
|
||||
*/
|
||||
function test_adding_package_type() {
|
||||
$package = $this->create_new_package();
|
||||
$package = $this->factory->product->create_product_bundle();
|
||||
|
||||
Wiaas_Package_Type::set_package_type($package->get_id(), 'standard');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user