This repository has been archived by the owner on Sep 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refs: #13
- Loading branch information
Showing
8 changed files
with
487 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 123 additions & 0 deletions
123
...reon-poller-display-central/php/class/configGenerate/centreon/AclTopologyRelationTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
<?php | ||
/** | ||
* Copyright 2016 Centreon | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
use \Centreon\Test\Mock\CentreonDB; | ||
use \CentreonPollerDisplayCentral\ConfigGenerate\Centreon\AclTopologyRelation; | ||
|
||
|
||
/** | ||
* @package centreon-poller-display-central | ||
* @version 1.0.0 | ||
* @author Centreon | ||
*/ | ||
class CentreonPollerDisplayCentral_AclTopologyRelation extends PHPUnit_Framework_TestCase | ||
{ | ||
protected static $db; | ||
protected static $pollerDisplay; | ||
protected static $acl; | ||
protected static $objectListIn; | ||
protected static $objectListOut; | ||
|
||
public function setUp() | ||
{ | ||
self::$db = new CentreonDB(); | ||
self::$pollerDisplay = 1; | ||
self::$acl = new AclTopologyRelation(self::$db, self::$pollerDisplay); | ||
self::$objectListIn = array( | ||
array( | ||
'acl_topo_id' => '1', | ||
'acl_topo_name' => 'toto' | ||
), | ||
array( | ||
'acl_topo_id' => '4', | ||
'acl_topo_name' => 'tutu' | ||
) | ||
); | ||
self::$objectListOut = array( | ||
array( | ||
'topology_topology_id' => '2', | ||
'acl_topo_id' => '1' | ||
), | ||
array( | ||
'topology_topology_id' => '3', | ||
'acl_topo_id' => '4' | ||
) | ||
); | ||
|
||
|
||
} | ||
|
||
public function tearDown() | ||
{ | ||
self::$db = null; | ||
} | ||
|
||
public function testGetList() | ||
{ | ||
self::$db->addResultSet( | ||
'SELECT * FROM acl_topology_relations WHERE acl_topo_id IN (1,4)', | ||
array( | ||
array( | ||
'topology_topology_id' => '2', | ||
'acl_topo_id' => '1' | ||
), | ||
array( | ||
'topology_topology_id' => '3', | ||
'acl_topo_id' => '4' | ||
) | ||
) | ||
); | ||
|
||
$sql = self::$acl->getList(self::$objectListIn); | ||
$this->assertEquals($sql, self::$objectListOut); | ||
} | ||
|
||
public function testGenerateSql() | ||
{ | ||
self::$db->addResultSet( | ||
'SELECT topology_name, topology_page FROM topology WHERE topology_id = 2', | ||
array( | ||
array( | ||
'topology_page' => '20', | ||
'topology_name' => 'toto' | ||
) | ||
) | ||
); | ||
self::$db->addResultSet( | ||
'SELECT topology_name, topology_page FROM topology WHERE topology_id = 3', | ||
array( | ||
array( | ||
'topology_page' => '30', | ||
'topology_name' => 'tutu' | ||
) | ||
) | ||
); | ||
|
||
$expectedResult = 'DELETE FROM acl_topology_relations; | ||
TRUNCATE acl_topology_relations; | ||
INSERT INTO `acl_topology_relations` (`topology_topology_id`,`acl_topo_id`) | ||
SELECT (SELECT topology_id FROM topology WHERE topology_name = "toto" AND topology_page = "20"),\'1\' | ||
WHERE (SELECT topology_id FROM topology WHERE topology_name = "toto" AND topology_page = "20"); | ||
INSERT INTO `acl_topology_relations` (`topology_topology_id`,`acl_topo_id`) | ||
SELECT (SELECT topology_id FROM topology WHERE topology_name = "tutu" AND topology_page = "30"),\'4\' | ||
WHERE (SELECT topology_id FROM topology WHERE topology_name = "tutu" AND topology_page = "30"); | ||
'; | ||
|
||
$sql = self::$acl->generateSql(self::$objectListOut); | ||
$this->assertEquals($sql, $expectedResult); | ||
} | ||
} |
100 changes: 100 additions & 0 deletions
100
tests/centreon-poller-display-central/php/class/configGenerate/centreon/AclTopologyTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<?php | ||
/** | ||
* Copyright 2016 Centreon | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
use \Centreon\Test\Mock\CentreonDB; | ||
use \CentreonPollerDisplayCentral\ConfigGenerate\Centreon\AclTopology; | ||
|
||
|
||
/** | ||
* @package centreon-poller-display-central | ||
* @version 1.0.0 | ||
* @author Centreon | ||
*/ | ||
class CentreonPollerDisplayCentral_AclTopology extends PHPUnit_Framework_TestCase | ||
{ | ||
protected static $db; | ||
protected static $pollerDisplay; | ||
protected static $acl; | ||
protected static $objectListIn; | ||
protected static $objectListOut; | ||
|
||
public function setUp() | ||
{ | ||
self::$db = new CentreonDB(); | ||
self::$pollerDisplay = 1; | ||
self::$acl = new AclTopology(self::$db, self::$pollerDisplay); | ||
self::$objectListIn = array( | ||
array( | ||
'agt_id' => '1', | ||
'acl_group_id' => '1', | ||
'acl_topology_id' => '1' | ||
), | ||
array( | ||
'agt_id' => '2', | ||
'acl_group_id' => '3', | ||
'acl_topology_id' => '4' | ||
) | ||
); | ||
|
||
self::$objectListOut = array( | ||
array( | ||
'acl_topo_id' => '1', | ||
'acl_topo_name' => 'toto' | ||
), | ||
array( | ||
'acl_topo_id' => '4', | ||
'acl_topo_name' => 'tutu' | ||
) | ||
); | ||
} | ||
|
||
public function tearDown() | ||
{ | ||
self::$db = null; | ||
} | ||
|
||
public function testGetList() | ||
{ | ||
self::$db->addResultSet( | ||
'SELECT * FROM acl_topology WHERE acl_topo_id IN (1,4)', | ||
array( | ||
array( | ||
'acl_topo_id' => '1', | ||
'acl_topo_name' => 'toto' | ||
), | ||
array( | ||
'acl_topo_id' => '4', | ||
'acl_topo_name' => 'tutu' | ||
) | ||
) | ||
); | ||
|
||
$sql = self::$acl->getList(self::$objectListIn); | ||
$this->assertEquals($sql, self::$objectListOut); | ||
} | ||
|
||
public function testGenerateSql() | ||
{ | ||
|
||
$expectedResult = 'DELETE FROM acl_topology; | ||
TRUNCATE acl_topology; | ||
INSERT INTO `acl_topology` (`acl_topo_id`,`acl_topo_name`) VALUES (\'1\',\'toto\'),(\'4\',\'tutu\');'; | ||
|
||
$sql = self::$acl->generateSql(self::$objectListOut); | ||
$this->assertEquals($sql, $expectedResult); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.