/**
  * Check getting page ID
  *
  * @since 1.1.0
  *
  * @group group
  * @group destination
  *
  * \ingot\testing\utility\destination::get_page_id()
  */
 public function testGetPageID()
 {
     $data = ingot_test_desitnation::create('page', true);
     $group = \ingot\testing\crud\group::read($data['group_ID']);
     $this->assertSame($data['page'], \ingot\testing\utility\destination::get_page_id($group));
 }
 /**
  *
  *
  * @since 1.1.0
  *
  * @group group
  * @group destination
  * @group cookie
  * @group destination_cookie
  *
  * @covers \ingot\testing\tests\click\destination\init::get_test()
  * @covers \ingot\testing\tests\click\destination\init::set_tracking()
  * @covers \ingot\testing\tests\click\destination\cookie::get_cookie()
  */
 public function testCookieTracking()
 {
     $data = ingot_test_desitnation::create('page');
     $group_id = $data['group_ID'];
     $this->assertTrue(is_numeric($group_id));
     $group = \ingot\testing\crud\group::read($group_id);
     $this->assertInternalType('array', $group);
     $bandit = new \ingot\testing\bandit\content($group_id);
     $variant_id = $bandit->choose();
     $this->assertTrue(is_numeric($variant_id));
     \ingot\testing\tests\click\destination\init::set_tracking();
     \ingot\testing\tests\click\destination\init::get_test($group_id);
     $obj = new \ingot\testing\object\group($group_id);
     $levers = $obj->get_levers();
     $this->assertInternalType('array', $levers);
     $cookie_name = \ingot\testing\tests\click\destination\cookie::cookie_key($group_id);
     $variant_id = \ingot\testing\tests\click\destination\init::get_test($group_id);
     $this->assertTrue(is_numeric($variant_id));
     $_COOKIE[$cookie_name] = $variant_id;
     $this->assertEquals($variant_id, \ingot\testing\tests\click\destination\cookie::get_cookie($group_id));
     $obj = new \ingot\testing\object\group($group_id);
     $_levers = $obj->get_levers();
     for ($i = 0; $i <= 10; $i++) {
         \ingot\testing\tests\click\destination\init::set_tracking();
     }
     $obj = new \ingot\testing\object\group($group_id);
     $levers = $obj->get_levers();
     $this->assertEquals($levers, $_levers);
     $this->assertInternalType('array', $levers);
     $this->assertArrayHasKey($group_id, $levers);
     $this->assertArrayHasKey($variant_id, $levers[$group_id]);
     $lever = $levers[$variant_id];
     $this->assertInternalType('object', $lever);
     $this->assertEquals(0, $lever->getNumerator());
     $this->assertEquals(1, $lever->getDenominator());
 }
 /**
  * Track EDD sale conversions
  *
  * @since 1.1.0
  *
  * @group group
  * @group destination
  * @group edd
  *
  * @covers  \ingot\testing\tests\click\destination\hooks::edd_complete_purchase()
  * @covers  \ingot\testing\tests\click\destination\hooks::add_hooks()
  */
 public function testEDDConversionsSale()
 {
     if (ingot_is_edd_active()) {
         $this->assertTrue(\ingot\testing\tests\click\destination\types::allowed_destination_type('sale_edd'));
         $product = ingot_test_data_price::edd_create_simple_download(10);
         $data = ingot_test_desitnation::create('sale_edd');
         $group_id = $data['group_ID'];
         $this->assertTrue(is_numeric($group_id));
         $variants = $data['variants'];
         new \ingot\testing\bandit\content($group_id);
         $variant_id = \ingot\testing\tests\click\destination\init::get_test($group_id);
         $this->assertTrue(is_numeric($variant_id));
         \ingot\testing\tests\click\destination\init::set_tracking();
         $this->assertTrue(in_array(\ingot\testing\tests\click\destination\init::get_test($group_id), $variants));
         $variant_id = \ingot\testing\tests\click\destination\init::get_test($group_id);
         $hooks = new \ingot\testing\tests\click\destination\hooks([$group_id]);
         $payment_id = ingot_test_data_price::edd_create_simple_payment($product);
         edd_complete_purchase($payment_id, 'publish', 'pending');
         $group = \ingot\testing\crud\group::read($group_id);
         $totals = \ingot\testing\utility\group::get_total($group);
         $this->assertEquals(3, $totals['total']);
         $this->assertEquals(2, $totals['conversions']);
     }
 }