<commit_before><?php

/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */

use AktiveMerchant\Billing\Gateways\AuthorizeNet;
use AktiveMerchant\Billing\Base;
use AktiveMerchant\Billing\CreditCard;

require_once 'config.php';

/**
 * AuthorizeNetTest class.
 *
 *
 * @package Aktive-Merchant
 * @author  <NAME>
 * @license http://www.opensource.org/licenses/mit-license.php
 *
 */
class AuthorizeNetTest extends AktiveMerchant\TestCase
{

    public $gateway;
    public $amount;
    public $options;
    public $creditcard;
    public $recurring_options;

    /**
     * Setup
     */
    function setUp()
    {
        Base::mode('test');

        $login_info = array(
            'login' => AUTH_NET_LOGIN,
            'password' => <PASSWORD>);
        $this->gateway = new AuthorizeNet($login_info);

        $this->amount = 100;
        $this->creditcard = new CreditCard(array(
                "first_name" => "John",
                "last_name" => "Doe",
                "number" => "4111111111111111",
                "month" => "01",
                "year" => "2015",
                "verification_value" => "000"
                )
        );
        $this->options = array(
            'order_id' => 'REF' . $this->gateway->generateUniqueId(),
            'description' => 'Autorize.net Test Transaction',
            'address' => array(
                'address1' => '1234 Street',
                'zip' => '98004',
                'state' => 'WA'
            )
        );

        $this->recurring_options = array(
            'amount' => 100,
            'subscription_name' => 'Test Subscription 1',
            'billing_address' => array(
                'first_name' => 'John' . $this->gateway->generateUniqueId(),
                'last_name' => 'Smith'
            ),
            'length' => 11,
            'unit' => 'months',
            'start_date' => date("Y-m-d", time()),
            'occurrences' => 1
        );
    }

    /**
     * Tests
     */
    
    public function testInitialization() {

      $this->assertNotNull($this->gateway);
      
      $this->assertInstanceOf(
          '\\AktiveMerchant\\Billing\\Gateway', 
          $this->gateway
      );
      
      $this->assertInstanceOf(
          '\\AktiveMerchant\\Billing\\Interfaces\\Charge', 
          $this->gateway
      );
      
      $this->assertInstanceOf(
          '\\AktiveMerchant\\Billing\\Interfaces\\Credit', 
          $this->gateway
      );
      
      $this->assertInstanceOf(
          '\\AktiveMerchant\\Billing\\Interfaces\\Recurring', 
          $this->gateway
      );
      
      $this->assertNotNull($this->creditcard);
    }
    
    public function testSuccessfulPurchase()
    {
        $this->mock_request($this->successful_purchase_response());
        
        $response = $this->gateway->purchase(
            $this->amount, $this->creditcard, $this->options
        );
        
        $this->assert_success($response);
        $this->assertEquals(
            'This transaction has been approved.', 
            $response->message()
        );
    }

    private function successful_purchase_response()
    {
        return "1|1|1|This transaction has been approved.|C5SEPE|Y|2176052979|REF3241141575|Autorize.net Test Transaction|100.00|CC|auth_capture||John|Doe||1234 Street||WA|98004||||||||||||||||||7CAFB5DD55B21227198694F15ED9D7DA|P|2|||||||||||XXXX1111|Visa||||||||||||||||";
    }

    public function testSuccessfulAuthorization()
    {
        $this->mock_request($this->successful_authorize_response());
        $response = $this->gateway->authorize(
            $this->amount, $this->creditcard, $this->options
        );
        
        $this->assert_success($response);<commit_msg>fix indent<commit_after><?php

/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */

use AktiveMerchant\Billing\Gateways\AuthorizeNet;
use AktiveMerchant\Billing\Base;
use AktiveMerchant\Billing\CreditCard;

require_once 'config.php';

/**
 * AuthorizeNetTest class.
 *
 *
 * @package Aktive-Merchant
 * @author  <NAME>
 * @license http://www.opensource.org/licenses/mit-license.php
 *
 */
class AuthorizeNetTest extends AktiveMerchant\TestCase
{

    public $gateway;
    public $amount;
    public $options;
    public $creditcard;
    public $recurring_options;

    /**
     * Setup
     */
    function setUp()
    {
        Base::mode('test');

        $login_info = array(
            'login' => AUTH_NET_LOGIN,
            'password' => <PASSWORD>);
        $this->gateway = new AuthorizeNet($login_info);

        $this->amount = 100;
        $this->creditcard = new CreditCard(array(
                "first_name" => "John",
                "last_name" => "Doe",
                "number" => "4111111111111111",
                "month" => "01",
                "year" => "2015",
                "verification_value" => "000"
                )
        );
        $this->options = array(
            'order_id' => 'REF' . $this->gateway->generateUniqueId(),
            'description' => 'Autorize.net Test Transaction',
            'address' => array(
                'address1' => '1234 Street',
                'zip' => '98004',
                'state' => 'WA'
            )
        );

        $this->recurring_options = array(
            'amount' => 100,
            'subscription_name' => 'Test Subscription 1',
            'billing_address' => array(
                'first_name' => 'John' . $this->gateway->generateUniqueId(),
                'last_name' => 'Smith'
            ),
            'length' => 11,
            'unit' => 'months',
            'start_date' => date("Y-m-d", time()),
            'occurrences' => 1
        );
    }

    /**
     * Tests
     */
    
    public function testInitialization() {

      $this->assertNotNull($this->gateway);
      
      $this->assertInstanceOf(
          '\\AktiveMerchant\\Billing\\Gateway', 
          $this->gateway
      );
      
      $this->assertInstanceOf(
          '\\AktiveMerchant\\Billing\\Interfaces\\Charge', 
          $this->gateway
      );
      
      $this->assertInstanceOf(
          '\\AktiveMerchant\\Billing\\Interfaces\\Credit', 
          $this->gateway
      );
      
      $this->assertInstanceOf(
          '\\AktiveMerchant\\Billing\\Interfaces\\Recurring', 
          $this->gateway
      );
      
      $this->assertNotNull($this->creditcard);
    }
    
    public function testSuccessfulPurchase()
    {
        $this->mock_request($this->successful_purchase_response());
        
        $response = $this->gateway->purchase(
            $this->amount, 
            $this->creditcard, 
            $this->options
        );
        
        $this->assert_success($response);
        $this->assertEquals(
            'This transaction has been approved.', 
            $response->message()
        );
    }

    private function successful_purchase_response()
    {
        return "1|1|1|This transaction has been approved.|C5SEPE|Y|2176052979|REF3241141575|Autorize.net Test Transaction|100.00|CC|auth_capture||John|Doe||1234 Street||WA|98004||||||||||||||||||7CAFB5DD55B21227198694F15ED9D7DA|P|2|||||||||||XXXX1111|Visa||||||||||||||||";
    }

    public function testSuccessfulAuthorization()
    {
        $this->mock_request($this->successful_authorize_response());
        $response = $this->gateway->authorize(
            $this->amount, $this->creditcard, $this->options
        );
        
        $this->assert_success($response);
{'fraction_non_alphanumeric': 0.15472855808990263, 'fraction_numerical': 0.029345071361878083, 'mean_word_length': 1.9473270440251573, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 131, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '980788', 'n_tokens_mistral': 2454, 'n_tokens_neox': 2241, 'n_words': 332}