HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux ip-172-31-42-149 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 07:00:04 UTC 2025 aarch64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/vhost/disk-apps/magento.bikenow.co/vendor/vertex/sdk/tests/Unit/VersionDeterminerTest.php
<?php declare(strict_types=1);

/**
 * @copyright  Vertex. All rights reserved.  https://www.vertexinc.com/
 * @author     Mediotype Development         <diveinto@mediotype.com>
 */

namespace Vertex\Test\Unit;

use PHPUnit\Framework\TestCase;
use Vertex\Exception\ConfigurationException;
use Vertex\Utility\VersionDeterminer;

/**
 * Tests for {@see VersionDeterminer}
 */
class VersionDeterminerTest extends TestCase
{
    /** @var \Vertex\Utility\VersionDeterminer */
    private $versionDeterminer;

    /**
     * @inheritdoc
     */
    protected function setUp(): void
    {
        $this->versionDeterminer = new VersionDeterminer();
    }

    /**
     * Provide data for primary test
     *
     * Expects to return two parameters, the first being the URL of an endpoint and the second being the expected API
     * level returned from {@see VersionDeterminer::execute()}
     *
     * @return array
     */
    public function dataProvider()
    {
        return [
            ['https://mgcsconnect.vertexsmb.com/vertex-ws/services/CalculateTax60?wsdl', '60'],
            ['https://mgcsconnect.vertexsmb.com/vertex-ws/services/CalculateTax60', '60'],
            ['https://mgcsconnect.vertexsmb.com/vertex-ws/services/LookupTaxAreas60?wsdl', '60'],
            ['https://mgcsconnect.vertexsmb.com/vertex-ws/services/LookupTaxAreas60', '60'],
            ['https://mgcsconnect.vertexsmb.com/vertex-ws/services/CalculateTax70?wsdl', '70'],
            ['https://mgcsconnect.vertexsmb.com/vertex-ws/services/CalculateTax70', '70'],
            ['https://mgcsconnect.vertexsmb.com/vertex-ws/services/LookupTaxAreas70?wsdl', '70'],
            ['https://mgcsconnect.vertexsmb.com/vertex-ws/services/LookupTaxAreas70', '70'],
        ];
    }

    /**
     * Test that a {@see ConfigurationException} is thrown when no version is found for a URL
     *
     * @return void
     */
    public function testException()
    {
        $this->expectException(ConfigurationException::class);
        $this->expectExceptionMessage('Provided URL does not contain a known, supported version');
        $this->versionDeterminer->execute('https://www.google.com/');
    }

    /**
     * Test that the correct API level is returned for any given URL
     *
     * @dataProvider dataProvider
     * @param string $url
     * @param string $apiLevel
     * @return void
     * @throws \Vertex\Exception\ConfigurationException
     */
    public function testVersionDeterminer($url, $apiLevel)
    {
        $this->assertEquals($apiLevel, $this->versionDeterminer->execute($url));
    }
}