mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
# Conflicts: # composer.json # core/cmdbchangeop.class.inc.php # core/cmdbobject.class.inc.php # css/light-grey.scss # setup/setuputils.class.inc.php # test/ItopTestCase.php # test/core/ConfigTest.php # test/core/LogAPITest.php # test/core/UserRightsTest.php # test/core/dictApcuTest.php # test/core/dictTest.php # test/core/iTopConfigParserTest.php # test/core/ormLinkSetTest.php # test/phpunit.xml.dist # test/postbuild_integration.xml.dist # test/setup/SetupUtilsTest.php # test/status/StatusIncTest.php # webservices/cron.php
79 lines
1.7 KiB
PHP
79 lines
1.7 KiB
PHP
<?php
|
|
|
|
|
|
namespace Combodo\iTop\Test\UnitTest\Core;
|
|
|
|
use Combodo\iTop\Test\UnitTest\ItopTestCase;
|
|
use CoreUnexpectedValue;
|
|
use MetaModel;
|
|
|
|
/**
|
|
* Class UniquenessConstraintTest
|
|
*
|
|
* @since 2.6.0 N°659 uniqueness constraint
|
|
*
|
|
* @package Combodo\iTop\Test\UnitTest\Core
|
|
*/
|
|
class UniquenessConstraintTest extends ItopTestCase
|
|
{
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
require_once(APPROOT.'/core/metamodel.class.php');
|
|
}
|
|
|
|
/**
|
|
* @covers MetaModel::CheckUniquenessRuleValidity
|
|
* @dataProvider uniquenessRuleValidityCheckProvider
|
|
*
|
|
* @param bool $bIsRuleShouldBeValid
|
|
* @param bool $bIsRuleOverride
|
|
* @param array $aRuleProperties
|
|
*/
|
|
public function testUniquenessRuleValidityCheck($bIsRuleShouldBeValid, $bIsRuleOverride, $aRuleProperties)
|
|
{
|
|
$bRuleValidResult = true;
|
|
try
|
|
{
|
|
MetaModel::CheckUniquenessRuleValidity($aRuleProperties, $bIsRuleOverride);
|
|
}
|
|
catch (CoreUnexpectedValue $e)
|
|
{
|
|
$bRuleValidResult = false;
|
|
}
|
|
|
|
$this->assertEquals($bIsRuleShouldBeValid, $bRuleValidResult, "Validity test returned $bRuleValidResult");
|
|
}
|
|
|
|
public function uniquenessRuleValidityCheckProvider()
|
|
{
|
|
return array(
|
|
'simplest rule' => array(true, false, array('attributes' => array('name'))),
|
|
'with all properties' => array(
|
|
true,
|
|
false,
|
|
array(
|
|
'attributes' => array('name'),
|
|
'filter' => 'name != \'\'',
|
|
'disabled' => false,
|
|
'is_blocking' => true,
|
|
),
|
|
),
|
|
'only disabled key without ancestor' => array(
|
|
false,
|
|
false,
|
|
array(
|
|
'disabled' => true,
|
|
),
|
|
),
|
|
'only disabled key with ancestor' => array(
|
|
true,
|
|
true,
|
|
array(
|
|
'disabled' => true,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|