<commit_before><?php

namespace Eo\KeyClient\Tests;

use Eo\KeyClient\Client;
use Eo\KeyClient\Payment\PaymentRequest;
use Eo\KeyClient\Payment\PaymentResponse;

/**
 * ClientTest
 */
class ClientTest extends \PHPUnit_Framework_TestCase
{
    /**
     * {@inheritdoc}
     */
    protected function setUp()
    {
        $this->alias  = getenv('KEYCLIENT_ALIAS') ?: 'payment_testm_urlmac';
        $this->secret = getenv('KEYCLIENT_SECRET') ?: 'esempiodicalcolomac';
    }

    /**
     * Test create payment url
     */
    public function testCreatePaymentUrl()
    {
        $client = new Client($this->alias, $this->secret);

        $payment = new PaymentRequest(1, 'EUR', 'transactionCode', 'http://example.com/completed', 'http://example.com/canceled');
        $payment->set('session_id', '123456');
        $payment->set('languageId', 'ITA-ENG');

        $url = $client->createPaymentUrl($payment);

        $this->assertEquals(
            $url,
            'https://ecommerce.keyclient.it/ecomm/ecomm/DispatcherServlet?importo=1&divisa=EUR&codTrans=transactionCode&url=http%3A%2F%2Fexample.com%2Fcompleted&url_back=http%3A%2F%2Fexample.com%2Fcanceled&session_id=123456&languageId=ITA-ENG&alias=payment_testm_urlmac&mac=abb95ee2a0c7017d046624a2e08816efe0c2e389'
        );
    }

    /**
     * Test parse payment response
     */
    public function testParsePaymentResponse()
    {
        $_GET['session_id'] = '';
        $_GET['regione'] = 'EUROPE';
        $_GET['codAut'] = 'TESTOK';
        $_GET['alias'] = 'payment_testm_urlmac';<commit_msg>Endpoint updated for tests<commit_after><?php

namespace Eo\KeyClient\Tests;

use Eo\KeyClient\Client;
use Eo\KeyClient\Payment\PaymentRequest;
use Eo\KeyClient\Payment\PaymentResponse;

/**
 * ClientTest
 */
class ClientTest extends \PHPUnit_Framework_TestCase
{
    /**
     * {@inheritdoc}
     */
    protected function setUp()
    {
        $this->alias  = getenv('KEYCLIENT_ALIAS') ?: 'payment_testm_urlmac';
        $this->secret = getenv('KEYCLIENT_SECRET') ?: 'esempiodicalcolomac';
    }

    /**
     * Test create payment url
     */
    public function testCreatePaymentUrl()
    {
        $client = new Client($this->alias, $this->secret);

        $payment = new PaymentRequest(1, 'EUR', 'transactionCode', 'http://example.com/completed', 'http://example.com/canceled');
        $payment->set('session_id', '123456');
        $payment->set('languageId', 'ITA-ENG');

        $url = $client->createPaymentUrl($payment);

        $this->assertEquals(
            $url,
            'https://ecommerce.nexi.it/ecomm/ecomm/DispatcherServlet?importo=1&divisa=EUR&codTrans=transactionCode&url=http%3A%2F%2Fexample.com%2Fcompleted&url_back=http%3A%2F%2Fexample.com%2Fcanceled&session_id=123456&languageId=ITA-ENG&alias=payment_testm_urlmac&mac=abb95ee2a0c7017d046624a2e08816efe0c2e389'
        );
    }

    /**
     * Test parse payment response
     */
    public function testParsePaymentResponse()
    {
        $_GET['session_id'] = '';
        $_GET['regione'] = 'EUROPE';
        $_GET['codAut'] = 'TESTOK';
        $_GET['alias'] = 'payment_testm_urlmac';
{'fraction_non_alphanumeric': 0.15261813537675606, 'fraction_numerical': 0.030012771392081736, 'mean_word_length': 3.4002808988764044, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '2982365', 'n_tokens_mistral': 1106, 'n_tokens_neox': 1049, 'n_words': 132}