Completed
Pull Request — develop (#605)
by
unknown
12:33 queued 06:41
created

DefaultControllerTest::testIndex()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 21
rs 9.3142
c 1
b 0
f 0
cc 1
eloc 13
nc 1
nop 0
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