Exemple #1
0
 /**
  * Generic getter for tests of both types
  *
  * @param int $id Test ID
  * @param string $what Optional. Which kind of test. Defaults to click
  *
  * @return array|bool
  */
 public static function test($id, $what = 'click')
 {
     if (self::is_price($what)) {
         return price_test::read($id);
     }
     return test::read($id);
 }
Exemple #2
0
 /**
  * Prepare price test details needed for use in cookies/tracking
  *
  * @since 0.2.0
  *
  * @param array $price_test Price test config
  * @param string $a_or_b a|b
  * @param int $sequence_id Sequence ID
  * @param int $group_id Group ID
  *
  * @return array
  */
 public static function price_detail($price_test, $a_or_b, $sequence_id, $group_id)
 {
     if (is_numeric($price_test)) {
         $price_test = price_test::read($price_test);
     }
     if (is_numeric($group_id)) {
         $group = group::read($group_id);
     } elseif (is_array($group_id)) {
         $group = $group_id;
         $group_id = helpers::v('ID', $group, 0);
     } else {
         return array();
     }
     if (!is_array($price_test) || !is_array($group)) {
         return array();
     }
     $details = array('plugin' => $group['plugin'], 'product_ID' => $price_test['product_ID'], 'test_ID' => $price_test['ID'], 'sequence_ID' => $sequence_id, 'group_ID' => $group_id, 'a_or_b' => $a_or_b);
     return $details;
 }
Exemple #3
0
 /**
  * Check price detail util
  *
  * @since 0.2.0
  *
  * @covers \ingot\testing\utility\price::price_detail()
  */
 function testPriceDetails()
 {
     return;
     $product_id = 9;
     $params = array('product_ID' => $product_id, 'default' => rand(-0.9, 0.9));
     for ($i = 0; $i <= 3; $i++) {
         $id = \ingot\testing\crud\price_test::create($params);
         $tests[$i] = $id;
         $params['default'] = rand(-0.9, 0.9);
     }
     $params = array('type' => 'price', 'plugin' => 'edd', 'group_name' => rand(), 'test_order' => $tests, 'product_ID' => $product_id);
     $group_id = \ingot\testing\crud\price_group::create($params);
     $group = \ingot\testing\crud\price_group::read($group_id);
     $sequence_id = $group['current_sequence'];
     $test = \ingot\testing\crud\price_test::read($tests[rand(0, 3)]);
     $details = \ingot\testing\utility\price::price_detail($test, 'a', $sequence_id, $group_id);
     $this->assertEquals($details['plugin'], $test['plugin']);
     $this->assertEquals($details['product_ID'], $test['product_ID']);
     $this->assertEquals($details['test_ID'], $test['ID']);
     $this->assertEquals($details['sequence_ID'], $sequence_id);
     $this->assertEquals($details['group_ID'], $group_id);
 }
Exemple #4
0
 /**
  * Set the test property of this class
  *
  * @since 0.0.9
  *
  * @access private
  *
  * @param int|array $test
  */
 private function set_test($test)
 {
     if (is_numeric($test)) {
         $this->test = price_test::read($test);
     } elseif (is_array($test)) {
         //@todo allow this once validation is in place
         //$this->test = $test;
     }
 }