61 lines
1.8 KiB
PHP
61 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace KupShop\DevelopmentBundle\Command;
|
|
|
|
use Symfony\Component\Console\Command\Command;
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
class GetEnd2EndData extends Command
|
|
{
|
|
protected function configure()
|
|
{
|
|
$this
|
|
->setName('kupshop:get_end2end_data')
|
|
->setDescription('Get data for end2end tests');
|
|
}
|
|
|
|
protected function execute(InputInterface $input, OutputInterface $output)
|
|
{
|
|
$ret = [];
|
|
|
|
// Urls
|
|
$urls = [
|
|
'login' => ['s' => 'login'],
|
|
'logout' => ['s' => 'logout'],
|
|
'cart' => ['s' => 'cart'],
|
|
'orders' => ['s' => 'orders'],
|
|
'orderView' => ['s' => 'orderView', 'IDo' => '[ID]'],
|
|
];
|
|
|
|
foreach ($urls as $name => $url) {
|
|
$ret['urls'][$name] = createScriptURL($url);
|
|
}
|
|
|
|
// Products to buy
|
|
$productList = new \ProductList(true);
|
|
$productList->limit(2);
|
|
$productList->applyDefaultFilterParams();
|
|
$products = $productList->getProducts()->slice(0, 2);
|
|
|
|
$ret['order']['products'] = array_map(function ($product) {
|
|
return [
|
|
'id' => $product->id,
|
|
'id_variation' => getVal('variationId', $product),
|
|
'url' => createScriptURL(['s' => 'product', 'IDproduct' => $product->id, 'absolute' => true]),
|
|
];
|
|
}, array_values($products));
|
|
|
|
// Total order price
|
|
$totalPrice = \DecimalConstants::zero();
|
|
foreach ($products as $product) {
|
|
$totalPrice = $totalPrice->add($product->price_array['value_with_vat']);
|
|
}
|
|
$ret['order']['total_price'] = $totalPrice;
|
|
|
|
$output->write(json_encode($ret));
|
|
|
|
return 0;
|
|
}
|
|
}
|