/** * Tests price calculation * * @dataProvider providerPrice * * @param array $aTestCase */ public function testPrice($aTestCase) { if ($aTestCase['skipped'] == 1) { $this->markTestSkipped("testcase is skipped"); } // gather data from test case $aExpected = $aTestCase['expected']; // load calculated basket from provided data $oConstruct = new BasketConstruct(); // create shops $iActiveShopId = $oConstruct->createShop($aTestCase['shop']); // create user if specified $oUser = $oConstruct->createObj($aTestCase['user'], "oxuser", "oxuser"); // create group and assign $oConstruct->createGroup($aTestCase['group']); // user login if ($oUser) { $oUser->login($aTestCase['user']['oxusername'], ''); } // setup options $oConstruct->setOptions($aTestCase['options']); // create categories $oConstruct->setCategories($aTestCase['categories']); // create articles $articlesData = $oConstruct->getArticles($aTestCase['articles']); // apply discounts $oConstruct->setDiscounts($aTestCase['discounts']); // set active shop if ($iActiveShopId != 1) { $oConstruct->setActiveShop($iActiveShopId); } // iteration through expectations foreach ($articlesData as $articleData) { $expected = $aExpected[$articleData['id']]; if (empty($expected)) { continue; } $article = oxNew('oxArticle'); $article->load($articleData['id']); $this->assertEquals($expected['base_price'], $this->getFormatted($article->getBasePrice()), "Base Price of article #{$articleData['id']}"); $this->assertEquals($expected['price'], $article->getFPrice(), "Price of article #{$articleData['id']}"); if (isset($expected['rrp_price'])) { $this->assertEquals($expected['rrp_price'], $article->getFTPrice(), "RRP price of article #{$articleData['id']}"); } if (isset($expected['unit_price'])) { $this->assertEquals($expected['unit_price'], $article->getFUnitPrice(), "Unit Price of article #{$articleData['id']}"); } if (isset($expected['is_range_price'])) { $this->assertEquals($expected['is_range_price'], $article->isRangePrice(), "Is range price check of article #{$articleData['id']}"); } if (isset($expected['min_price'])) { $this->assertEquals($expected['min_price'], $article->getFMinPrice(), "Min price of article #{$articleData['id']}"); } if (isset($expected['var_min_price'])) { $this->assertEquals($expected['var_min_price'], $article->getFVarMinPrice(), "Var min price of article #{$articleData['id']}"); } if (isset($expected['show_rrp'])) { $blShowRPP = false; if ($article->getTPrice() && $article->getTPrice()->getPrice() > $article->getPrice()->getPrice()) { $blShowRPP = true; } $this->assertEquals($expected['show_rrp'], $blShowRPP, "RRP price showing of article #{$articleData['id']}"); } } }