File tree Expand file tree Collapse file tree 3 files changed +6
-9
lines changed
app/code/Magento/Directory Expand file tree Collapse file tree 3 files changed +6
-9
lines changed Original file line number Diff line number Diff line change @@ -97,16 +97,16 @@ public function getCountryInfo($countryId)
97
97
);
98
98
99
99
$ countriesCollection = $ this ->directoryHelper ->getCountryCollection ($ store )->load ();
100
+ $ regions = $ this ->directoryHelper ->getRegionData ();
101
+ $ country = $ countriesCollection ->getItemById ($ countryId );
100
102
101
- if ($ countriesCollection -> count () == 0 ) {
103
+ if (! $ country ) {
102
104
throw new NoSuchEntityException (
103
105
__ (
104
106
'Requested country is not available. '
105
107
)
106
108
);
107
109
}
108
- $ regions = $ this ->directoryHelper ->getRegionData ();
109
- $ country = $ countriesCollection ->getItemById ($ countryId );
110
110
$ countryInfo = $ this ->setCountryInfo ($ country , $ regions , $ storeLocale );
111
111
112
112
return $ countryInfo ;
Original file line number Diff line number Diff line change @@ -143,7 +143,7 @@ public function loadByStore($store = null)
143
143
* Loads Item By Id
144
144
*
145
145
* @param string $countryId
146
- * @return \Magento\Directory\Model\ResourceModel\Country
146
+ * @return \Magento\Directory\Model\ResourceModel\Country|null
147
147
*/
148
148
public function getItemById ($ countryId )
149
149
{
@@ -152,7 +152,7 @@ public function getItemById($countryId)
152
152
return $ country ;
153
153
}
154
154
}
155
- return $ this -> _countryFactory -> create () ;
155
+ return null ;
156
156
}
157
157
158
158
/**
Original file line number Diff line number Diff line change @@ -129,9 +129,7 @@ public function testGetCountryInfo()
129
129
'' ,
130
130
false
131
131
);
132
- $ countryCollection ->expects ($ this ->once ())->method ('addCountryIdFilter ' )->willReturnSelf ();
133
132
$ countryCollection ->expects ($ this ->once ())->method ('load ' )->willReturnSelf ();
134
- $ countryCollection ->expects ($ this ->once ())->method ('count ' )->willReturn (1 );
135
133
$ countryCollection ->expects ($ this ->once ())->method ('getItemById ' )->with ('AE ' )->willReturn ($ testCountryInfo );
136
134
137
135
$ this ->directoryHelper ->expects ($ this ->once ())->method ('getCountryCollection ' )->willReturn ($ countryCollection );
@@ -174,11 +172,10 @@ public function testGetCountryInfoNotFound()
174
172
'' ,
175
173
false
176
174
);
177
- $ countryCollection ->expects ($ this ->once ())->method ('addCountryIdFilter ' )->willReturnSelf ();
178
175
$ countryCollection ->expects ($ this ->once ())->method ('load ' )->willReturnSelf ();
179
- $ countryCollection ->expects ($ this ->once ())->method ('count ' )->willReturn (0 );
180
176
181
177
$ this ->directoryHelper ->expects ($ this ->once ())->method ('getCountryCollection ' )->willReturn ($ countryCollection );
178
+ $ countryCollection ->expects ($ this ->once ())->method ('getItemById ' )->willReturn (null );
182
179
$ this ->model ->getCountryInfo ('AE ' );
183
180
}
184
181
}
You can’t perform that action at this time.
0 commit comments