|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Elmage\TextNg\Test\Unit; |
|
4
|
|
|
|
|
5
|
|
|
use Elmage\TextNg\Authentication\ApiKeyAuthentication; |
|
6
|
|
|
use Elmage\TextNg\Configuration; |
|
7
|
|
|
use Elmage\TextNg\HttpClient; |
|
8
|
|
|
use Elmage\TextNg\Test\TestCase; |
|
9
|
|
|
|
|
10
|
|
|
class ConfigurationTest extends TestCase |
|
11
|
|
|
{ |
|
12
|
|
|
public function testDefaultApiUrl() |
|
13
|
|
|
{ |
|
14
|
|
|
$config = new Configuration(new ApiKeyAuthentication("TEST_KEY"), "Test"); |
|
15
|
|
|
|
|
16
|
|
|
$this->assertEquals(Configuration::DEFAULT_API_URL, $config->getApiUrl()); |
|
17
|
|
|
} |
|
18
|
|
|
|
|
19
|
|
|
public function testCustomApiUrl() |
|
20
|
|
|
{ |
|
21
|
|
|
$config = new Configuration(new ApiKeyAuthentication("TEST_KEY"), "Test"); |
|
22
|
|
|
$config->setApiUrl('https://example.com'); |
|
23
|
|
|
$this->assertEquals('https://example.com', $config->getApiUrl()); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
public function testDefaultApiVersion() |
|
27
|
|
|
{ |
|
28
|
|
|
$config = new Configuration(new ApiKeyAuthentication("TEST_KEY"), "Test"); |
|
29
|
|
|
$this->assertEquals(Configuration::DEFAULT_API_VERSION, $config->getApiVersion()); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public function testCustomApiVersion() |
|
33
|
|
|
{ |
|
34
|
|
|
$config = new Configuration(new ApiKeyAuthentication("TEST_KEY"), "Test"); |
|
35
|
|
|
$config->setApiVersion('2000-01-01'); |
|
36
|
|
|
$this->assertEquals('2000-01-01', $config->getApiVersion()); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
public function testCreateHttpClient() |
|
40
|
|
|
{ |
|
41
|
|
|
$config = new Configuration(new ApiKeyAuthentication("TEST_KEY"), "Test"); |
|
42
|
|
|
$this->assertInstanceOf(HttpClient::class, $config->createHttpClient()); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function testApiKey() |
|
46
|
|
|
{ |
|
47
|
|
|
$config = new Configuration(new ApiKeyAuthentication("TEST_KEY"), "Test"); |
|
48
|
|
|
$this->assertInstanceOf(Configuration::class, Configuration::apiKey($config->getAuthentication()->getApiKey())); |
|
49
|
|
|
|
|
50
|
|
|
$key = "NEW_KEY"; |
|
51
|
|
|
$config->getAuthentication()->setApiKey($key); |
|
52
|
|
|
$this->assertEquals($key, $config->getAuthentication()->getApiKey()); |
|
53
|
|
|
|
|
54
|
|
|
$auth = new ApiKeyAuthentication("Random"); |
|
55
|
|
|
$config->setAuthentication($auth); |
|
56
|
|
|
|
|
57
|
|
|
$this->assertEquals($auth, $config->getAuthentication()); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
public function testSenderAccessorAndModifier() |
|
61
|
|
|
{ |
|
62
|
|
|
$config = new Configuration(new ApiKeyAuthentication("TEST_KEY"), "Test"); |
|
63
|
|
|
$this->assertEquals("Test", $config->getSender()); |
|
64
|
|
|
|
|
65
|
|
|
$config->setSender("Test2"); |
|
66
|
|
|
$this->assertEquals("Test2", $config->getSender()); |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|