12 use PHPUnit_Framework_MockObject_MockObject as MockObject;
22 private $countryProvider;
36 $this->directory = $this->getMockBuilder(Data::class)
37 ->disableOriginalConstructor()
38 ->setMethods([
'getDefaultCountry'])
41 $this->quote = $this->getMockBuilder(Quote::class)
42 ->disableOriginalConstructor()
43 ->setMethods([
'getBillingAddress',
'getShippingAddress'])
54 $address = $this->getMockBuilder(Address::class)
55 ->disableOriginalConstructor()
56 ->setMethods([
'getCountry'])
59 $this->quote->expects(static::once())
60 ->method(
'getBillingAddress')
63 $this->quote->expects(static::never())
64 ->method(
'getShippingAddress');
66 $address->expects(static::exactly(2))
67 ->method(
'getCountry')
69 $this->directory->expects(static::never())
70 ->method(
'getDefaultCountry');
72 static::assertEquals(
'UK', $this->countryProvider->getCountry($this->quote));
80 $address = $this->getMockBuilder(Address::class)
81 ->disableOriginalConstructor()
82 ->setMethods([
'getCountry'])
85 $this->quote->expects(static::never())
86 ->method(
'getShippingAddress');
87 $this->quote->expects(static::once())
88 ->method(
'getBillingAddress')
92 ->method(
'getCountry')
94 $this->directory->expects(static::once())
95 ->method(
'getDefaultCountry')
97 static::assertEquals(
'US', $this->countryProvider->getCountry($this->quote));
105 $address = $this->getMockBuilder(Address::class)
106 ->disableOriginalConstructor()
107 ->setMethods([
'getCountry'])
110 $this->quote->expects(static::once())
111 ->method(
'getBillingAddress')
114 $this->quote->expects(static::once())
115 ->method(
'getShippingAddress')
118 $address->expects(static::exactly(2))
119 ->method(
'getCountry')
122 $this->directory->expects(static::never())
123 ->method(
'getDefaultCountry');
125 static::assertEquals(
'CA', $this->countryProvider->getCountry($this->quote));
testGetCountryForBillingAddressWithoutCountry()
testGetCountryShippingAddress()