-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ee06528
commit e4859d7
Showing
2 changed files
with
49 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,11 @@ | |
|
||
namespace Tests\App\Functional\PersonalData; | ||
|
||
use App\DataFixtures\Demo\ComplaintStatusDataFixture; | ||
use App\DataFixtures\Demo\CountryDataFixture; | ||
use App\DataFixtures\Demo\CurrencyDataFixture; | ||
use App\DataFixtures\Demo\OrderStatusDataFixture; | ||
use App\DataFixtures\Demo\PricingGroupDataFixture; | ||
use App\Model\Customer\User\CustomerUser; | ||
use App\Model\Customer\User\CustomerUserData; | ||
use App\Model\Order\Item\OrderItem; | ||
|
@@ -18,10 +23,7 @@ | |
use Shopsys\FrameworkBundle\Model\Complaint\ComplaintData; | ||
use Shopsys\FrameworkBundle\Model\Complaint\ComplaintItem; | ||
use Shopsys\FrameworkBundle\Model\Complaint\Status\ComplaintStatus; | ||
use Shopsys\FrameworkBundle\Model\Complaint\Status\ComplaintStatusData; | ||
use Shopsys\FrameworkBundle\Model\Complaint\Status\ComplaintStatusTypeEnum; | ||
use Shopsys\FrameworkBundle\Model\Country\Country; | ||
use Shopsys\FrameworkBundle\Model\Country\CountryData; | ||
use Shopsys\FrameworkBundle\Model\Customer\BillingAddress; | ||
use Shopsys\FrameworkBundle\Model\Customer\BillingAddressData; | ||
use Shopsys\FrameworkBundle\Model\Customer\Customer; | ||
|
@@ -30,19 +32,16 @@ | |
use Shopsys\FrameworkBundle\Model\Customer\DeliveryAddressData; | ||
use Shopsys\FrameworkBundle\Model\Order\Item\OrderItemTypeEnum; | ||
use Shopsys\FrameworkBundle\Model\Pricing\Currency\Currency; | ||
use Shopsys\FrameworkBundle\Model\Pricing\Currency\CurrencyData; | ||
use Shopsys\FrameworkBundle\Model\Pricing\Group\PricingGroup; | ||
use Shopsys\FrameworkBundle\Model\Pricing\Group\PricingGroupData; | ||
use Shopsys\FrameworkBundle\Model\Pricing\Price; | ||
use Tests\App\Functional\Model\Order\TestOrderProvider; | ||
use Tests\App\Test\TransactionFunctionalTestCase; | ||
use Twig\Environment; | ||
|
||
class PersonalDataExportXmlTest extends TransactionFunctionalTestCase | ||
{ | ||
protected const EMAIL = '[email protected]'; | ||
protected const EXPECTED_XML_FILE_NAME = 'test.xml'; | ||
protected const DOMAIN_ID_FIRST = Domain::FIRST_DOMAIN_ID; | ||
protected const string EMAIL = '[email protected]'; | ||
protected const string EXPECTED_XML_FILE_NAME = 'test.xml'; | ||
|
||
/** | ||
* @inject | ||
|
@@ -51,7 +50,7 @@ class PersonalDataExportXmlTest extends TransactionFunctionalTestCase | |
|
||
public function testExportXml(): void | ||
{ | ||
$country = $this->createCountry(); | ||
$country = $this->getReference(CountryDataFixture::COUNTRY_CZECH_REPUBLIC, Country::class); | ||
|
||
$customerData = new CustomerData(); | ||
$customerData->domainId = Domain::FIRST_DOMAIN_ID; | ||
|
@@ -64,11 +63,8 @@ public function testExportXml(): void | |
$customer->edit($customerData); | ||
|
||
$customerUser = $this->createCustomerUser($customer); | ||
$status = $this->createMock(OrderStatus::class); | ||
$currencyData = new CurrencyData(); | ||
$currencyData->name = 'CZK'; | ||
$currencyData->code = 'CZK'; | ||
$currency = new Currency($currencyData); | ||
$currency = $this->getReference(CurrencyDataFixture::CURRENCY_CZK, Currency::class); | ||
$status = $this->getReference(OrderStatusDataFixture::ORDER_STATUS_NEW, OrderStatus::class); | ||
$order = $this->createOrder($currency, $status, $country); | ||
/** @var \App\Model\Product\Product $product */ | ||
$product = $this->createMock(Product::class); | ||
|
@@ -94,24 +90,12 @@ public function testExportXml(): void | |
$this->assertXmlStringEqualsXmlFile(__DIR__ . '/Resources/' . self::EXPECTED_XML_FILE_NAME, $generatedXml); | ||
} | ||
|
||
/** | ||
* @return \Shopsys\FrameworkBundle\Model\Country\Country | ||
*/ | ||
private function createCountry() | ||
{ | ||
$countryData = new CountryData(); | ||
$countryData->names = ['cz' => 'Czech Republic']; | ||
$countryData->code = 'CZ'; | ||
|
||
return new Country($countryData); | ||
} | ||
|
||
/** | ||
* @param \Shopsys\FrameworkBundle\Model\Country\Country $country | ||
* @param \Shopsys\FrameworkBundle\Model\Customer\Customer $customer | ||
* @return \Shopsys\FrameworkBundle\Model\Customer\BillingAddress | ||
*/ | ||
private function createBillingAddress(Country $country, Customer $customer) | ||
private function createBillingAddress(Country $country, Customer $customer): BillingAddress | ||
{ | ||
$billingAddressData = new BillingAddressData(); | ||
$billingAddressData->country = $country; | ||
|
@@ -132,7 +116,7 @@ private function createBillingAddress(Country $country, Customer $customer) | |
* @param \Shopsys\FrameworkBundle\Model\Customer\Customer $customer | ||
* @return \Shopsys\FrameworkBundle\Model\Customer\DeliveryAddress | ||
*/ | ||
private function createDeliveryAddress(Country $country, Customer $customer) | ||
private function createDeliveryAddress(Country $country, Customer $customer): DeliveryAddress | ||
{ | ||
$deliveryAddressData = new DeliveryAddressData(); | ||
$deliveryAddressData->country = $country; | ||
|
@@ -152,16 +136,14 @@ private function createDeliveryAddress(Country $country, Customer $customer) | |
* @param \Shopsys\FrameworkBundle\Model\Customer\Customer $customer | ||
* @return \App\Model\Customer\User\CustomerUser | ||
*/ | ||
private function createCustomerUser(Customer $customer) | ||
private function createCustomerUser(Customer $customer): CustomerUser | ||
{ | ||
$pricingGroupData = new PricingGroupData(); | ||
$pricingGroupData->name = 'name'; | ||
$pricingGroup = new PricingGroup($pricingGroupData, Domain::FIRST_DOMAIN_ID); | ||
$pricingGroup = $this->getReferenceForDomain(PricingGroupDataFixture::PRICING_GROUP_ORDINARY, Domain::FIRST_DOMAIN_ID, PricingGroup::class); | ||
|
||
$customerUserData = new CustomerUserData(); | ||
$customerUserData->firstName = 'Jaromír'; | ||
$customerUserData->lastName = 'Jágr'; | ||
$customerUserData->domainId = self::DOMAIN_ID_FIRST; | ||
$customerUserData->domainId = Domain::FIRST_DOMAIN_ID; | ||
$customerUserData->createdAt = new DateTime('2018-04-13'); | ||
$customerUserData->email = '[email protected]'; | ||
$customerUserData->telephone = '+420987654321'; | ||
|
@@ -184,7 +166,7 @@ private function createOrder(Currency $currency, OrderStatus $status, Country $c | |
$orderData->status = $status; | ||
$orderData->email = '[email protected]'; | ||
$orderData->createdAt = new DateTime('2018-04-13'); | ||
$orderData->domainId = self::DOMAIN_ID_FIRST; | ||
$orderData->domainId = Domain::FIRST_DOMAIN_ID; | ||
$orderData->lastName = 'Bořič'; | ||
$orderData->firstName = 'Adam'; | ||
$orderData->city = 'Liberec'; | ||
|
@@ -209,14 +191,13 @@ private function createOrder(Currency $currency, OrderStatus $status, Country $c | |
*/ | ||
private function createComplaint(Country $country, Order $order, CustomerUser $customerUser): Complaint | ||
{ | ||
$complaintStatusData = new ComplaintStatusData(); | ||
$complaintStatusData->name = ['cs' => 'name']; | ||
$complaintStatus = new ComplaintStatus($complaintStatusData, ComplaintStatusTypeEnum::STATUS_TYPE_NEW); | ||
$complaintStatus = $this->getReference(ComplaintStatusDataFixture::COMPLAINT_STATUS_NEW, ComplaintStatus::class); | ||
|
||
$complaintData = new ComplaintData(); | ||
$complaintData->domainId = self::DOMAIN_ID_FIRST; | ||
$complaintData->domainId = Domain::FIRST_DOMAIN_ID; | ||
$complaintData->number = '1523596513'; | ||
$complaintData->order = $order; | ||
$complaintData->createdAt = new DateTime('2018-04-13'); | ||
$complaintData->customerUser = $customerUser; | ||
$complaintData->deliveryFirstName = 'Adam'; | ||
$complaintData->deliveryLastName = 'Bořič'; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,11 +66,40 @@ | |
</item> | ||
</order_items> | ||
<order_other_data> | ||
<order_status/> | ||
<order_status><![CDATA[New]]></order_status> | ||
<phone><![CDATA[+420987654321]]></phone> | ||
<email><![CDATA[[email protected]]]></email> | ||
</order_other_data> | ||
</order> | ||
</customer_orders> | ||
<customer_complaints> | ||
<complaint> | ||
<complaint_number>1523596513</complaint_number> | ||
<complaint_create_date>2018-04-13T00:00:00+00:00</complaint_create_date> | ||
<complaint_addresses> | ||
<address> | ||
<firstname><![CDATA[Adam]]></firstname> | ||
<lastname><![CDATA[Bořič]]></lastname> | ||
<company_name><![CDATA[Shopsys]]></company_name> | ||
<street><![CDATA[Cihelní 5]]></street> | ||
<city><![CDATA[Liberec]]></city> | ||
<postal_code><![CDATA[65421]]></postal_code> | ||
<telephone><![CDATA[+420987654321]]></telephone> | ||
<country_code><![CDATA[CZ]]></country_code> | ||
</address> | ||
</complaint_addresses> | ||
<complaint_items> | ||
<item> | ||
<item_name/> | ||
<item_quantity/> | ||
<item_catnum/> | ||
<item_description/> | ||
</item> | ||
</complaint_items> | ||
<complaint_other_data> | ||
<complaint_status><![CDATA[New]]></complaint_status> | ||
</complaint_other_data> | ||
</complaint> | ||
</customer_complaints> | ||
</customer> | ||
</customers> |