Skip to content
Snippets Groups Projects
Verified Commit 85b0da07 authored by Florian Azizian's avatar Florian Azizian
Browse files

FEAT #9107 admin shipping

parent 54e3fe58
No related branches found
No related tags found
No related merge requests found
......@@ -31,6 +31,7 @@ abstract class EntityModelAbstract
'table' => empty($aArgs['table']) ? ['entities'] : $aArgs['table'],
'where' => empty($aArgs['where']) ? [] : $aArgs['where'],
'data' => empty($aArgs['data']) ? [] : $aArgs['data'],
'left_join' => empty($aArgs['left_join']) ? [] : $aArgs['left_join'],
'order_by' => empty($aArgs['orderBy']) ? [] : $aArgs['orderBy'],
'limit' => empty($aArgs['limit']) ? 0 : $aArgs['limit']
]);
......
......@@ -54,10 +54,11 @@ class ShippingController
$shippingInfo['entities'] = (array)json_decode($shippingInfo['entities']);
$allEntities = EntityModel::get([
'select' => ['e1.id', 'e1.entity_id', 'e1.entity_label', 'e2.id as parent_id'],
'table' => ['entities e1, entities e2'],
'where' => ['e1.enabled = ?', 'e1.parent_entity_id = e2.entity_id'],
'data' => ['Y']
'select' => ['e1.id', 'e1.entity_id', 'e1.entity_label', 'e2.id as parent_id'],
'table' => ['entities e1', 'entities e2'],
'left_join' => ['e1.parent_entity_id = e2.entity_id'],
'where' => ['e1.enabled = ?'],
'data' => ['Y']
]);
foreach ($allEntities as $key => $value) {
......@@ -79,9 +80,7 @@ class ShippingController
$allEntities[$key]['text'] = $value['entity_label'];
}
$shippingInfo['entities'] = $allEntities;
return $response->withJson($shippingInfo);
return $response->withJson(['shipping' => $shippingInfo, 'entities' => $allEntities]);
}
public function create(Request $request, Response $response)
......@@ -234,10 +233,11 @@ class ShippingController
}
$allEntities = EntityModel::get([
'select' => ['e1.id', 'e1.entity_id', 'e1.entity_label', 'e2.id as parent_id'],
'table' => ['entities e1, entities e2'],
'where' => ['e1.enabled = ?', 'e1.parent_entity_id = e2.entity_id'],
'data' => ['Y']
'select' => ['e1.id', 'e1.entity_id', 'e1.entity_label', 'e2.id as parent_id'],
'table' => ['entities e1', 'entities e2'],
'left_join' => ['e1.parent_entity_id = e2.entity_id'],
'where' => ['e1.enabled = ?'],
'data' => ['Y']
]);
print_r($allEntities);
......@@ -250,7 +250,7 @@ class ShippingController
$allEntities[$key]['parent'] = (string)$value['parent_id'];
$allEntities[$key]['icon'] = "fa fa-sitemap";
}
$allEntities[$key]['state']['opened'] = false;
$allEntities[$key]['allowed'] = true;
$allEntities[$key]['state']['opened'] = true;
......
......@@ -69,16 +69,17 @@ class ShippingControllerTest extends TestCase
$responseBody = json_decode((string)$response->getBody());
$this->assertNotEmpty($responseBody);
$this->assertSame('TEST', $responseBody->label);
$this->assertSame('description du TEST', $responseBody->description);
$this->assertSame('color', $responseBody->options->shaping[0]);
$this->assertSame('both_sides', $responseBody->options->shaping[1]);
$this->assertSame('address_page', $responseBody->options->shaping[2]);
$this->assertSame('small_simple', $responseBody->options->envelopMode);
$this->assertSame('fast', $responseBody->options->sendMode);
$this->assertSame(1, $responseBody->fee->first_page);
$this->assertSame(2, $responseBody->fee->next_page);
$this->assertSame(12, $responseBody->fee->postage_price);
$this->assertSame('TEST', $responseBody->shipping->label);
$this->assertSame('description du TEST', $responseBody->shipping->description);
$this->assertSame('color', $responseBody->shipping->options->shaping[0]);
$this->assertSame('both_sides', $responseBody->shipping->options->shaping[1]);
$this->assertSame('address_page', $responseBody->shipping->options->shaping[2]);
$this->assertSame('small_simple', $responseBody->shipping->options->envelopMode);
$this->assertSame('fast', $responseBody->shipping->options->sendMode);
$this->assertSame(1, $responseBody->shipping->fee->first_page);
$this->assertSame(2, $responseBody->shipping->fee->next_page);
$this->assertSame(12, $responseBody->shipping->fee->postage_price);
$this->assertNotNull($responseBody->shipping->entities);
$this->assertNotNull($responseBody->entities);
######## ERROR #############
......@@ -137,15 +138,15 @@ class ShippingControllerTest extends TestCase
$responseBody = json_decode((string)$response->getBody());
$this->assertNotEmpty($responseBody);
$this->assertSame('TEST 2', $responseBody->label);
$this->assertSame('description du test 2', $responseBody->description);
$this->assertSame('color', $responseBody->options->shaping[0]);
$this->assertSame('address_page', $responseBody->options->shaping[1]);
$this->assertSame('big_simple', $responseBody->options->envelopMode);
$this->assertSame('fast', $responseBody->options->sendMode);
$this->assertSame(10, $responseBody->fee->first_page);
$this->assertSame(20, $responseBody->fee->next_page);
$this->assertSame(12, $responseBody->fee->postage_price);
$this->assertSame('TEST 2', $responseBody->shipping->label);
$this->assertSame('description du test 2', $responseBody->shipping->description);
$this->assertSame('color', $responseBody->shipping->options->shaping[0]);
$this->assertSame('address_page', $responseBody->shipping->options->shaping[1]);
$this->assertSame('big_simple', $responseBody->shipping->options->envelopMode);
$this->assertSame('fast', $responseBody->shipping->options->sendMode);
$this->assertSame(10, $responseBody->shipping->fee->first_page);
$this->assertSame(20, $responseBody->shipping->fee->next_page);
$this->assertSame(12, $responseBody->shipping->fee->postage_price);
$this->assertNotNull($responseBody->entities);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment