예제 #1
0
파일: set.php 프로젝트: rene-hermenau/ingot
 /**
  * Set the actual cookies
  *
  * @since 1.1.0
  *
  * @param \ingot\testing\cookies\init $cookies Cookies init class
  */
 public static function setup_cookies($cookies)
 {
     if (!empty($cookies->get_ingot_cookie(false))) {
         $cookie_time = ingot_cookie_time();
         $cookie_name = $cookies->get_cookie_name();
         setcookie($cookie_name, $cookies->get_ingot_cookie(true), time() + $cookie_time, COOKIEPATH, COOKIE_DOMAIN, false);
     }
 }
예제 #2
0
파일: set.php 프로젝트: rene-hermenau/ingot
 /**
  * Run all parts of cookie/price tests setup
  *
  * @since 1.1.0
  *
  * @return bool
  */
 public static function run()
 {
     if (false == ingot_is_front_end()) {
         return false;
     }
     $all_cookies = $cookies = array();
     if (INGOT_DEV_MODE) {
         if (isset($_COOKIE) && is_array($_COOKIE)) {
             $all_cookies = $_COOKIE;
         }
         $cookies = init::create($all_cookies);
         self::setup_cookies($cookies);
     }
     /**
      * Fires after Ingot Cookies Are Set
      *
      * Note: will fire if they were set empty
      * Should happen at init:25
      *
      * @since 0.0.9
      *
      * @param \ingot\testing\cookies\init $cookies Cookies object
      */
     do_action('ingot_cookies_set', $cookies);
     return true;
 }
예제 #3
0
 /**
  * Test price testing setup
  *
  * @since 1.1.0
  *
  * @group cookie
  * @group price_cookie
  * @group price
  *
  *
  * @covers \ingot\testing\cookies\set::price_testing()
  */
 public function testRunPriceTests()
 {
     return;
     $this->assertFalse((bool) did_action('ingot_loaded'));
     $group_1 = ingot_test_data_price::edd_tests(10);
     $group_2 = ingot_test_data_price::edd_tests(15);
     $product_1 = $group_1['product_ID'];
     $product_2 = $group_2['product_ID'];
     $cookies = \ingot\testing\cookies\init::create([]);
     $this->assertFalse(is_wp_error($cookies));
     $ingot_cookies = $cookies->get_ingot_cookie(false);
     $this->assertInternalType('array', $ingot_cookies);
     $this->assertArrayHasKey('edd', $ingot_cookies);
     $objects = \ingot\testing\cookies\set::price_testing($ingot_cookies);
     $this->assertArrayHasKey('edd', $objects);
     $this->assertInternalType('object', $objects['edd']);
     /** @var ingot\testing\tests\price\plugins\edd $edd */
     $edd = $objects['edd'];
     $products = $edd->get_products();
     $this->assertEquals(2, count($products));
     $this->assertArrayHasKey($product_1, $products);
     $this->assertArrayHasKey($product_2, $products);
 }
예제 #4
0
 /**
  * Get price test object from the price cookie
  *
  * @since 1.1.0
  *
  * @param string $plugin Slug of plugin edd|woo
  * @param int $id  Product ID
  * @param array|null $cookie
  *
  * @return \ingot\testing\object\price\test
  */
 public static function get_price_test_from_cookie($plugin, $id, $cookie = null)
 {
     if (in_array($plugin, types::allowed_price_types())) {
         if (is_null($cookie)) {
             $cookie = init::get_instance()->get_ingot_cookie(false)['price'];
         }
         if (isset($cookie[$plugin][$id])) {
             $test = $cookie[$plugin][$id];
             return self::inflate_price_test($test);
         }
     }
 }