@@ -11,20 +11,22 @@ class BackendTest extends TestCase
1111{
1212 public function typesProvider (): iterable
1313 {
14- yield 'null ' => [null , null ];
15- yield 'foo ' => ['foo ' , null ];
16- yield 'containerFoo ' => [null , 'foo ' ];
17- yield 'FooBoo ' => ['foo ' , 'boo ' ];
14+ yield 'null ' => [null , null , null ];
15+ yield 'foo ' => ['foo ' , null , null ];
16+ yield 'containerFoo ' => [null , 'foo ' , null ];
17+ yield 'contextFoo ' => [null , null , 'foo ' ];
18+ yield 'FooBooLoo ' => ['foo ' , 'boo ' , 'loo ' ];
1819 }
1920
2021 /**
2122 * @dataProvider typesProvider
2223 */
23- public function testCreate (?string $ type , ?string $ containerType ): void
24+ public function testCreate (?string $ type , ?string $ containerType, ? string $ context ): void
2425 {
25- $ backend = new Backend ($ type , $ containerType );
26+ $ backend = new Backend ($ type , $ containerType, $ context );
2627 self ::assertSame ($ type , $ backend ->getType ());
2728 self ::assertSame ($ containerType , $ backend ->getContainerType ());
29+ self ::assertSame ($ context , $ backend ->getContext ());
2830 }
2931
3032 /**
@@ -34,21 +36,64 @@ public function testCreateFromArray(
3436 array $ data ,
3537 ?string $ expectedType ,
3638 ?string $ expectedContainerType ,
39+ ?string $ expectedContext ,
3740 bool $ expectedEmpty
3841 ): void {
3942 $ backend = Backend::fromDataArray ($ data );
4043
4144 self ::assertSame ($ expectedType , $ backend ->getType ());
4245 self ::assertSame ($ expectedContainerType , $ backend ->getContainerType ());
46+ self ::assertSame ($ expectedContext , $ backend ->getContext ());
4347 self ::assertSame ($ expectedEmpty , $ backend ->isEmpty ());
4448 }
4549
4650 public function provideCreateFromArrayData (): iterable
4751 {
48- yield 'empty ' => [[], null , null , true ];
49- yield 'with type ' => [['type ' => 'custom ' ], 'custom ' , null , false ];
50- yield 'with container type ' => [['containerType ' => 'custom ' ], null , 'custom ' , false ];
51- yield 'with both types ' => [['type ' => 'custom ' , 'containerType ' => 'motsuc ' ], 'custom ' , 'motsuc ' , false ];
52+ yield 'empty ' => [
53+ [],
54+ null ,
55+ null ,
56+ null ,
57+ true ,
58+ ];
59+ yield 'with type ' => [
60+ [
61+ 'type ' => 'custom ' ,
62+ ],
63+ 'custom ' ,
64+ null ,
65+ null ,
66+ false ,
67+ ];
68+ yield 'with container type ' => [
69+ [
70+ 'containerType ' => 'custom ' ,
71+ ],
72+ null ,
73+ 'custom ' ,
74+ null ,
75+ false ,
76+ ];
77+ yield 'with context ' => [
78+ [
79+ 'context ' => 'wlm ' ,
80+ ],
81+ null ,
82+ null ,
83+ 'wlm ' ,
84+ false ,
85+ ];
86+ yield 'with all properties ' => [
87+ [
88+ 'type ' => 'custom ' ,
89+ 'containerType ' => 'motsuc ' ,
90+ 'context ' => 'wlm ' ,
91+ ],
92+ 'custom ' ,
93+ 'motsuc ' ,
94+ 'wlm ' ,
95+ false ,
96+ ];
5297 }
5398
5499 /**
@@ -62,20 +107,44 @@ public function testExportAsDataArray(Backend $backend, array $expectedResult):
62107 public function provideExportAsDataArrayData (): iterable
63108 {
64109 yield 'empty ' => [
65- new Backend (null , null ),
66- ['type ' => null , 'containerType ' => null ],
110+ new Backend (null , null , null ),
111+ [
112+ 'type ' => null ,
113+ 'containerType ' => null ,
114+ 'context ' => null ,
115+ ],
67116 ];
68117 yield 'with type ' => [
69- new Backend ('custom ' , null ),
70- ['type ' => 'custom ' , 'containerType ' => null ],
118+ new Backend ('custom ' , null , null ),
119+ [
120+ 'type ' => 'custom ' ,
121+ 'containerType ' => null ,
122+ 'context ' => null ,
123+ ],
71124 ];
72125 yield 'with container type ' => [
73- new Backend (null , 'custom ' ),
74- ['type ' => null , 'containerType ' => 'custom ' ],
126+ new Backend (null , 'custom ' , null ),
127+ [
128+ 'type ' => null ,
129+ 'containerType ' => 'custom ' ,
130+ 'context ' => null ,
131+ ],
132+ ];
133+ yield 'with context ' => [
134+ new Backend (null , null , 'wml ' ),
135+ [
136+ 'type ' => null ,
137+ 'containerType ' => null ,
138+ 'context ' => 'wml ' ,
139+ ],
75140 ];
76- yield 'with both types ' => [
77- new Backend ('custom ' , 'motsuc ' ),
78- ['type ' => 'custom ' , 'containerType ' => 'motsuc ' ],
141+ yield 'with all properties ' => [
142+ new Backend ('custom ' , 'motsuc ' , 'wml ' ),
143+ [
144+ 'type ' => 'custom ' ,
145+ 'containerType ' => 'motsuc ' ,
146+ 'context ' => 'wml ' ,
147+ ],
79148 ];
80149 }
81150}
0 commit comments