Projekt

Obecné

Profil

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
104
}
(1-1/2)