|
| 1 | +<?php |
| 2 | + |
| 3 | +require __DIR__ . '/../vendor/autoload.php'; |
| 4 | + |
| 5 | +use Ay4t\RestClient\Config\Config; |
| 6 | +use PHPUnit\Framework\TestCase; |
| 7 | + |
| 8 | +class ConfigTest extends TestCase |
| 9 | +{ |
| 10 | + /** |
| 11 | + * @test |
| 12 | + */ |
| 13 | + public function testKonstruktorDenganApiKeySekretKeyDanApiUrl() |
| 14 | + { |
| 15 | + $apiKey = '1234567890'; |
| 16 | + $secretKey = 'abcdefghij'; |
| 17 | + $apiUrl = 'https://example.com/api'; |
| 18 | + |
| 19 | + $config = new Config($apiKey, $secretKey, $apiUrl); |
| 20 | + |
| 21 | + $this->assertEquals($apiKey, $config->apiKey); |
| 22 | + $this->assertEquals($secretKey, $config->secretKey); |
| 23 | + $this->assertEquals($apiUrl, $config->apiUrl); |
| 24 | + } |
| 25 | + |
| 26 | + /** |
| 27 | + * @test |
| 28 | + */ |
| 29 | + public function testKonstruktorDenganApiKeyKosong() |
| 30 | + { |
| 31 | + $this->expectException(\InvalidArgumentException::class); |
| 32 | + |
| 33 | + new Config('', 'abcdefghij', 'https://example.com/api'); |
| 34 | + } |
| 35 | + |
| 36 | + /** |
| 37 | + * @test |
| 38 | + */ |
| 39 | + public function testKonstruktorDenganSecretKeyKosong() |
| 40 | + { |
| 41 | + $this->expectException(\InvalidArgumentException::class); |
| 42 | + |
| 43 | + new Config('1234567890', '', 'https://example.com/api'); |
| 44 | + } |
| 45 | + |
| 46 | + /** |
| 47 | + * @test |
| 48 | + */ |
| 49 | + public function testKonstruktorDenganApiUrlKosong() |
| 50 | + { |
| 51 | + $this->expectException(\InvalidArgumentException::class); |
| 52 | + |
| 53 | + new Config('1234567890', 'abcdefghij', ''); |
| 54 | + } |
| 55 | + |
| 56 | + /** |
| 57 | + * @test |
| 58 | + */ |
| 59 | + public function testKonstruktorDenganApiKeyTidakValid() |
| 60 | + { |
| 61 | + $this->expectException(\InvalidArgumentException::class); |
| 62 | + |
| 63 | + new Config('abc', 'abcdefghij', 'https://example.com/api'); |
| 64 | + } |
| 65 | + |
| 66 | + /** |
| 67 | + * @test |
| 68 | + */ |
| 69 | + public function testKonstruktorDenganSecretKeyTidakValid() |
| 70 | + { |
| 71 | + $this->expectException(\InvalidArgumentException::class); |
| 72 | + |
| 73 | + new Config('1234567890', 'abc', 'https://example.com/api'); |
| 74 | + } |
| 75 | + |
| 76 | + /** |
| 77 | + * @test |
| 78 | + */ |
| 79 | + public function testKonstruktorDenganApiUrlTidakValid() |
| 80 | + { |
| 81 | + $this->expectException(\InvalidArgumentException::class); |
| 82 | + |
| 83 | + new Config('1234567890', 'abcdefghij', 'abc'); |
| 84 | + } |
| 85 | +} |
0 commit comments