function test_wl_configuration_redlink_dataset_name()
 {
     $value = uniqid();
     wl_configuration_set_redlink_dataset_name($value);
     $this->assertEquals($value, wl_configuration_get_redlink_dataset_name());
 }
Example #2
0
/**
 * Configure WordPress with the test settings (may vary according to the local PHP and WordPress versions).
 */
function wl_configure_wordpress_test()
{
    add_filter('wl_write_log_handler', 'wl_test_get_write_log_handler');
    do_action('activate_wordlift/wordlift.php');
    // If the WordLift key is set, then we'll configure it, otherwise we configure Redlink.
    if (false !== getenv('WORDLIFT_KEY')) {
        // When setting the WordLift Key, the Redlink dataset URI is provisioned by WordLift Server.
        wl_configuration_set_key(getenv('WORDLIFT_KEY'));
        if ('' === wl_configuration_get_redlink_dataset_uri()) {
            die('The Redlink dataset URI is not set (maybe the WordLift key is not valid?)');
        }
    } else {
        // TODO: remove this part.
        // or use Redlink.
        // Set the dataset name to the specified dataset or define it based on the current environment.
        $dataset_name = false !== getenv('REDLINK_DATASET_NAME') ? getenv('REDLINK_DATASET_NAME') : str_replace('.', '-', sprintf('%s-php-%s.%s-wp-%s-ms-%s', 'wordlift-tests', PHP_MAJOR_VERSION, PHP_MINOR_VERSION, getenv('WP_VERSION'), getenv('WP_MULTISITE')));
        $app_name = false !== getenv('REDLINK_APP_NAME') ? getenv('REDLINK_APP_NAME') : 'wordlift';
        // Check that the API_URL env is set.
        if (false === getenv('API_URL')) {
            die('The API_URL environment variable is not set.');
        }
        wl_configuration_set_redlink_key(getenv('REDLINK_APP_KEY'));
        wl_configuration_set_redlink_user_id(getenv('REDLINK_USER_ID'));
        wl_configuration_set_api_url(getenv('API_URL'));
        wl_configuration_set_redlink_dataset_name($dataset_name);
        wl_configuration_set_redlink_application_name($app_name);
        wl_configuration_set_redlink_dataset_uri('http://data.redlink.io/' . getenv('REDLINK_USER_ID') . '/' . $dataset_name);
    }
}