Fix tests

This commit is contained in:
Almira Krdzic
2018-10-15 05:06:46 +02:00
parent e810dd086a
commit f14d35b1aa
17 changed files with 245 additions and 77 deletions

View File

@@ -34,6 +34,19 @@ class Wiaas_Pricing_Test extends Wiaas_Unit_Test_Case {
$cost_margin = 0;
Wiaas_Package_Pricing::set_package_prices($package, $pricing_rules, $commision, $cost_margin);
$customer_id = wp_create_term(
'Customer',
Wiaas_User_Organization::TAXONOMY_NAME
)['term_id'];
$commercial_lead_id = wp_create_term(
'Commercial Lead',
Wiaas_User_Organization::TAXONOMY_NAME
)['term_id'];
self::_set_package_default_extras($commercial_lead_id, $package->get_id());
$expected_prices = array(
'purchase' => array(
'fixed_extra' => 100,
@@ -52,7 +65,32 @@ class Wiaas_Pricing_Test extends Wiaas_Unit_Test_Case {
)
);
return array( $package, $expected_prices );
return array( $package, $expected_prices, $customer_id, $commercial_lead_id );
}
private function _set_package_default_extras($commercial_lead_id, $package_id) {
$cl_extras = array(
'purchase_default' => array(
'fixed' => 0,
'recurrent' => 0,
'services' => 0,
'visible' => true
),
'purchase_24_default' => array(
'fixed' => 0,
'recurrent' => 0,
'services' => 0,
'visible' => true
),
'managed_36_default' => array(
'fixed' => 0,
'recurrent' => 0,
'services' => 0,
'visible' => true
)
);
Wiaas_Package_CL_Pricing::set_extras($commercial_lead_id, $package_id, $cl_extras);
}
/**
@@ -172,9 +210,12 @@ class Wiaas_Pricing_Test extends Wiaas_Unit_Test_Case {
*/
function test_get_standard_package_customer_price() {
list( $package, $expected_prices ) = $this->_create_package_to_sell();
list( $package, $expected_prices, $customer_id, $commercial_lead_id ) = $this->_create_package_to_sell();
$customer_prices = Wiaas_Pricing::get_standard_package_customer_prices($package);
$customer_prices = Wiaas_Pricing::get_standard_package_customer_prices(
$package,
$customer_id,
$commercial_lead_id);
$this->assertCount(3, $customer_prices);
@@ -203,7 +244,7 @@ class Wiaas_Pricing_Test extends Wiaas_Unit_Test_Case {
* @covers Wiaas_Pricing::get_addon_package_customer_price()
*/
function test_get_addon_package_customer_price() {
list( $package ) = $this->_create_package_to_sell();
list( $package, $expected_prices, $customer_id, $commercial_lead_id ) = $this->_create_package_to_sell();
$addon_product = $this->create_new_product(20);
$this->add_product_category($addon_product, 'hardware');
@@ -233,6 +274,8 @@ class Wiaas_Pricing_Test extends Wiaas_Unit_Test_Case {
$cost_margin = 0;
Wiaas_Package_Pricing::set_package_prices($addon_package, $pricing_rules, $commision, $cost_margin);
self::_set_package_default_extras($commercial_lead_id, $addon_package->get_id());
Wiaas_Package_Addon::set_package_addons($package, array($addon_package->get_id()));
$expected_prices = array(
@@ -253,7 +296,11 @@ class Wiaas_Pricing_Test extends Wiaas_Unit_Test_Case {
)
);
$customer_prices = Wiaas_Pricing::get_addon_package_customer_price($addon_package, $package);
$customer_prices = Wiaas_Pricing::get_addon_package_customer_price(
$addon_package,
$package,
$customer_id,
$commercial_lead_id);
$this->assertCount(3, $customer_prices);
@@ -281,7 +328,7 @@ class Wiaas_Pricing_Test extends Wiaas_Unit_Test_Case {
* @covers Wiaas_Pricing::get_option_package_customer_price()
*/
function test_get_option_package_customer_price() {
list( $package ) = $this->_create_package_to_sell();
list( $package, $customer_id, $commercial_lead_id ) = $this->_create_package_to_sell();
$option_product = $this->create_new_product(20);
$this->add_product_category($option_product, 'hardware');
@@ -311,6 +358,8 @@ class Wiaas_Pricing_Test extends Wiaas_Unit_Test_Case {
$cost_margin = 0;
Wiaas_Package_Pricing::set_package_prices($option_package, $pricing_rules, $commision, $cost_margin);
self::_set_package_default_extras($commercial_lead_id, $option_package->get_id());
Wiaas_Package_Option_Groups::set_package_option_groups($package, array(
'id' => 'option',
'name' => 'Option',
@@ -336,7 +385,11 @@ class Wiaas_Pricing_Test extends Wiaas_Unit_Test_Case {
)
);
$customer_prices = Wiaas_Pricing::get_option_package_customer_price($option_package, $package);
$customer_prices = Wiaas_Pricing::get_option_package_customer_price(
$option_package,
$package,
$customer_id,
$commercial_lead_id);
$this->assertCount(3, $customer_prices);