/** * 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); }
/** * Loads ingot if not already loaded. * * @since 0.0.5 */ public static function maybe_load() { if (did_action('ingot_loaded')) { return; } if (!defined('INGOT_DEV_MODE')) { /** * Puts Ingot into dev mode * * Don't use on a live site -- makes API totally open * * @since 0.0.5 */ define('INGOT_DEV_MODE', false); } $load = true; if (!version_compare(PHP_VERSION, '5.5.0', '>=')) { $load = false; } $autoloader = dirname(__FILE__) . '/vendor/autoload.php'; if (!file_exists($autoloader)) { $load = false; } if ($load) { include_once $autoloader; self::maybe_add_tables(); self::maybe_upgrade(); self::maybe_load_trial(); if (\ingot\testing\db\delta::check_if_tables_exist()) { ingot\testing\ingot::instance(); //make admin go in admin if (is_admin()) { new ingot\ui\make(); } if (ingot_is_front_end() || ingot_is_admin_ajax()) { //setup destination tests $destination_tests = \ingot\testing\tests\click\destination\init::set_tracking(); //run cookies add_action('ingot_loaded', function () { /** * Disable running cookies * * @since 1.1.0 * * @param bool $run */ if (true == (bool) apply_filters('ingot_run_cookies', true) && !did_action('ingot_cookies_set')) { if (!empty($destination_tests)) { \ingot\testing\tests\click\destination\init::setup_cookies($destination_tests); } \ingot\testing\cookies\set::run(); } }); } /** * Runs when Ingot has loaded. * * @since 0.0.5 */ do_action('ingot_loaded'); } else { if (is_admin()) { printf('<div class="error"><p>%s</p></div>', __('Ingot Not Loaded', 'ingot')); } /** * Runs if Ingot failed to load * * @since 0.3.0 * */ do_action('ingot_loaded_failed'); return; } } }