public function testCreateAndGetProductTemplateById() { $user = UserTestHelper::createBasicUser('Steven'); $product = ProductTestHelper::createProductByNameForOwner('Product 1', $user); $productTemplate = ProductTemplateTestHelper::createProductTemplateByVariables($product, ProductTemplate::PRICE_FREQUENCY_ONE_TIME, ProductTemplate::TYPE_PRODUCT, ProductTemplate::STATUS_ACTIVE, SellPriceFormula::TYPE_EDITABLE); $this->assertTrue($productTemplate->save()); $id = $productTemplate->id; $productTemplate->forget(); unset($productTemplate); $productTemplate = ProductTemplate::getById($id); $this->assertEquals('Red Widget', $productTemplate->name); $this->assertEquals('Description', $productTemplate->description); $this->assertEquals(ProductTemplate::PRICE_FREQUENCY_ONE_TIME, intval($productTemplate->priceFrequency)); $this->assertEquals(500.54, $productTemplate->cost->value); $this->assertEquals(400.54, $productTemplate->listPrice->value); $this->assertEquals(300.54, $productTemplate->sellPrice->value); $this->assertEquals(ProductTemplate::TYPE_PRODUCT, $productTemplate->type); $typeArray = ProductTemplateElementUtil::getProductTemplateTypeDropdownArray(); $statusArray = ProductTemplateElementUtil::getProductTemplateStatusDropdownArray(); $this->assertEquals("Product", $typeArray[$productTemplate->type]); $this->assertEquals(ProductTemplate::STATUS_ACTIVE, $productTemplate->status); $this->assertEquals("Active", $statusArray[$productTemplate->status]); $this->assertEquals($product, $productTemplate->products[0]); //$this->assertTrue($productTemplate->sellPriceFormula->isSame($sellPriceFormula)); $this->assertEquals($productTemplate->sellPriceFormula->type, SellPriceFormula::TYPE_EDITABLE); }
public function testGetProductTemplatePriceFrequencyDisplayedGridValue() { $super = User::getByUsername('super'); Yii::app()->user->userModel = $super; $productTemplate = ProductTemplateTestHelper::createProductTemplateByName('My Product Template 2'); $id = $productTemplate->id; $productTemplate->forget(); unset($productTemplate); $productTemplate = ProductTemplate::getById($id); $priceFrequency = ProductTemplateElementUtil::getProductTemplatePriceFrequencyDisplayedGridValue($productTemplate, 0); $this->assertEquals($priceFrequency, "Monthly"); }
protected function getDropDownArray() { return ProductTemplateElementUtil::getProductTemplatePriceFrequencyDropdownArray(); }
public function getDropDownArray() { return ProductTemplateElementUtil::getProductTemplateTypeDropdownArray(); }
public function __construct($modelClassName, $attributeName) { parent::__construct($modelClassName, $attributeName); $this->dropDownValues = ProductTemplateElementUtil::getProductTemplateTypeDropdownArray(); }
/** * @return array */ protected static function resolveDropDownArray() { return ProductTemplateElementUtil::getProductTemplateStatusDropdownArray(); }
/** * Registers the script required on usage of sell price formula */ protected function registerScripts() { Yii::app()->clientScript->registerScript('ShowHideDiscountOrMarkupPercentageTextField', ProductTemplateElementUtil::getShowHideDiscountOrMarkupPercentageTextFieldScript(), CClientScript::POS_END); Yii::app()->clientScript->registerScript('EnableDisableSellPriceElementBySellPriceFormula', ProductTemplateElementUtil::getEnableDisableSellPriceElementBySellPriceFormulaScript(), CClientScript::POS_END); Yii::app()->clientScript->registerScript('CalculateSellPriceBySellPriceFormula', ProductTemplateElementUtil::getCalculatedSellPriceBySellPriceFormulaScript(), CClientScript::POS_END); Yii::app()->clientScript->registerScript('BindActionsWithFormFieldsForSellPrice', ProductTemplateElementUtil::bindActionsWithFormFieldsForSellPrice(), CClientScript::POS_END); }
/** * @return array */ protected function getDropDownArray() { return ProductTemplateElementUtil::getProductTemplateStatusDropdownArray(); }
/** * @return array */ protected static function resolveDropDownArray() { return ProductTemplateElementUtil::getProductTemplatePriceFrequencyDropdownArray(); }