mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-19 08:38:45 +02:00
N°5608 - Move unit tests to a dedicated folder and start reorganizing to match iTop folder structure
This commit is contained in:
93
test/php-unit-tests/tests/core/DBSearchCommitTest.php
Normal file
93
test/php-unit-tests/tests/core/DBSearchCommitTest.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Eric
|
||||
* Date: 17/09/2018
|
||||
* Time: 12:31
|
||||
*/
|
||||
|
||||
namespace Combodo\iTop\Test\UnitTest\Core;
|
||||
|
||||
use Combodo\iTop\Test\UnitTest\ItopDataTestCase;
|
||||
use DBObjectSet;
|
||||
use DBSearch;
|
||||
|
||||
/**
|
||||
* Tests of the DBSearch class.
|
||||
* <ul>
|
||||
* <li>MakeGroupByQuery</li>
|
||||
* </ul>
|
||||
*
|
||||
* @runTestsInSeparateProcesses
|
||||
* @preserveGlobalState disabled
|
||||
* @backupGlobals disabled
|
||||
*/
|
||||
class DBSearchCommitTest extends ItopDataTestCase
|
||||
{
|
||||
// Need database COMMIT in order to create the FULLTEXT INDEX of MySQL
|
||||
const USE_TRANSACTION = false;
|
||||
|
||||
/**
|
||||
* @throws \CoreException
|
||||
* @throws \MissingQueryArgument
|
||||
* @throws \MySQLException
|
||||
* @throws \MySQLHasGoneAwayException
|
||||
* @throws \OQLException
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function testAttributeTagSet()
|
||||
{
|
||||
// Create a tag
|
||||
$this->CreateTagData(TAG_CLASS, TAG_ATTCODE, 'tag1', 'UNIT First');
|
||||
$this->CreateTagData(TAG_CLASS, TAG_ATTCODE, 'tag2', 'UNIT Second');
|
||||
//Use it
|
||||
$oObjWithTagSet = $this->CreateObjectWithTagSet();
|
||||
$oObjWithTagSet->Set(TAG_ATTCODE, 'tag1');
|
||||
$oObjWithTagSet->DBWrite();
|
||||
|
||||
$oSearch = DBSearch::FromOQL("SELECT ".TAG_CLASS);
|
||||
$oSearch->AddCondition(TAG_ATTCODE, 'tag1', 'MATCHES');
|
||||
$oSet = new DBObjectSet($oSearch);
|
||||
static::assertEquals(1, $oSet->Count());
|
||||
|
||||
|
||||
$oObjWithTagSet->Set(TAG_ATTCODE, 'tag1 tag2');
|
||||
$oObjWithTagSet->DBWrite();
|
||||
|
||||
$oSet = new DBObjectSet($oSearch);
|
||||
static::assertEquals(1, $oSet->Count());
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \CoreException
|
||||
* @throws \CoreUnexpectedValue
|
||||
* @throws \MissingQueryArgument
|
||||
* @throws \MySQLException
|
||||
* @throws \MySQLHasGoneAwayException
|
||||
* @throws \OQLException
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function testAttributeTagSet2()
|
||||
{
|
||||
// Create a tag
|
||||
$this->CreateTagData(TAG_CLASS, TAG_ATTCODE, 'tag1', 'UNIT First');
|
||||
$this->CreateTagData(TAG_CLASS, TAG_ATTCODE, 'tag2', 'UNIT Second');
|
||||
//Use it
|
||||
$oObjWithTagSet = $this->CreateObjectWithTagSet();
|
||||
$oObjWithTagSet->Set(TAG_ATTCODE, 'tag1');
|
||||
$oObjWithTagSet->DBWrite();
|
||||
|
||||
$oSearch = DBSearch::FromOQL("SELECT ".TAG_CLASS);
|
||||
$oSearch->AddCondition(TAG_ATTCODE, 'tag1');
|
||||
$oSet = new \DBObjectSet($oSearch);
|
||||
static::assertEquals(1, $oSet->Count());
|
||||
|
||||
|
||||
$oObjWithTagSet->Set(TAG_ATTCODE, 'tag1 tag2');
|
||||
$oObjWithTagSet->DBWrite();
|
||||
|
||||
$oSet = new \DBObjectSet($oSearch);
|
||||
static::assertEquals(0, $oSet->Count());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user