<commit_before><?php

namespace Bdt\Test\Eway;

use Bdt\Eway\EwayClient;
use GuzzleHttp\Command\Event\EventWrapper;
use GuzzleHttp\Subscriber\Mock;

class EwayClientTest extends \PHPUnit_Framework_TestCase
{
    public function setup()
    {
        $this->client = EwayClient::factory(array(
            'base_url' => 'https://www.eway.com.au/gateway_cvn/xmltest/testpage.asp',
        ));
        $this->mock = new Mock;
        $this->client->getHttpClient()->getEmitter()->attach($this->mock);
    }

    public function testCanSetCustomerIdInClient()
    {
        $this->client = EwayClient::factory(array(
            'base_url' => 'https://www.eway.com.au/gateway_cvn/xmltest/testpage.asp',
            'customer_id' => 100 
        ));
        $command = $this->client->getCommand('SendPayment', array(
            'totalAmount'     => '10',
            'cardHoldersName' => '<NAME>',
            'cardNumber'      => '4444333322221111',
            'cardExpiryMonth' => '06',
            'cardExpiryYear'  => '20',
            'CVN'             => '123',
        ));
        EventWrapper::prepareCommand($command, $this->client);
        $this->assertEquals(100, $command['customerID']);
    }

    public function testSendPayment()
    {
        $this->setMockResponse('sendpayment_success.txt');<commit_msg>Update EwayClientTest to support newer guzzle-services changes<commit_after><?php

namespace Bdt\Test\Eway;

use Bdt\Eway\EwayClient;
use GuzzleHttp\Command\Event\CommandEvents;
use GuzzleHttp\Subscriber\Mock;

class EwayClientTest extends \PHPUnit_Framework_TestCase
{
    public function setup()
    {
        $this->client = EwayClient::factory(array(
            'base_url' => 'https://www.eway.com.au/gateway_cvn/xmltest/testpage.asp',
        ));
        $this->mock = new Mock;
        $this->client->getHttpClient()->getEmitter()->attach($this->mock);
    }

    public function testCanSetCustomerIdInClient()
    {
        $this->client = EwayClient::factory(array(
            'base_url' => 'https://www.eway.com.au/gateway_cvn/xmltest/testpage.asp',
            'customer_id' => 100 
        ));
        $command = $this->client->getCommand('SendPayment', array(
            'totalAmount'     => '10',
            'cardHoldersName' => '<NAME>',
            'cardNumber'      => '4444333322221111',
            'cardExpiryMonth' => '06',
            'cardExpiryYear'  => '20',
            'CVN'             => '123',
        ));
        CommandEvents::prepare($command, $this->client);
        $this->assertEquals(100, $command['customerID']);
    }

    public function testSendPayment()
    {
        $this->setMockResponse('sendpayment_success.txt');
{'fraction_non_alphanumeric': 0.15324384787472037, 'fraction_numerical': 0.023117076808351976, 'mean_word_length': 2.5395778364116093, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 49, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, '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': '1041301', 'n_tokens_mistral': 869, 'n_tokens_neox': 821, 'n_words': 117}