Fix tests
modifié: core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilder.php modifié: core/lib/Thelia/ImportExport/Export/Type/ContentExport.php modifié: core/lib/Thelia/Tests/ImportExport/Export/ContentExportTest.php
This commit is contained in:
@@ -73,7 +73,11 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
public function addFile($filePath, $directoryInArchive = "/", $name = null, $isOnline = false)
|
public function addFile($filePath, $directoryInArchive = "/", $name = null, $isOnline = false)
|
||||||
{
|
{
|
||||||
if (!empty($name)) {
|
if (!empty($name)) {
|
||||||
$directoryInArchive .= DS . dirname($name);
|
$dirName = dirname($name);
|
||||||
|
if ($dirName == ".") {
|
||||||
|
$dirName = "";
|
||||||
|
}
|
||||||
|
$directoryInArchive .= DS . $dirName;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($name) || !is_scalar($name)) {
|
if (empty($name) || !is_scalar($name)) {
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ use Thelia\Model\FolderDocumentQuery;
|
|||||||
use Thelia\Model\FolderImageQuery;
|
use Thelia\Model\FolderImageQuery;
|
||||||
use Thelia\Model\Lang;
|
use Thelia\Model\Lang;
|
||||||
use Thelia\Model\Map\ContentDocumentTableMap;
|
use Thelia\Model\Map\ContentDocumentTableMap;
|
||||||
|
use Thelia\Model\Map\ContentFolderTableMap;
|
||||||
use Thelia\Model\Map\ContentI18nTableMap;
|
use Thelia\Model\Map\ContentI18nTableMap;
|
||||||
use Thelia\Model\Map\ContentTableMap;
|
use Thelia\Model\Map\ContentTableMap;
|
||||||
use Thelia\Model\Map\FolderDocumentTableMap;
|
use Thelia\Model\Map\FolderDocumentTableMap;
|
||||||
@@ -84,14 +85,31 @@ class ContentExport extends ExportHandler implements
|
|||||||
|
|
||||||
|
|
||||||
$query = ContentQuery::create()
|
$query = ContentQuery::create()
|
||||||
|
->select([
|
||||||
|
ContentTableMap::ID,
|
||||||
|
ContentTableMap::VISIBLE,
|
||||||
|
"content_TITLE",
|
||||||
|
"content_CHAPO",
|
||||||
|
"content_DESCRIPTION",
|
||||||
|
"content_CONCLUSION",
|
||||||
|
"content_seo_TITLE",
|
||||||
|
"content_seo_DESCRIPTION",
|
||||||
|
"content_seo_KEYWORDS",
|
||||||
|
"url_URL",
|
||||||
|
"folder_TITLE",
|
||||||
|
"folder_ID",
|
||||||
|
"folder_IS_DEFAULT"
|
||||||
|
])
|
||||||
->_if($this->isImageExport())
|
->_if($this->isImageExport())
|
||||||
->useContentImageQuery("content_image_join", Criteria::LEFT_JOIN)
|
->useContentImageQuery("content_image_join", Criteria::LEFT_JOIN)
|
||||||
->addAsColumn("content_IMAGES", "GROUP_CONCAT(DISTINCT `content_image_join`.FILE)")
|
->addAsColumn("content_IMAGES", "GROUP_CONCAT(DISTINCT `content_image_join`.FILE)")
|
||||||
|
->addSelectColumn("content_IMAGES")
|
||||||
->endUse()
|
->endUse()
|
||||||
->_endif()
|
->_endif()
|
||||||
->_if($this->isDocumentExport())
|
->_if($this->isDocumentExport())
|
||||||
->useContentDocumentQuery()
|
->useContentDocumentQuery()
|
||||||
->addAsColumn("content_DOCUMENTS", "GROUP_CONCAT(DISTINCT ".ContentDocumentTableMap::FILE.")")
|
->addAsColumn("content_DOCUMENTS", "GROUP_CONCAT(DISTINCT ".ContentDocumentTableMap::FILE.")")
|
||||||
|
->addSelectColumn("content_DOCUMENTS")
|
||||||
->endUse()
|
->endUse()
|
||||||
->_endif()
|
->_endif()
|
||||||
->useContentFolderQuery(null, Criteria::LEFT_JOIN)
|
->useContentFolderQuery(null, Criteria::LEFT_JOIN)
|
||||||
@@ -99,11 +117,13 @@ class ContentExport extends ExportHandler implements
|
|||||||
->_if($this->isDocumentExport())
|
->_if($this->isDocumentExport())
|
||||||
->useFolderDocumentQuery()
|
->useFolderDocumentQuery()
|
||||||
->addAsColumn("folder_DOCUMENTS", "GROUP_CONCAT(DISTINCT ".FolderDocumentTableMap::FILE.")")
|
->addAsColumn("folder_DOCUMENTS", "GROUP_CONCAT(DISTINCT ".FolderDocumentTableMap::FILE.")")
|
||||||
|
->addSelectColumn("folder_DOCUMENTS")
|
||||||
->endUse()
|
->endUse()
|
||||||
->_endif()
|
->_endif()
|
||||||
->_if($this->isImageExport())
|
->_if($this->isImageExport())
|
||||||
->useFolderImageQuery(null, Criteria::LEFT_JOIN)
|
->useFolderImageQuery(null, Criteria::LEFT_JOIN)
|
||||||
->addAsColumn("folder_IMAGES", "GROUP_CONCAT(DISTINCT ".FolderImageTableMap::FILE.")")
|
->addAsColumn("folder_IMAGES", "GROUP_CONCAT(DISTINCT ".FolderImageTableMap::FILE.")")
|
||||||
|
->addSelectColumn("folder_IMAGES")
|
||||||
->endUse()
|
->endUse()
|
||||||
->_endif()
|
->_endif()
|
||||||
->addJoinObject($folderI18nJoin, "folder_i18n_join")
|
->addJoinObject($folderI18nJoin, "folder_i18n_join")
|
||||||
@@ -111,6 +131,7 @@ class ContentExport extends ExportHandler implements
|
|||||||
->addAsColumn("folder_TITLE", FolderI18nTableMap::TITLE)
|
->addAsColumn("folder_TITLE", FolderI18nTableMap::TITLE)
|
||||||
->addAsColumn("folder_ID", FolderTableMap::ID)
|
->addAsColumn("folder_ID", FolderTableMap::ID)
|
||||||
->endUse()
|
->endUse()
|
||||||
|
->addAsColumn("folder_IS_DEFAULT", ContentFolderTableMap::DEFAULT_FOLDER)
|
||||||
->endUse()
|
->endUse()
|
||||||
->addJoinObject($contentI18nJoin, "content_i18n_join")
|
->addJoinObject($contentI18nJoin, "content_i18n_join")
|
||||||
->addJoinCondition("content_i18n_join", ContentI18nTableMap::LOCALE . " = ?", $locale, null, \PDO::PARAM_STR)
|
->addJoinCondition("content_i18n_join", ContentI18nTableMap::LOCALE . " = ?", $locale, null, \PDO::PARAM_STR)
|
||||||
@@ -137,44 +158,10 @@ class ContentExport extends ExportHandler implements
|
|||||||
\PDO::PARAM_STR
|
\PDO::PARAM_STR
|
||||||
)
|
)
|
||||||
->addAsColumn("url_URL", RewritingUrlTableMap::URL)
|
->addAsColumn("url_URL", RewritingUrlTableMap::URL)
|
||||||
->select([
|
|
||||||
ContentTableMap::ID,
|
|
||||||
ContentTableMap::VISIBLE,
|
|
||||||
"content_TITLE",
|
|
||||||
"content_CHAPO",
|
|
||||||
"content_DESCRIPTION",
|
|
||||||
"content_CONCLUSION",
|
|
||||||
"content_seo_TITLE",
|
|
||||||
"content_seo_DESCRIPTION",
|
|
||||||
"content_seo_KEYWORDS",
|
|
||||||
"url_URL",
|
|
||||||
"folder_TITLE",
|
|
||||||
"folder_ID",
|
|
||||||
])
|
|
||||||
->groupBy(ContentTableMap::ID)
|
->groupBy(ContentTableMap::ID)
|
||||||
->groupBy("folder_ID")
|
->groupBy("folder_ID")
|
||||||
;
|
;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var ContentQuery $query
|
|
||||||
*/
|
|
||||||
if ($this->isDocumentExport()) {
|
|
||||||
$query->select($query->getSelect() + [
|
|
||||||
"folder_DOCUMENTS",
|
|
||||||
"content_DOCUMENTS",
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var ContentQuery $query
|
|
||||||
*/
|
|
||||||
if ($this->isImageExport()) {
|
|
||||||
$query->select($query->getSelect() + [
|
|
||||||
"folder_IMAGES",
|
|
||||||
"content_IMAGES",
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$dataSet = $query
|
$dataSet = $query
|
||||||
->find()
|
->find()
|
||||||
->toArray()
|
->toArray()
|
||||||
@@ -227,6 +214,7 @@ class ContentExport extends ExportHandler implements
|
|||||||
"seo_keywords",
|
"seo_keywords",
|
||||||
"url",
|
"url",
|
||||||
"folder_id",
|
"folder_id",
|
||||||
|
"is_default_folder",
|
||||||
"folder_title",
|
"folder_title",
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -246,6 +234,7 @@ class ContentExport extends ExportHandler implements
|
|||||||
"url_URL" => "url",
|
"url_URL" => "url",
|
||||||
"folder_TITLE" => "folder_title",
|
"folder_TITLE" => "folder_title",
|
||||||
"folder_ID" => "folder_id",
|
"folder_ID" => "folder_id",
|
||||||
|
"folder_IS_DEFAULT" => "is_default_folder"
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -85,6 +85,11 @@ class ContentExportTest extends \PHPUnit_Framework_TestCase
|
|||||||
$folder->getTitle(),
|
$folder->getTitle(),
|
||||||
$data[$i]["folder_title"]
|
$data[$i]["folder_title"]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
$contentFolder->getDefaultFolder(),
|
||||||
|
(bool)((int)$data[$i]["is_default_folder"])
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} while (
|
} while (
|
||||||
isset($data[++$i]["id"]) &&
|
isset($data[++$i]["id"]) &&
|
||||||
@@ -121,7 +126,7 @@ class ContentExportTest extends \PHPUnit_Framework_TestCase
|
|||||||
$j = 1;
|
$j = 1;
|
||||||
while ($data[$i-$j]["id"] === $data[$i]["id"]) {
|
while ($data[$i-$j]["id"] === $data[$i]["id"]) {
|
||||||
if (!empty($data[$i - $j++]["content_images"])) {
|
if (!empty($data[$i - $j++]["content_images"])) {
|
||||||
$data[$i]["content_images"] = $data[$i-$j-1]["content_images"];
|
$data[$i]["content_images"] = $data[$i-$j+1]["content_images"];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -133,6 +138,7 @@ class ContentExportTest extends \PHPUnit_Framework_TestCase
|
|||||||
->useFolderQuery()
|
->useFolderQuery()
|
||||||
->useContentFolderQuery()
|
->useContentFolderQuery()
|
||||||
->filterByContentId($data[$i]["id"])
|
->filterByContentId($data[$i]["id"])
|
||||||
|
->filterByFolderId($data[$i]["folder_id"])
|
||||||
->endUse()
|
->endUse()
|
||||||
->endUse()
|
->endUse()
|
||||||
->select(FolderImageTableMap::FILE)
|
->select(FolderImageTableMap::FILE)
|
||||||
|
|||||||
Reference in New Issue
Block a user