|
Apache/2.4.41 (Ubuntu) Linux vmi616275.contaboserver.net 5.4.0-84-generic #94-Ubuntu SMP Thu Aug 26 20:27:37 UTC 2021 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) server ip : 62.171.164.128 | your ip : 127.0.0.1 safemode OFF > / home / a / home / dev2.destoffenstraat.com / vendor / vertex / sdk / tests / Unit / |
Filename | /home/a/home/dev2.destoffenstraat.com/vendor/vertex/sdk/tests/Unit/VersionDeterminerTest.php |
Size | 2.52 kb |
Permission | rw-rw-rw- |
Owner | root : root |
Create time | 21-Aug-2025 12:26 |
Last modified | 23-Sep-2020 09:46 |
Last accessed | 22-Aug-2025 20:17 |
Actions | edit | rename | delete | download (gzip) |
View | text | code | image |
<?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));
}
}
/**
* @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));
}
}