<commit_before><?php

namespace AffiliateLinkr\Tests\CommissionJunction;

/**
 * Description of LinkSearchTest
 *
 * @author jeremyzerr
 */
class ApiCredentialsTest extends \PHPUnit_Framework_TestCase {
  
  public function testApiCredentialsCreation() {
    // create client
    $oApiCredentials = new \AffiliateLinkr\CommissionJunction\ApiCredentials();

    $this->assertNotNull($oApiCredentials);
  }

  public function testApiCredentialsFromFile() {
    // test just the ini file pulling
    // test file is in .affiliatelinkr/credentials
    $filename = dirname(__FILE__) . '/' . \AffiliateLinkr\CommissionJunction\ApiCredentials::CREDENTIALS_FILE;
    $oApiCredentials = \AffiliateLinkr\CommissionJunction\ApiCredentials::fromIni($filename);

    $this->assertNotNull($oApiCredentials);
    
    $this->assertEquals("FOO", $oApiCredentials->getDeveloperKey());
    
  }  
  
  public function testApiCredentialsIndirectlyFromFile() {
    // test the ini file pulling when there are no environment variables set
    // set home directory
    $_SERVER['HOME'] = dirname(__FILE__);
    $varInFile = "FOO";
    $oApiCredentials = \AffiliateLinkr\CommissionJunction\ApiCredentials::factory();

    $this->assertNotNull($oApiCredentials);
    
    $this->assertEquals($varInFile, $oApiCredentials->getDeveloperKey());
    
  } 
  
  public function testApiCredentialsFromEnvironment() {
    // test using environment variables overriding even when a file exists
    // set home directory that would be necessary for a file
    $_SERVER['HOME'] = dirname(__FILE__);
    // set the environment variable, this is what it should be set to
    $envVarName = \AffiliateLinkr\CommissionJunction\ApiCredentials::ENV_KEY;
    $_SERVER[$envVarName] = "BAR";
    $oApiCredentials = \AffiliateLinkr\CommissionJunction\ApiCredentials::factory();

    $this->assertNotNull($oApiCredentials);
    
    $this->assertEquals($_SERVER[$envVarName], $oApiCredentials->getDeveloperKey());
    
  }   
  
}<commit_msg>Added one more test for manually defining developer key in credentials<commit_after><?php

namespace AffiliateLinkr\Tests\CommissionJunction;

/**
 * Description of LinkSearchTest
 *
 * @author jeremyzerr
 */
class ApiCredentialsTest extends \PHPUnit_Framework_TestCase {
  
  public function testApiCredentialsCreation() {
    // create client
    $oApiCredentials = new \AffiliateLinkr\CommissionJunction\ApiCredentials();

    $this->assertNotNull($oApiCredentials);
  }
  
  public function testApiCredentialsCreationWithKey() {
    // create client
    $testKey = "TEST";
    $oApiCredentials = new \AffiliateLinkr\CommissionJunction\ApiCredentials($testKey);

    $this->assertNotNull($oApiCredentials);
    $this->assertEquals($testKey, $oApiCredentials->getDeveloperKey());
  }  

  public function testApiCredentialsFromFile() {
    // test just the ini file pulling
    // test file is in .affiliatelinkr/credentials
    $filename = dirname(__FILE__) . '/' . \AffiliateLinkr\CommissionJunction\ApiCredentials::CREDENTIALS_FILE;
    $oApiCredentials = \AffiliateLinkr\CommissionJunction\ApiCredentials::fromIni($filename);

    $this->assertNotNull($oApiCredentials);
    
    $this->assertEquals("FOO", $oApiCredentials->getDeveloperKey());
    
  }  
  
  public function testApiCredentialsIndirectlyFromFile() {
    // test the ini file pulling when there are no environment variables set
    // set home directory
    $_SERVER['HOME'] = dirname(__FILE__);
    $varInFile = "FOO";
    $oApiCredentials = \AffiliateLinkr\CommissionJunction\ApiCredentials::factory();

    $this->assertNotNull($oApiCredentials);
    
    $this->assertEquals($varInFile, $oApiCredentials->getDeveloperKey());
    
  } 
  
  public function testApiCredentialsFromEnvironment() {
    // test using environment variables overriding even when a file exists
    // set home directory that would be necessary for a file
    $_SERVER['HOME'] = dirname(__FILE__);
    // set the environment variable, this is what it should be set to
    $envVarName = \AffiliateLinkr\CommissionJunction\ApiCredentials::ENV_KEY;
    $_SERVER[$envVarName] = "BAR";
    $oApiCredentials = \AffiliateLinkr\CommissionJunction\ApiCredentials::factory();

    $this->assertNotNull($oApiCredentials);
    
    $this->assertEquals($_SERVER[$envVarName], $oApiCredentials->getDeveloperKey());
    
  }   
  
}
{'fraction_non_alphanumeric': 0.10950744558991982, 'fraction_numerical': 0.0, 'mean_word_length': 4.279322853688029, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6961754', 'n_tokens_mistral': 1249, 'n_tokens_neox': 1254, 'n_words': 255}