<commit_before><?php

namespace Cardinity\Tests;

use Cardinity\Client;
use PHPUnit\Framework\TestCase;
use Cardinity\Method\Payment;

class ClientEndpointTest extends ClientTestCase
{
    private $baseConfig;
    private $log;

    /**
     * @return void
     */
    public function setUp(): void
    {
        $this->baseConfig = [
            'consumerKey' => CONSUMER_KEY,
            'consumerSecret' => CONSUMER_SECRET,
        ];
        $this->log = Client::LOG_NONE;
    }

    /**
     * Test create client with invalid URL
     *
     * @return void
     */
    public function testInvalidURLEndpoint(){

        $this->baseConfig['apiEndpoint'] = '123abc';
        try {
            Client::create($this->baseConfig, $this->log);
        } catch (\Exception $e) {
            //throw $th;
            $this->assertStringContainsString('Your API endpoint is not a valid URL', $e->getMessage());
        }
    }

     /**
     * Test create client with valid URL,
     *
     * @return void
     */
    public function testValidUrlWrongEndpoint(){

        $this->baseConfig['apiEndpoint'] = 'https://api.carwash.com/v1/';

        try {
            $client = Client::create($this->baseConfig, $this->log);

            $method = new Payment\Create($this->getPaymentParams());
            $client->call($method);

        } catch (\Exception $e) {
            //throw $th;
            $this->assertStringContainsString('error', $e->getMessage());
        }
        $this->assertInstanceOf('Cardinity\Client', $client);
    }

    /**
     * Test create client with valid URL,
     *
     * @return void
     */
    public function testValidURLValidEndpoint(){

        $this->baseConfig['apiEndpoint'] = 'https://api.cardinity.com/v1/';
        $client = Client::create($this->baseConfig, $this->log);
        $this->assertInstanceOf('Cardinity\Client', $client);
    }

     /**
     * Test create client with valid URL,
     *
     * @return void
     */
    public function testNoEndpoint(){

        unset($this->baseConfig['apiEndpoint']);
        $client = Client::create($this->baseConfig, $this->log);
        $this->assertInstanceOf('Cardinity\Client', $client);
    }
}<commit_msg>PHP-468 updated test use reflection to check default value<commit_after><?php

namespace Cardinity\Tests;

use Cardinity\Client;
use PHPUnit\Framework\TestCase;
use Cardinity\Method\Payment;

class ClientEndpointTest extends ClientTestCase
{
    private $baseConfig;
    private $log;

    /**
     * @return void
     */
    public function setUp(): void
    {
        $this->baseConfig = [
            'consumerKey' => CONSUMER_KEY,
            'consumerSecret' => CONSUMER_SECRET,
        ];
        $this->log = Client::LOG_NONE;
    }

    /**
     * Test create client with invalid URL
     *
     * @return void
     */
    public function testInvalidURLEndpoint(){

        $this->baseConfig['apiEndpoint'] = '123abc';
        try {
            Client::create($this->baseConfig, $this->log);
        } catch (\Exception $e) {
            //throw $th;
            $this->assertStringContainsString('Your API endpoint is not a valid URL', $e->getMessage());
        }
    }

     /**
     * Test create client with valid URL,
     *
     * @return void
     */
    public function testValidUrlWrongEndpoint(){

        $this->baseConfig['apiEndpoint'] = 'https://example.com/';

        try {
            $client = Client::create($this->baseConfig, $this->log);
        } catch (\Exception $e) {
            //throw $th;
            $this->assertStringContainsString('error', $e->getMessage());
        }
        $this->assertInstanceOf('Cardinity\Client', $client);
    }

    /**
     * Test create client with valid URL,
     *
     * @return void
     */
    public function testValidURLValidEndpoint(){

        $this->baseConfig['apiEndpoint'] = 'https://api.cardinity.com/v1/';
        $client = Client::create($this->baseConfig, $this->log);
        $this->assertInstanceOf('Cardinity\Client', $client);
    }

     /**
     * Test create client with valid URL,
     *
     * @return void
     */
    public function testNoEndpoint(){

        unset($this->baseConfig['apiEndpoint']);
        $client = Client::create($this->baseConfig, $this->log);

        $reflection = new \ReflectionObject($client);
        $urlProperty = $reflection->getProperty('url');
        $urlProperty->setAccessible(true);

        $this->assertSame($urlProperty->getValue(),'https://api.cardinity.com/v1/');
        $this->assertInstanceOf('Cardinity\Client', $client);
    }
}
{'fraction_non_alphanumeric': 0.14797814207650273, 'fraction_numerical': 0.0028415300546448087, 'mean_word_length': 2.2968299711815563, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 55, 'https://': 5, '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': '6692049', 'n_tokens_mistral': 1319, 'n_tokens_neox': 1287, 'n_words': 261}