-
Notifications
You must be signed in to change notification settings - Fork 74
Expand file tree
/
Copy pathChoiceMaxOccursRuleTest.php
More file actions
91 lines (79 loc) · 2.85 KB
/
Copy pathChoiceMaxOccursRuleTest.php
File metadata and controls
91 lines (79 loc) · 2.85 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
<?php
declare(strict_types=1);
namespace WsdlToPhp\PackageGenerator\Tests\File\Validation;
/**
* The ItemsChoiceType struct contains a choice (choiceMaxOccurs: 1) whose elements have
* their own maxOccurs: 5, so each property must accept up to 5 items even though the
* choice itself may only occur once.
*
* @see https://github.com/WsdlToPhp/PackageGenerator/issues/340
*
* @internal
* @coversDefaultClass
*/
final class ChoiceMaxOccursRuleTest extends AbstractRule
{
/**
* The ItemIdentifier
* Meta information extracted from the WSDL
* - choice: ItemIdentifier | ItemName
* - choiceMaxOccurs: 1
* - choiceMinOccurs: 1
* - maxOccurs: 5
* - minOccurs: 1.
*/
public function testSetItemIdentifierWithSeveralItemsMustPass(): void
{
$instance = self::getUnitTestsItemsChoiceTypeInstance(true);
$this->assertSame($instance, $instance->setItemIdentifier([1, 2, 3, 4, 5]));
}
/**
* The ItemIdentifier
* Meta information extracted from the WSDL
* - choice: ItemIdentifier | ItemName
* - choiceMaxOccurs: 1
* - choiceMinOccurs: 1
* - maxOccurs: 5
* - minOccurs: 1.
*/
public function testAddToItemIdentifierWithSeveralItemsMustPass(): void
{
$instance = self::getUnitTestsItemsChoiceTypeInstance(true);
$this->assertSame($instance, $instance->setItemIdentifier([1])->addToItemIdentifier(2)->addToItemIdentifier(3));
}
/**
* The ItemIdentifier
* Meta information extracted from the WSDL
* - choice: ItemIdentifier | ItemName
* - choiceMaxOccurs: 1
* - choiceMinOccurs: 1
* - maxOccurs: 5
* - minOccurs: 1.
*/
public function testSetItemIdentifierWithTooManyItemsMustThrowAnException(): void
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Invalid count of 6, the number of elements contained by the property must be less than or equal to 5');
$instance = self::getUnitTestsItemsChoiceTypeInstance(true);
$instance->setItemIdentifier([1, 2, 3, 4, 5, 6]);
}
/**
* The ItemName
* Meta information extracted from the WSDL
* - choice: ItemIdentifier | ItemName
* - choiceMaxOccurs: 1
* - choiceMinOccurs: 1
* - maxOccurs: 5
* - minOccurs: 1.
*/
public function testSetItemNameAfterItemIdentifierMustThrowAnException(): void
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('The property ItemName can\'t be set as the property ItemIdentifier is already set. Only one property must be set among these properties: ItemName, ItemIdentifier.');
$instance = self::getUnitTestsItemsChoiceTypeInstance(true);
$instance
->setItemIdentifier([1, 2])
->setItemName(['one', 'two'])
;
}
}