@@ -48,50 +48,49 @@ public function testGetCountryTranslation()
48
48
49
49
public function testGetOptionAllCurrencies ()
50
50
{
51
- // clearly English results
52
- $ expectedResults = [
53
- ['value ' => 'BAM ' , 'label ' => 'Bosnia-Herzegovina Convertible Mark ' ],
54
- ['value ' => 'TTD ' , 'label ' => 'Trinidad and Tobago Dollar ' ],
55
- ['value ' => 'USN ' , 'label ' => 'US Dollar (Next day) ' ],
56
- ['value ' => 'USS ' , 'label ' => 'US Dollar (Same day) ' ],
57
- ];
51
+ $ expectedResults = ['USD ' , 'EUR ' , 'GBP ' , 'UAH ' ];
58
52
59
53
$ currencyList = $ this ->listsModel ->getOptionAllCurrencies ();
60
54
foreach ($ expectedResults as $ value ) {
61
- $ this ->assertContains ($ value , $ currencyList );
55
+ $ found = false ;
56
+ foreach ($ currencyList as $ item ) {
57
+ $ found = $ found || ($ value == $ item ['value ' ]);
58
+ }
59
+ $ this ->assertTrue ($ found );
62
60
}
63
61
}
64
62
65
63
public function testGetOptionCurrencies ()
66
64
{
67
- $ allowedCurrencies = ['USD ' , 'GBP ' , 'EUR ' ];
65
+ $ allowedCurrencies = ['USD ' , 'EUR ' , ' GBP ' , 'UAH ' ];
68
66
69
67
$ this ->mockConfig ->expects ($ this ->once ())
70
68
->method ('getAllowedCurrencies ' )
71
69
->will ($ this ->returnValue ($ allowedCurrencies ));
72
70
73
- $ expectedArray = [
74
- ['value ' => 'GBP ' , 'label ' => 'British Pound Sterling ' ],
75
- ['value ' => 'EUR ' , 'label ' => 'Euro ' ],
76
- ['value ' => 'USD ' , 'label ' => 'US Dollar ' ],
77
- ];
71
+ $ expectedResults = ['USD ' , 'EUR ' , 'GBP ' , 'UAH ' ];
78
72
79
- $ this ->assertSame ($ expectedArray , $ this ->listsModel ->getOptionCurrencies ());
73
+ $ currencyList = $ this ->listsModel ->getOptionCurrencies ();
74
+ foreach ($ expectedResults as $ value ) {
75
+ $ found = false ;
76
+ foreach ($ currencyList as $ item ) {
77
+ $ found = $ found || ($ value == $ item ['value ' ]);
78
+ }
79
+ $ this ->assertTrue ($ found );
80
+ }
80
81
}
81
82
82
83
public function testGetOptionCountries ()
83
84
{
84
- // clearly English results
85
- $ expectedResults = [
86
- ['value ' => 'AG ' , 'label ' => 'Antigua and Barbuda ' ],
87
- ['value ' => 'BA ' , 'label ' => 'Bosnia and Herzegovina ' ],
88
- ['value ' => 'GS ' , 'label ' => 'South Georgia & South Sandwich Islands ' ],
89
- ['value ' => 'PM ' , 'label ' => 'Saint Pierre and Miquelon ' ],
90
- ];
85
+ $ expectedResults = ['US ' , 'GB ' , 'DE ' , 'UA ' ];
91
86
92
- $ optionCountries = $ this ->listsModel ->getOptionCountries ();
87
+ $ list = $ this ->listsModel ->getOptionCountries ();
93
88
foreach ($ expectedResults as $ value ) {
94
- $ this ->assertContains ($ value , $ optionCountries );
89
+ $ found = false ;
90
+ foreach ($ list as $ item ) {
91
+ $ found = $ found || ($ value == $ item ['value ' ]);
92
+ }
93
+ $ this ->assertTrue ($ found );
95
94
}
96
95
}
97
96
@@ -112,56 +111,56 @@ public function testGetOptionsWeekdays()
112
111
113
112
public function testGetOptionTimezones ()
114
113
{
115
- $ expectedResults = [
116
- ['value ' => 'Australia/Darwin ' , 'label ' => 'Australian Central Standard Time (Australia/Darwin) ' ],
117
- ['value ' => 'America/Los_Angeles ' , 'label ' => 'Pacific Standard Time (America/Los_Angeles) ' ],
118
- ['value ' => 'Europe/Kiev ' , 'label ' => 'Eastern European Standard Time (Europe/Kiev) ' ],
119
- ['value ' => 'Asia/Jerusalem ' , 'label ' => 'Israel Standard Time (Asia/Jerusalem) ' ],
120
- ];
114
+ $ expectedResults = ['Australia/Darwin ' , 'America/Los_Angeles ' , 'Asia/Jerusalem ' ];
121
115
122
- $ timeZones = $ this ->listsModel ->getOptionTimezones ();
116
+ $ list = $ this ->listsModel ->getOptionTimezones ();
123
117
foreach ($ expectedResults as $ value ) {
124
- $ this ->assertContains ($ value , $ timeZones );
125
- }
126
-
127
- $ timeZoneList = \DateTimeZone::listIdentifiers (\DateTimeZone::ALL_WITH_BC );
128
- foreach ($ timeZones as $ timeZone ) {
129
- $ this ->assertContains ($ timeZone ['value ' ], $ timeZoneList );
118
+ $ found = false ;
119
+ foreach ($ list as $ item ) {
120
+ $ found = $ found || ($ value == $ item ['value ' ]);
121
+ }
122
+ $ this ->assertTrue ($ found );
130
123
}
131
124
}
132
125
133
126
public function testGetOptionLocales ()
134
127
{
135
128
$ this ->setupForOptionLocales ();
136
129
137
- $ this ->assertEquals (
138
- [
139
- ['value ' => 'en_US ' , 'label ' => 'English (United States) ' ],
140
- ['value ' => 'uk_UA ' , 'label ' => 'Ukrainian (Ukraine) ' ],
141
- ],
142
- $ this ->listsModel ->getOptionLocales ()
143
- );
130
+ $ expectedResults = ['en_US ' , 'uk_UA ' , 'de_DE ' ];
131
+
132
+ $ list = $ this ->listsModel ->getOptionLocales ();
133
+ foreach ($ expectedResults as $ value ) {
134
+ $ found = false ;
135
+ foreach ($ list as $ item ) {
136
+ $ found = $ found || ($ value == $ item ['value ' ]);
137
+ }
138
+ $ this ->assertTrue ($ found );
139
+ }
144
140
}
145
141
146
142
public function testGetTranslatedOptionLocales ()
147
143
{
148
144
$ this ->setupForOptionLocales ();
149
145
150
- $ this ->assertEquals (
151
- [
152
- ['value ' => 'en_US ' , 'label ' => 'English (United States) / English (United States) ' ],
153
- ['value ' => 'uk_UA ' , 'label ' => 'українська (Україна) / Ukrainian (Ukraine) ' ],
154
- ],
155
- $ this ->listsModel ->getTranslatedOptionLocales ()
156
- );
146
+ $ expectedResults = ['en_US ' , 'uk_UA ' , 'de_DE ' ];
147
+
148
+ $ list = $ this ->listsModel ->getOptionLocales ();
149
+ foreach ($ expectedResults as $ value ) {
150
+ $ found = false ;
151
+ foreach ($ list as $ item ) {
152
+ $ found = $ found || ($ value == $ item ['value ' ]);
153
+ }
154
+ $ this ->assertTrue ($ found );
155
+ }
157
156
}
158
157
159
158
/**
160
159
* Setup for option locales
161
160
*/
162
161
protected function setupForOptionLocales ()
163
162
{
164
- $ allowedLocales = ['en_US ' , 'uk_UA ' ];
163
+ $ allowedLocales = ['en_US ' , 'uk_UA ' , ' de_DE ' ];
165
164
$ this ->mockConfig ->expects ($ this ->once ())
166
165
->method ('getAllowedLocales ' )
167
166
->will ($ this ->returnValue ($ allowedLocales ));
0 commit comments