$t->diag('************************'); $t->diag('*** Promotions tools ***'); $t->diag('************************'); $promotions1 = array('id' => 1, 'stackable' => false, 'date_from' => date("Y-m-d H:i:s", strtotime(sprintf("-%s months", 2))), 'date_to' => date("Y-m-d H:i:s", strtotime(sprintf("+%s months", 1))), 'total_from' => 100.0, 'total_to' => 200.0, 'reduction_type' => 'percentageOff', 'reduction_value' => 10.0, 'title' => 'Summer Sale', 'comment' => ''); $promotions2 = array('id' => 2, 'stackable' => false, 'date_from' => date("Y-m-d H:i:s", strtotime(sprintf("-%s months", 2))), 'date_to' => date("Y-m-d H:i:s", strtotime(sprintf("+%s months", 1))), 'total_from' => 150.0, 'total_to' => 200.0, 'reduction_type' => 'percentageOff', 'reduction_value' => 15.0, 'title' => 'Summer Sale', 'comment' => ''); $promotions3 = array('id' => 3, 'stackable' => false, 'date_from' => date("Y-m-d H:i:s", strtotime(sprintf("+%s months", 1))), 'date_to' => date("Y-m-d H:i:s", strtotime(sprintf("+%s months", 3))), 'total_from' => 120.0, 'total_to' => 200.0, 'reduction_type' => 'percentageOff', 'reduction_value' => 8.0, 'title' => 'Summer Sale', 'comment' => ''); $promotions4 = array('id' => 3, 'stackable' => false, 'date_from' => date("Y-m-d H:i:s", strtotime(sprintf("-%s months", 1))), 'date_to' => date("Y-m-d H:i:s", strtotime(sprintf("+%s months", 1))), 'total_from' => null, 'total_to' => 100.0, 'reduction_type' => 'dollarOff', 'reduction_value' => 5.0, 'title' => 'Summer Sale', 'comment' => ''); $promotions = array($promotions2, $promotions1, $promotions3, $promotions4); $t->diag('Array - Ordered promotions by saving'); $promotions = rtShopPromotionToolkit::orderPromotionsBySaving($promotions, 80); //print_r($promotions); $t->is(isset($promotions[0]['reduced_total']), true, '::orderPromotionsBySaving() Array has a reduced_total attribute.'); $t->is($promotions[0]['id'], 2, '::orderPromotionsBySaving() Array appears to sorted correctly by reduced_total.'); $t->is($promotions[0]['reduced_total'], 68, '::orderPromotionsBySaving() Array appears to sorted correctly ascending by reduced_total.'); $t->diag('Array - Ordered promotions by total'); $promotions = rtShopPromotionToolkit::orderPromotionsByTotalFrom($promotions, 80); //print_r($promotions); $t->is(isset($promotions[0]['distance_to']), true, '::orderPromotionsByTotalFrom() Array has a distance_to attribute.'); $t->is($promotions[0]['id'], 1, '::orderPromotionsByTotalFrom() Array appears to sorted correctly by distance_to.'); $t->is($promotions[0]['distance_to'], 20, '::orderPromotionsByTotalFrom() Array appears to sorted correctly ascending by distance_to.'); unset($promotions, $promotions1, $promotions2, $promotions3, $promotions4); // Add promotions data try { rtShopPromotionTestTools::clean(); $i3 = new rtShopPromotionCart(); $i3->setTitle('Combinations'); $i3->setDateTo(date('Y-m-d H:i:s', strtotime(sprintf("+%s months", 2)))); $i3->setTotalFrom(100); $i3->setTotalTo(200); $i3->setReductionType('percentageOff'); $i3->setReductionValue(10);