Begin FormatterData
modifié: core/lib/Thelia/Core/FileFormat/Formatter/FormatterData.php nouveau fichier: core/lib/Thelia/Tests/FileFormat/Formatter/FormatterDataTest.php
This commit is contained in:
@@ -12,6 +12,8 @@
|
||||
|
||||
namespace Thelia\Core\FileFormat\Formatter;
|
||||
use Propel\Runtime\ActiveQuery\ModelCriteria;
|
||||
use Propel\Runtime\Collection\ArrayCollection;
|
||||
use Propel\Runtime\Collection\ObjectCollection;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
|
||||
/**
|
||||
@@ -34,15 +36,31 @@ class FormatterData
|
||||
|
||||
public function loadModelCriteria(ModelCriteria $criteria)
|
||||
{
|
||||
|
||||
$propelData =
|
||||
$criteria
|
||||
->find()
|
||||
;
|
||||
$propelData = $criteria->find();
|
||||
|
||||
if (empty($propelData)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$asColumns = $propelData->getFormatter()->getAsColumns();
|
||||
|
||||
if (empty($asColumns) && $propelData instanceof ObjectCollection) {
|
||||
/**
|
||||
* Full request ( without select nor join )
|
||||
*/
|
||||
} elseif (empty($asColumns) && $propelData instanceof ArrayCollection) {
|
||||
/**
|
||||
* Request with joins, but without select
|
||||
*/
|
||||
} elseif (count($asColumns) > 1) {
|
||||
/**
|
||||
* Request with multiple select
|
||||
*/
|
||||
} elseif (count($asColumns) === 1) {
|
||||
/**
|
||||
* Request with one select
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Tests\FileFormat\Formatter;
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
use Thelia\Core\FileFormat\Formatter\FormatterData;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Model\Base\ProductQuery;
|
||||
use Thelia\Model\Base\ProductSaleElementsQuery;
|
||||
use Thelia\Model\LangQuery;
|
||||
use Thelia\Model\Product;
|
||||
|
||||
/**
|
||||
* Class FormatterDataTest
|
||||
* @package Thelia\Tests\FileFormat\Formatter
|
||||
* @author Benjamin Perche <bperche@openstudio.fr>
|
||||
*/
|
||||
class FormatterDataTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
protected $data;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
new Translator(new Container());
|
||||
$this->data = new FormatterData();
|
||||
|
||||
$query = ProductQuery::create()
|
||||
->filterById([3,4,5], Criteria::IN);
|
||||
|
||||
$this->data->loadModelCriteria($query);
|
||||
|
||||
$query = ProductSaleElementsQuery::create()
|
||||
->joinProduct()
|
||||
->select(["ProductSaleElements.id", "Product.id"])
|
||||
->filterById([3,4,5], Criteria::IN)
|
||||
;
|
||||
|
||||
$this->data->loadModelCriteria($query);
|
||||
|
||||
$query = ProductSaleElementsQuery::create()
|
||||
->joinProduct()
|
||||
->select(["ProductSaleElements.id"])
|
||||
->filterById([3,4,5], Criteria::IN)
|
||||
;
|
||||
|
||||
$this->data->loadModelCriteria($query);
|
||||
|
||||
$query = ProductQuery::create()
|
||||
->joinProductSaleElements()
|
||||
->filterById([3,4,5], Criteria::IN);
|
||||
|
||||
$this->data->loadModelCriteria($query);
|
||||
}
|
||||
|
||||
public function testA()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user