forked from Symfomany/laravelcinema
/
MoviesTest.php
executable file
·111 lines (92 loc) · 2.7 KB
/
MoviesTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
class MoviesTest extends TestCase
{
use WithoutMiddleware;
// https://openclassrooms.com/courses/decouvrez-le-framework-php-laravel/les-tests-unitaires-4
/**
* A basic functional test example.
*
* @return void
*/
public function testHomepage()
{
$this->visit('/')
->see("We're Getting Ready To Launch!");
}
/**
* Test login
*/
public function testAdmin()
{
$this->visit('/admin')
->followRedirects()
->see("Email")
->see("Password");
}
/**
* Test login
*/
public function testAuthentificationFailure()
{
$this->visit('/auth/login')
->see("Email")
->see("Password")
->type('blabla@gmail.com', 'email')
->type('djscrave', 'password')
->press('Connexion')
->followRedirects()
->see("Email")
->see("Password")
->seePageIs('/auth/login');
}
/**
* Test login Success
*/
public function testAuthentificationSuccess()
{
$this->visit('/auth/login')
->type('julien2@meetserious.com', 'email')
->type('123456', 'password')
->check('remember')
->press('Connexion')
->followRedirects()
->seePageIs('/admin');
}
/**
* Test login
*/
public function testMoviesVisibleAndCover()
{
$this->visit('/auth/login')
->type('julien2@meetserious.com', 'email')
->type('123456', 'password')
->check('remember')
->press('Connexion')
->followRedirects()
->see('Dashboard')
->click('Gestion des films')
->seePageIs("admin/movies/index")
->see("Le seigneur des anneaux")
->get('http://localhost:8000/admin/movies/cover/1') //get requet
->followRedirects()
->see("Le film Le seigneur des anneaux a bien été retiré de l'avant")
->seeInDatabase('movies', ['id' => 1, 'cover' => 0])
->get('http://localhost:8000/admin/movies/activate/1')
->followRedirects()
->seeInDatabase('movies', ['id' => 1, 'visible' => 0]);
}
/**
* Test login
*/
public function testMoviesCreateFailure()
{
$this->markTestSkipped("Sorry...");
$this
->visit('/admin/movies/create');
// ->seePageIs('/admin/movies/create')
// ->type('z', 'title')
// ->press('Enregistrer ce film');
}
}