Projekt

Obecné

Profil

Stáhnout (3.5 KB) Statistiky
| Větev: | Revize:
1
<?php
2

    
3
namespace App\Tests\Controller;
4

    
5
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
6

    
7
class HatmapControllerTest extends WebTestCase {
8
    public function testPageLoad() {
9
        $client = static::createClient();
10
        $client->request('GET', '/heatmap');
11

    
12
        $this->assertTrue($client->getResponse()->isSuccessful());
13
    }
14

    
15
    public function testPageLoadWithData() {
16
        $client = static::createClient();
17
        $client->request('GET', '/heatmap?date=2019-04-11&time=12&type[]=JIS');
18

    
19
        $this->assertTrue($client->getResponse()->isSuccessful());
20
    }
21

    
22
    public function testPageLoadWithInvalidData() {
23
        $client = static::createClient();
24
        $client->request('GET', '/heatmap?date=2019-04-11&time=12&type[]=NIC');
25
        $this->assertTrue($client->getResponse()->isSuccessful());
26

    
27
        $client->request('GET', '/heatmap?date=2019-04-11&time=25&type[]=KOLOBEZKY');
28
        $this->assertTrue($client->getResponse()->isSuccessful());
29

    
30
        $client->request('GET', '/heatmap?date=11-04-2019&time=12&type[]=KOLOBEZKY');
31
        $this->assertTrue($client->getResponse()->isSuccessful());
32
    }
33

    
34
    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

    
67
    public function testOpenDataAjax() {
68
        $client = static::createClient();
69
        $client->xmlHttpRequest('POST', '/heatmap/opendata', [
70
            'name' => 'KOLOBEZKY',
71
            'date' => '2019-04-11',
72
            'time' => '9',
73
        ]);
74
        $this->assertTrue($client->getResponse()->isSuccessful());
75
    }
76

    
77
    public function testAvailableDatasetsAjax() {
78
        $client = static::createClient();
79
        $client->xmlHttpRequest(
80
            'POST',
81
            '/heatmap/available',
82
            [
83
                'date' => '2019-04-11',
84
            ]
85
        );
86
        $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
        $client->xmlHttpRequest(
98
            'POST',
99
            '/heatmap/positions',
100
            [
101
                'name' => 'KOLOBEZKY',
102
            ]
103
        );
104
        $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
}
(1-1/2)