mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-12 23:14:18 +01:00
N°8397 - Suppress export V1 from iTop packages - fix tests
This commit is contained in:
@@ -221,17 +221,10 @@ class QueryOQL extends Query
|
||||
{
|
||||
try{
|
||||
// retrieve attributes
|
||||
$sFields = trim($this->Get('fields'));
|
||||
$sOql = $this->Get('oql');
|
||||
|
||||
// construct base url depending on version
|
||||
$bExportV1Recommended = ($sFields == '');
|
||||
if ($bExportV1Recommended) {
|
||||
$sUrl = utils::GetAbsoluteUrlAppRoot().'webservices/export.php?format=spreadsheet&login_mode=basic&query='.$this->GetKey();
|
||||
}
|
||||
else{
|
||||
$sUrl = utils::GetAbsoluteUrlAppRoot().'webservices/export-v2.php?format=spreadsheet&login_mode=basic&date_format='.urlencode((string)AttributeDateTime::GetFormat()).'&query='.$this->GetKey();
|
||||
}
|
||||
$sUrl = utils::GetAbsoluteUrlAppRoot().'webservices/export-v2.php?format=spreadsheet&login_mode=basic&date_format='.urlencode((string)AttributeDateTime::GetFormat()).'&query='.$this->GetKey();
|
||||
|
||||
// search object from OQL
|
||||
$oSearch = DBObjectSearch::FromOQL($sOql);
|
||||
@@ -256,22 +249,9 @@ class QueryOQL extends Query
|
||||
$oPage->add_script("$('[name=\"attr_oql\"]').addClass('ibo-query-oql ibo-is-code'); $('[data-attribute-code=\"oql\"]').addClass('ibo-query-oql ibo-is-code');");
|
||||
|
||||
if (!$bEditMode) {
|
||||
$sFields = trim($this->Get('fields'));
|
||||
$bExportV1Recommended = ($sFields == '');
|
||||
if ($bExportV1Recommended) {
|
||||
$oFieldAttDef = MetaModel::GetAttributeDef('QueryOQL', 'fields');
|
||||
$oAlert = AlertUIBlockFactory::MakeForFailure()
|
||||
->SetIsClosable(false)
|
||||
->SetIsCollapsible(false);
|
||||
$oAlert->AddCSSClass('mb-5');
|
||||
$oAlert->AddSubBlock(new Html(Dict::Format('UI:Query:UrlV1', '')));
|
||||
$oPage->AddSubBlock($oAlert);
|
||||
$sUrl = utils::GetAbsoluteUrlAppRoot().'webservices/export.php?format=spreadsheet&login_mode=basic&query='.$this->GetKey();
|
||||
} else {
|
||||
$sUrl = utils::GetAbsoluteUrlAppRoot().'webservices/export-v2.php?format=spreadsheet&login_mode=basic&date_format='.urlencode((string)AttributeDateTime::GetFormat()).'&query='.$this->GetKey();
|
||||
}
|
||||
$sUrl = utils::GetAbsoluteUrlAppRoot().'webservices/export-v2.php?format=spreadsheet&login_mode=basic&date_format='.urlencode((string)AttributeDateTime::GetFormat()).'&query='.$this->GetKey();
|
||||
|
||||
$sOql = $this->Get('oql');
|
||||
$sMessage = null;
|
||||
try {
|
||||
$oSearch = DBObjectSearch::FromOQL($sOql);
|
||||
$aParameters = $oSearch->GetQueryParams();
|
||||
|
||||
@@ -89,35 +89,6 @@ class QueryTest extends ItopDataTestCase
|
||||
return $oQuery;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test query export V1 usage.
|
||||
*
|
||||
* @param string $sDescription query description
|
||||
* @param string $sOql query oql phrase
|
||||
*
|
||||
* @dataProvider getQueryProvider
|
||||
*/
|
||||
public function testQueryExportV1Usage(string $sDescription, string $sOql)
|
||||
{
|
||||
// create query OQL
|
||||
$oQuery = $this->CreateQueryOQL($this->dataName(), $sDescription, $sOql);
|
||||
|
||||
// call export service
|
||||
$this->CallExportService($oQuery);
|
||||
|
||||
// reload to update counter (done by export process)
|
||||
$oQuery->Reload();
|
||||
|
||||
// extract counter
|
||||
$iResult = $oQuery->Get('export_count');
|
||||
|
||||
// delete the query
|
||||
$oQuery->DBDelete();
|
||||
|
||||
// test
|
||||
$this->assertEquals(1, $iResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test query export V2 usage.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user