mirror of
				https://github.com/Icinga/icingaweb2.git
				synced 2025-10-31 19:34:16 +01:00 
			
		
		
		
	The StatusDat tests didn't run as they were outdated, now a newer version is added refs #4178 refs #4179
		
			
				
	
	
		
			80 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			80 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace Tests\Icinga\Web\Paginator\Adapter;
 | |
| 
 | |
| use Monitoring\Backend\Statusdat;
 | |
| use Icinga\Protocol\Statusdat\Reader;
 | |
| use Icinga\Web\Paginator\Adapter\QueryAdapter;
 | |
| use Tests\Icinga\Protocol\Statusdat\StatusdatTestLoader;
 | |
| 
 | |
| require_once 'Zend/Paginator/Adapter/Interface.php';
 | |
| 
 | |
| require_once '../../library/Icinga/Web/Paginator/Adapter/QueryAdapter.php';
 | |
| 
 | |
| require_once 'library/Icinga/Protocol/Statusdat/StatusdatTestLoader.php';
 | |
| StatusdatTestLoader::requireLibrary();
 | |
| 
 | |
| require_once '../../modules/monitoring/library/Monitoring/Backend/Statusdat/Criteria/Order.php';
 | |
| require_once '../../modules/monitoring/library/Monitoring/Backend/AbstractBackend.php';
 | |
| require_once '../../modules/monitoring/library/Monitoring/Backend/Statusdat/Query/Query.php';
 | |
| require_once '../../modules/monitoring/library/Monitoring/Backend/Statusdat.php';
 | |
| require_once '../../modules/monitoring/library/Monitoring/Backend/Statusdat/Query/StatusQuery.php';
 | |
| require_once '../../modules/monitoring/library/Monitoring/Backend/Statusdat/DataView/HostStatusView.php';
 | |
| require_once '../../modules/monitoring/library/Monitoring/View/MonitoringView.php';
 | |
| require_once '../../modules/monitoring/library/Monitoring/View/StatusView.php';
 | |
| 
 | |
| require_once '../../library/Icinga/Protocol/AbstractQuery.php';
 | |
| 
 | |
| 
 | |
| 
 | |
| class QueryAdapterTest extends \PHPUnit_Framework_TestCase
 | |
| {
 | |
|     private $cacheDir;
 | |
| 
 | |
|     private $config;
 | |
| 
 | |
|     protected function setUp()
 | |
|     {
 | |
|         $this->cacheDir = '/tmp'. Reader::STATUSDAT_DEFAULT_CACHE_PATH;
 | |
| 
 | |
|         if (!file_exists($this->cacheDir)) {
 | |
|             mkdir($this->cacheDir);
 | |
|         }
 | |
| 
 | |
|         $statusdatFile = dirname(__FILE__). '/../../../../../res/status/icinga.status.dat';
 | |
|         $cacheFile = dirname(__FILE__). '/../../../../../res/status/icinga.objects.cache';
 | |
| 
 | |
|         $this->config = new \Zend_Config(
 | |
|             array(
 | |
|                 'status_file' => $statusdatFile,
 | |
|                 'objects_file' => $cacheFile
 | |
|             )
 | |
|         );
 | |
|     }
 | |
| 
 | |
|     public function testLimit1()
 | |
|     {
 | |
|         $backend = new Statusdat($this->config);
 | |
|         $query = $backend->select()->from('status');
 | |
| 
 | |
|         $adapter = new QueryAdapter($query);
 | |
| 
 | |
|         $this->assertEquals(30, $adapter->count());
 | |
| 
 | |
|         $data = $adapter->getItems(0, 10);
 | |
| 
 | |
|         $this->assertCount(10, $data);
 | |
| 
 | |
|         $data = $adapter->getItems(10, 20);
 | |
|         $this->assertCount(10, $data);
 | |
|     }
 | |
| 
 | |
|     public function testLimit2()
 | |
|     {
 | |
|         $backend = new Statusdat($this->config);
 | |
|         $query = $backend->select()->from('status');
 | |
| 
 | |
|         $adapter = new QueryAdapter($query);
 | |
|         $this->assertEquals(30, $adapter->count());
 | |
|     }
 | |
| } |