Completed
Push — master ( 845964...864a7b )
by Louis
16s
created

PonthubControllerTest::testImdbSearch()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 11
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
3
namespace Tests\KI\PonthubBundle\Controller;
4
5
use Symfony\Component\Filesystem\Filesystem;
6
use Symfony\Component\HttpFoundation\File\UploadedFile;
7
use Tests\KI\CoreBundle\WebTestCase;
8
9
class PonthubControllerTest extends WebTestCase
10
{
11
    public function testFilelist()
12
    {
13
        $basePath = __DIR__.'/../../../../web/uploads/tests/';
14
        $fs = new Filesystem();
15
        $fs->copy($basePath.'files_tmp.list', $basePath.'files.list');
16
        $list = new UploadedFile($basePath.'files.list', 'files.list');
17
18
        $this->client->request('POST', '/filelist/12345', [], ['filelist' => $list]);
19
        $response = $this->client->getResponse();
20
        $this->assertJsonResponse($response, 403);
21
22
        $this->client->request('POST', '/filelist/1234', [], ['filelist' => $list]);
23
        $response = $this->client->getResponse();
24
        $this->assertJsonResponse($response, 202);
25
26
        // On vérifie que les ressources concernées ont bien été créées
27
        $this->client->request('GET', '/games/dawn-of-war-1-dark-crusade');
28
        $response = $this->client->getResponse();
29
        $this->assertJsonResponse($response, 200);
30
31
        $this->client->request('GET', '/games/europa-universalis-1');
32
        $response = $this->client->getResponse();
33
        $this->assertJsonResponse($response, 200);
34
35
        $this->client->request('GET', '/movies/the-chronicles-of-narnia-the-lion-the-witch-and-the-wardrobe');
36
        $response = $this->client->getResponse();
37
        $this->assertJsonResponse($response, 200);
38
39
        $this->client->request('GET', '/movies/the-king-s-speech');
40
        $response = $this->client->getResponse();
41
        $this->assertJsonResponse($response, 200);
42
43
        $this->client->request('GET', '/others/google-sketchup-pro-2015');
44
        $response = $this->client->getResponse();
45
        $this->assertJsonResponse($response, 200);
46
47
        $this->client->request('GET', '/softwares/autocad-2014-windows');
48
        $response = $this->client->getResponse();
49
        $this->assertJsonResponse($response, 200);
50
51
        $this->client->request('GET', '/series/house-of-cards/episodes/s01-e09-chapter-9');
52
        $response = $this->client->getResponse();
53
        $this->assertJsonResponse($response, 200);
54
55
        $this->client->request('GET', '/series/house-of-cards/episodes/s02-e02-chapter-15');
56
        $response = $this->client->getResponse();
57
        $this->assertJsonResponse($response, 200);
58
    }
59
60
    // FIXME disabled because OMDBAPI went private...
0 ignored issues
show
Coding Style introduced by
Comment refers to a FIXME task "disabled because OMDBAPI went private"
Loading history...
61
62
    // public function testImdbSearch()
63
    // {
64
    //     $this->client->request('POST', '/imdb/search', ['album' => 'Back In Black']);
65
    //     $response = $this->client->getResponse();
66
    //     $this->assertJsonResponse($response, 400);
67
    //
68
    //     $this->client->request('POST', '/imdb/search', ['name' => 'Star Wars']);
69
    //     $response = $this->client->getResponse();
70
    //     $this->assertJsonResponse($response, 200);
71
    //     $this->assertTrue(!empty(json_decode($response->getContent())));
72
    // }
73
    //
74
    // public function testImdbInfos()
75
    // {
76
    //     $this->client->request('POST', '/imdb/infos', ['album' => 'Back In Black']);
77
    //     $response = $this->client->getResponse();
78
    //     $this->assertJsonResponse($response, 400);
79
    //
80
    //     $this->client->request('POST', '/imdb/infos', ['id' => 'tt0076759']);
81
    //     $response = $this->client->getResponse();
82
    //     $this->assertJsonResponse($response, 200);
83
    //     $infos = json_decode($response->getContent(), true);
84
    //     $this->assertNotEquals($infos, null);
85
    //     $this->assertEquals($infos['year'], 1977);
86
    //     $this->assertEquals($infos['duration'], 121*60);
87
    //     $this->assertEquals($infos['director'], 'George Lucas');
88
    // }
89
90
    public function testStatistics()
91
    {
92
        $this->client->request('GET', '/statistics/ponthub');
93
        $response = $this->client->getResponse();
94
        $this->assertJsonResponse($response, 200);
95
    }
96
}
97