Files
old-new-wiaas/backend/app/plugins/wiaas/tests/unit-tests/pricing/test-wiaas-package-pricing.php
2018-12-02 22:18:09 +01:00

64 lines
2.3 KiB
PHP

<?php
class Wiaas_Package_Pricing_Test extends Wiaas_Unit_Test_Case {
/**
* @covers Wiaas_Package_Pricing::set_package_prices()
* @covers Wiaas_Package_Pricing::get_package_prices()
*/
function test_set_and_get_package_prices() {
$package = $this->factory->product->create_product_bundle();
$pricing_rules = array(
'purchase' => array(
'minimal_fixed_price' => 10,
'principal_amount' => 0,
'minimal_services_price' => 0
),
'purchase_24' => array(
'minimal_fixed_price' => 10,
'principal_amount' => 0,
'minimal_services_price' => 10
),
'managed_36' => array(
'minimal_fixed_price' => 10,
'principal_amount' => 10,
'minimal_services_price' => 10
)
);
$commision = 60;
$cost_margin = 0;
Wiaas_Package_Pricing::set_package_prices($package, $pricing_rules, $commision, $cost_margin);
$configured_prices = Wiaas_Package_Pricing::get_package_prices($package);
$this->assertCount(3, $configured_prices);
$this->assertArrayHasKey('purchase', $configured_prices);
$this->assertArrayHasKey('purchase_24', $configured_prices);
$this->assertArrayHasKey('managed_36', $configured_prices);
foreach ($configured_prices as $type => $configured_price) {
$this->assertArrayHasKey('id', $configured_price);
$this->assertArrayHasKey('payment_type', $configured_price);
$this->assertArrayHasKey('max_contract_period', $configured_price);
$this->assertArrayHasKey('package_pay_period', $configured_price);
$this->assertArrayHasKey('period_unit', $configured_price);
$this->assertArrayHasKey('services_contract_period', $configured_price);
$this->assertArrayHasKey('commision_split', $configured_price);
$this->assertArrayHasKey('minimal_fixed_price', $configured_price);
$this->assertArrayHasKey('principal_amount', $configured_price);
$this->assertArrayHasKey('minimal_services_price', $configured_price);
$this->assertEquals($configured_price['id'], $type);
$this->assertEquals($configured_price['minimal_fixed_price'], $pricing_rules[$type]['minimal_fixed_price']);
$this->assertEquals($configured_price['principal_amount'], $pricing_rules[$type]['principal_amount']);
$this->assertEquals($configured_price['minimal_services_price'], $pricing_rules[$type]['minimal_services_price']);
}
}
}