/**
  * Ensures that the widget header is correct.
  */
 function test_header()
 {
     // Load mock data
     require 'mock_data.php';
     ibm_sbtk_activate_plugin();
     if (!class_exists('SBTEndpointUpdate')) {
         require BASE_PATH . '/controllers/SBTEndpointUpdate.php';
     }
     // Fake post request - populate it with mock data
     $_POST['endpoint_name'] = $config['wp_endpoint_1_name'];
     $_POST['endpoint_url'] = $config['wp_endpoint_1_url'];
     $_POST['consumer_key'] = $config['wp_endpoint_1_consumer_key'];
     $_POST['consumer_secret'] = $config['wp_endpoint_1_consumer_secret'];
     $_POST['authorization_url'] = $config['wp_endpoint_1_authorization_url'];
     $_POST['access_token_url'] = $config['wp_endpoint_1_access_token_url'];
     $_POST['request_token_url'] = $config['wp_endpoint_1_request_token_url'];
     $_POST['authentication_method'] = $config['wp_endpoint_1_authentication_method'];
     $_POST['basic_auth_username'] = $config['wp_endpoint_1_basic_auth_username'];
     $_POST['basic_auth_password'] = $config['wp_endpoint_1_basic_auth_password'];
     $_POST['basic_auth_method'] = $config['wp_endpoint_1_basic_auth_method'];
     $_POST['sdk_deploy_url'] = $config['sdk_deploy_url'];
     $_POST['delete_endpoint'] = 'no';
     $_POST['libraries_list'] = $config['js_library'];
     // Update the endpoint
     $update = new SBTEndpointUpdate();
     $this->assertTrue(function_exists('ibm_sbtk_header'));
     ob_start();
     ibm_sbtk_header(array());
     $html = ob_get_clean();
     // Check that JS for the header is correct
     //$this->_validateHeader($html);
     //  Iterate through all available src attributes and checks that links are valid.
     $this->_validateLinks($html);
 }
Example #2
0
 /**
  * Test that plugin activation function exists.
  */
 function test_options_setup()
 {
     // Check activation
     $this->assertTrue(function_exists('ibm_sbtk_activate_plugin'));
     $this->assertTrue(ibm_sbtk_activate_plugin());
     // Check deactivation
     $this->assertTrue(function_exists('ibm_sbtk_deactivate_plugin'));
     $this->assertTrue(ibm_sbtk_deactivate_plugin());
     $this->assertTrue(ibm_sbtk_activate_plugin());
 }
 /**
  * Tests the storage of the OAuth tokens.
  */
 function test_oauth_token_storage()
 {
     $token = "HasdkHas7373&";
     ibm_sbtk_activate_plugin();
     if (!class_exists('SBTMemoryCookieAdapter')) {
         require BASE_PATH . '/core/models/SBTMemoryCookieAdapter.php';
     }
     $mockAdapter = new SBTMemoryCookieAdapter();
     $store = SBTCredentialStore::getInstance($mockAdapter);
     // Store tokens
     $store->storeOAuthAccessToken($token);
     $store->storeRequestToken($token);
     $store->storeToken($token);
     // Retrieve stored user credentials
     $retToken1 = $store->getOAuthAccessToken();
     $retToken2 = $store->getRequestToken();
     $retToken3 = $store->getToken();
     // Check that stored tokens are the same than the original
     // token
     $this->assertEquals($token, $retToken1);
     $this->assertEquals($token, $retToken2);
     $this->assertEquals($token, $retToken3);
 }