freenetis-github/tests/application/controllers/api_endpoints/Network_LinkTest.php @ 11e2d062
18ac9009 | Ondřej Fibich | <?php
|
|
/*
|
|||
* This file is part of open source system FreenetIS
|
|||
* and it is release under GPLv3 licence.
|
|||
*
|
|||
* More info about licence can be found:
|
|||
* http://www.gnu.org/licenses/gpl-3.0.html
|
|||
*
|
|||
* More info about project can be found:
|
|||
* http://www.freenetis.org/
|
|||
*
|
|||
*/
|
|||
require_once __DIR__ . '/AbstractEndPointTestCase.php';
|
|||
/**
|
|||
* Generated by PHPUnit_SkeletonGenerator on 2014-11-24 at 11:59:20.
|
|||
*/
|
|||
class Network_Link_ApiTest extends AbstractEndPointTestCase
|
|||
{
|
|||
/**
|
|||
* @covers Network_Link_Api::get_all
|
|||
*/
|
|||
public function testGet_all()
|
|||
{
|
|||
$rsp = $this->request_get('/network/link', NULL, 200);
|
|||
$this->assertTrue(is_array($rsp->body));
|
|||
}
|
|||
/**
|
|||
* @covers Network_Link_Api::get_list
|
|||
*/
|
|||
public function testGet_list()
|
|||
{
|
|||
$rsp = $this->request_get('/network/link/list', NULL, 200);
|
|||
$this->assertTrue(is_array($rsp->body));
|
|||
}
|
|||
/**
|
|||
* @covers Network_Link_Api::get_list_of_type
|
|||
*/
|
|||
public function testGet_list_of_type()
|
|||
{
|
|||
$this->request_get('/network/link/invalid_type/list', NULL, 404);
|
|||
$rsp1 = $this->request_get('/network/link/roaming/list', NULL, 200);
|
|||
$this->assertTrue(is_array($rsp1->body));
|
|||
$rsp2 = $this->request_get('/network/link/air/list', NULL, 200);
|
|||
$this->assertTrue(is_array($rsp2->body));
|
|||
$rsp3 = $this->request_get('/network/link/fiber/list', NULL, 200);
|
|||
$this->assertTrue(is_array($rsp3->body));
|
|||
$rsp4 = $this->request_get('/network/link/cable/list', NULL, 200);
|
|||
$this->assertTrue(is_array($rsp4->body));
|
|||
}
|
|||
/**
|
|||
* @covers Network_Link_Api::get_item
|
|||
*/
|
|||
public function testGet_item()
|
|||
{
|
|||
$this->request_get('/111111', NULL, 404);
|
|||
// TODO: add existing
|
|||
}
|
|||
/**
|
|||
* @covers Network_Link_Api::get_items_subnets
|
|||
*/
|
|||
public function testGet_items_subnets()
|
|||
{
|
|||
$this->request_get('/network/link/subnets', NULL, 400); // ids missing
|
|||
$this->request_get('/network/link/subnets',
|
|||
array('ids' => ''), 400); // ids empty
|
|||
$rsp1 = $this->request_get('/network/link/subnets',
|
|||
array('ids' => '1111111111'), 200);
|
|||
$this->assertTrue(is_array($rsp1->body));
|
|||
$this->assertEquals(0, count($rsp1->body));
|
|||
$rsp2 = $this->request_get('/network/link/subnets',
|
|||
array('ids' => '111111111,111111112'), 200);
|
|||
$this->assertTrue(is_array($rsp2->body));
|
|||
$this->assertEquals(0, count($rsp2->body));
|
|||
// TODO: add existing
|
|||
}
|
|||
/**
|
|||
* @covers Network_Link_Api::get_items_vlans
|
|||
*/
|
|||
public function testGet_items_vlans()
|
|||
{
|
|||
$this->request_get('/network/link/vlans', NULL, 400); // ids missing
|
|||
$this->request_get('/network/link/vlans?ids=', NULL, 400); // ids empty
|
|||
$rsp1 = $this->request_get('/network/link/vlans',
|
|||
array('ids' => '1111111111'), 200);
|
|||
$this->assertTrue(is_array($rsp1->body));
|
|||
$this->assertEquals(0, count($rsp1->body));
|
|||
$rsp2 = $this->request_get('/network/link/vlans',
|
|||
array('ids' => '111111111,111111112'), 200);
|
|||
$this->assertTrue(is_array($rsp2->body));
|
|||
$this->assertEquals(0, count($rsp2->body));
|
|||
// TODO: add existing
|
|||
}
|
|||
/**
|
|||
* @covers Network_Link_Api::count
|
|||
*/
|
|||
public function testCount()
|
|||
{
|
|||
$rsp = $this->request_get('/network/link/count', NULL, 200);
|
|||
$this->assertTrue(isset($rsp->body->count));
|
|||
}
|
|||
}
|