Skip to content

Commit

Permalink
fix: Remove superfluous if checks
Browse files Browse the repository at this point in the history
  • Loading branch information
aragon999 committed Aug 19, 2024
1 parent 208b294 commit 5986a84
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions tests/Functional/Bundle/CustomerSearchBundleDBAL/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,20 +126,18 @@ protected function createCustomer(array $customer)
unset($customerData['addresses'], $customerData['orders'], $customerData['newsletter']);
$customerId = $this->insert('s_user', $customerData);

if (\array_key_exists('addresses', $customer)) {
foreach ($customer['addresses'] as $address) {
$address['user_id'] = $customerId;
$addressId = $this->insert('s_user_addresses', $address);

$this->connection->update(
's_user',
[
'default_billing_address_id' => $addressId,
'default_shipping_address_id' => $addressId,
],
['id' => $customerId]
);
}
foreach ($customer['addresses'] as $address) {
$address['user_id'] = $customerId;
$addressId = $this->insert('s_user_addresses', $address);

$this->connection->update(
's_user',
[
'default_billing_address_id' => $addressId,
'default_shipping_address_id' => $addressId,
],
['id' => $customerId]
);
}

if (\array_key_exists('orders', $customer)) {
Expand All @@ -159,11 +157,9 @@ protected function createCustomer(array $customer)
$order['userID'] = $customerId;
$orderId = $this->insert('s_order', $order);

if (\array_key_exists('details', $order)) {
foreach ($order['details'] as $detail) {
$detail['orderID'] = $orderId;
$this->insert('s_order_details', $detail);
}
foreach ($order['details'] as $detail) {
$detail['orderID'] = $orderId;
$this->insert('s_order_details', $detail);
}
}
}
Expand Down

0 comments on commit 5986a84

Please sign in to comment.