|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Test cases for basic coverage for ProxyApi Bundle |
|
4
|
|
|
*/ |
|
5
|
|
|
namespace Graviton\ProxyApiBundle\Tests\Controller; |
|
6
|
|
|
|
|
7
|
|
|
use Symfony\Component\HttpFoundation\Response; |
|
8
|
|
|
use Symfony\Component\Routing\Router; |
|
9
|
|
|
|
|
10
|
|
|
use Graviton\TestBundle\Test\RestTestCase; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Basic functional test for ProxyApi |
|
14
|
|
|
* |
|
15
|
|
|
* @author List of contributors <https://github.com/libgraviton/graviton/graphs/contributors> |
|
16
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License |
|
17
|
|
|
* @link http://swisscom.ch |
|
18
|
|
|
*/ |
|
19
|
|
|
class DefaultControllerTest extends RestTestCase |
|
20
|
|
|
{ |
|
21
|
|
|
/** |
|
22
|
|
|
* Testing basic functionality |
|
23
|
|
|
* Api to Weather station, json response |
|
24
|
|
|
* @return void |
|
25
|
|
|
*/ |
|
26
|
|
|
public function testIndex() |
|
27
|
|
|
{ |
|
28
|
|
|
$client = static::createClient(); |
|
29
|
|
|
|
|
30
|
|
|
// Let's get information from the schema |
|
31
|
|
|
$client->request('GET', '/proxy/'); |
|
32
|
|
|
$content = $client->getResponse()->getContent(); |
|
33
|
|
|
$services = json_decode($content, true); |
|
34
|
|
|
|
|
35
|
|
|
$this->assertArrayHasKey('services', $services, 'No services in proxy: '. json_encode($services)); |
|
36
|
|
|
$this->assertArrayHasKey('weather', $services['services'], 'No services in proxy: '. json_encode($services)); |
|
37
|
|
|
|
|
38
|
|
|
// Lets get graviton version, core is or endpoint in test config for weather api |
|
39
|
|
|
$client->request('GET', '/proxy/weather/ortswetter?value=3000&name=Bern&type=zip'); |
|
40
|
|
|
$content = $client->getResponse()->getContent(); |
|
41
|
|
|
$weather = json_decode($content, true); |
|
42
|
|
|
|
|
43
|
|
|
$this->assertArrayHasKey('currentWeather', $weather, 'Response from weather: '. json_encode($services)); |
|
44
|
|
|
$this->assertArrayHasKey('tt', $weather['currentWeather'], 'Response from weather: '. json_encode($services)); |
|
45
|
|
|
$this->assertArrayHasKey('prognose', $weather, 'Response from weather: '. json_encode($services)); |
|
46
|
|
|
} |
|
47
|
|
|
} |
|
48
|
|
|
|