Projekt

Obecné

Profil

Stáhnout (3.5 KB) Statistiky
| Větev: | Revize:
1 ea92a5e5 vastja
<?php
2
3
namespace App\Tests\Controller;
4
5
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
6
7
class HatmapControllerTest extends WebTestCase {
8 afb0cc02 vastja
    public function testPageLoad() {
9 ea92a5e5 vastja
        $client = static::createClient();
10
        $client->request('GET', '/heatmap');
11 2f227a6c ballakt
12 afb0cc02 vastja
        $this->assertTrue($client->getResponse()->isSuccessful());
13 ea92a5e5 vastja
    }
14 afb0cc02 vastja
15
    public function testPageLoadWithData() {
16
        $client = static::createClient();
17 2f227a6c ballakt
        $client->request('GET', '/heatmap?date=2019-04-11&time=12&type[]=JIS');
18 1cf1413d ballakt
19 afb0cc02 vastja
        $this->assertTrue($client->getResponse()->isSuccessful());
20
    }
21
22
    public function testPageLoadWithInvalidData() {
23
        $client = static::createClient();
24 2f227a6c ballakt
        $client->request('GET', '/heatmap?date=2019-04-11&time=12&type[]=NIC');
25 afb0cc02 vastja
        $this->assertTrue($client->getResponse()->isSuccessful());
26
27 2f227a6c ballakt
        $client->request('GET', '/heatmap?date=2019-04-11&time=25&type[]=KOLOBEZKY');
28 afb0cc02 vastja
        $this->assertTrue($client->getResponse()->isSuccessful());
29
30 2f227a6c ballakt
        $client->request('GET', '/heatmap?date=11-04-2019&time=12&type[]=KOLOBEZKY');
31 afb0cc02 vastja
        $this->assertTrue($client->getResponse()->isSuccessful());
32
    }
33
34 52b74f24 Martin Sebela
    public function testFormSubmit() {
35
        $client = static::createClient();
36
        $client->request('GET', '/heatmap');
37
38
        $crawler = $client->submitForm('btn-update-heatmap');
39
        $this->assertTrue($client->getResponse()->isSuccessful());
40
41
        $crawler = $client->submitForm(
42
            'btn-update-heatmap',
43
            [
44
                'date' => '2019-04-11',
45
                'time' => '0',
46
                'type[1]' => 'JIS',
47
            ]
48
        );
49
        $this->assertTrue($client->getResponse()->isSuccessful());
50
    }
51
52
    public function testFormSubmitInvalid() {
53
        $client = static::createClient();
54
        $client->request('GET', '/heatmap');
55
56
        $crawler = $client->submitForm(
57
            'btn-update-heatmap',
58
            [
59
                'date' => '11-04-2019',
60
                'time' => '0',
61
                'type[1]' => 'JIS',
62
            ]
63
        );
64
        $this->assertTrue($client->getResponse()->isSuccessful());
65
    }
66 afb0cc02 vastja
67
    public function testOpenDataAjax() {
68
        $client = static::createClient();
69
        $client->xmlHttpRequest('POST', '/heatmap/opendata', [
70
            'name' => 'KOLOBEZKY',
71
            'date' => '2019-04-11',
72 1cf1413d ballakt
            'time' => '9',
73 afb0cc02 vastja
        ]);
74
        $this->assertTrue($client->getResponse()->isSuccessful());
75
    }
76
77
    public function testAvailableDatasetsAjax() {
78
        $client = static::createClient();
79 1cf1413d ballakt
        $client->xmlHttpRequest(
80
            'POST',
81
            '/heatmap/available',
82
            [
83
                'date' => '2019-04-11',
84
            ]
85
        );
86 afb0cc02 vastja
        $this->assertTrue($client->getResponse()->isSuccessful());
87
    }
88
89
    public function testDatesWithAvailableDatasetsAjax() {
90
        $client = static::createClient();
91
        $client->xmlHttpRequest('POST', '/heatmap/dates');
92
        $this->assertTrue($client->getResponse()->isSuccessful());
93
    }
94
95
    public function testDataSourcePoistionsAjax() {
96
        $client = static::createClient();
97 1cf1413d ballakt
        $client->xmlHttpRequest(
98
            'POST',
99
            '/heatmap/positions',
100
            [
101
                'name' => 'KOLOBEZKY',
102
            ]
103
        );
104 afb0cc02 vastja
        $this->assertTrue($client->getResponse()->isSuccessful());
105
    }
106
107
    public function testLastAvailableCollectionsAjax() {
108
        $client = static::createClient();
109
        $client->xmlHttpRequest('POST', '/heatmap/last');
110
        $this->assertTrue($client->getResponse()->isSuccessful());
111
    }
112 1cf1413d ballakt
}