Projekt

Obecné

Profil

Stáhnout (3.48 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

    
9
    public function testPageLoad() {
10
        $client = static::createClient();
11
        $client->request('GET', '/heatmap');
12
        $this->assertTrue($client->getResponse()->isSuccessful());
13
    }
14

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

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

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

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

    
33
    public function testFormSubmit() {
34
        $client = static::createClient();
35
        $client->request('GET', '/heatmap');
36

    
37
        $crawler = $client->submitForm('Potvrdit výběr');
38
        $this->assertTrue($client->getResponse()->isSuccessful());
39

    
40
        $crawler = $client->submitForm('Potvrdit výběr', 
41
        [
42
            'data_set[date]' => '2019-04-11',
43
            'data_set[time]' => '0',
44
            'data_set[type]' => 'JIS'
45
        ]);
46
        $this->assertTrue($client->getResponse()->isSuccessful());
47
    }
48

    
49
    public function testFormSubmitInvalid() {
50
        $client = static::createClient();
51
        $client->request('GET', '/heatmap');
52

    
53
        $crawler = $client->submitForm('Potvrdit výběr', 
54
        [
55
            'data_set[date]' => '11-04-2019',
56
            'data_set[time]' => '0',
57
            'data_set[type]' => 'JIS'
58
        ]);
59
        $this->assertTrue($client->getResponse()->isSuccessful());
60
    }
61

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

    
72
    public function testAvailableDatasetsAjax() {
73
        $client = static::createClient();
74
        $client->xmlHttpRequest('POST', '/heatmap/available', 
75
        [
76
            'date' => '2019-04-11'
77
        ]);
78
        $this->assertTrue($client->getResponse()->isSuccessful());
79
    }
80

    
81
    public function testDatesWithAvailableDatasetsAjax() {
82
        $client = static::createClient();
83
        $client->xmlHttpRequest('POST', '/heatmap/dates');
84
        $this->assertTrue($client->getResponse()->isSuccessful());
85
    }
86

    
87
    public function testDataSourcePoistionsAjax() {
88
        $client = static::createClient();
89
        $client->xmlHttpRequest('POST', '/heatmap/positions', 
90
        [
91
            'name' => 'KOLOBEZKY'
92
        ]);
93
        $this->assertTrue($client->getResponse()->isSuccessful());
94
    }
95

    
96
    public function testLastAvailableCollectionsAjax() {
97
        $client = static::createClient();
98
        $client->xmlHttpRequest('POST', '/heatmap/last');
99
        $this->assertTrue($client->getResponse()->isSuccessful());
100
    }
101

    
102
}
(1-1/2)