71 lines
2.1 KiB
PHP
71 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace KupShop\DropshipBundle\Tests;
|
|
|
|
use KupShop\DropshipBundle\Transfer\ExpandoTransfer;
|
|
use KupShop\DropshipBundle\Util\DropshipmentUtil;
|
|
use PHPUnit\DbUnit\DataSet\ArrayDataSet;
|
|
use PHPUnit\DbUnit\DataSet\DefaultDataSet;
|
|
|
|
class TransferTest extends \DatabaseTestCase
|
|
{
|
|
protected ExpandoTransfer $expandoTransfer;
|
|
protected DropshipmentUtil $dropShipmentUtil;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->expandoTransfer = $this->get(ExpandoTransfer::class);
|
|
$this->dropShipmentUtil = $this->get(DropshipmentUtil::class);
|
|
}
|
|
|
|
public function testStoresExpandoTransfer(): void
|
|
{
|
|
$this->expandoTransfer->setup($this->dropShipmentUtil->getDropshipment(2)); // expando
|
|
$this->expandoTransfer->dropshipment['source_url'] = __DIR__.'/files/xml_expando_feed.xml';
|
|
|
|
$stores_items = sqlQueryBuilder()
|
|
->select('*')
|
|
->from('stores_items')
|
|
->where('id_product = 76 AND id_variation = 401')
|
|
->execute()
|
|
->fetchAllAssociative();
|
|
|
|
$variation = sqlQueryBuilder()
|
|
->select('*')
|
|
->from('products_variations')
|
|
->where('id = 401 AND id_product = 76')
|
|
->execute()
|
|
->fetchAssociative();
|
|
|
|
$this->assertEquals(47, $stores_items[1]['quantity']);
|
|
$this->assertEquals(319, $variation['in_store']);
|
|
|
|
$this->expandoTransfer->process();
|
|
|
|
$stores_items = sqlQueryBuilder()
|
|
->select('*')
|
|
->from('stores_items')
|
|
->where('id_product = 76 AND id_variation = 401')
|
|
->execute()
|
|
->fetchAllAssociative();
|
|
|
|
$variation = sqlQueryBuilder()
|
|
->select('*')
|
|
->from('products_variations')
|
|
->where('id = 401 AND id_product = 76')
|
|
->execute()
|
|
->fetchAssociative();
|
|
|
|
// Kontrola odebraného kusu
|
|
$this->assertEquals(46, $stores_items[1]['quantity']);
|
|
$this->assertEquals(318, $variation['in_store']);
|
|
}
|
|
|
|
public function getDataSet(): ArrayDataSet|DefaultDataSet
|
|
{
|
|
return $this->getJsonDataSetFromFile();
|
|
}
|
|
}
|