Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
É
Éco-presto
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
COLLINOT Baptiste
Éco-presto
Commits
c1028fd9
Commit
c1028fd9
authored
1 year ago
by
DEMANGEL Mael
Browse files
Options
Downloads
Patches
Plain Diff
ajout du test de poster une annonce
parent
fcbd51b2
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
templates/annonce_creation/creation.html.twig
+1
-1
1 addition, 1 deletion
templates/annonce_creation/creation.html.twig
tests/TestsPosterAnnonceTest.php
+119
-0
119 additions, 0 deletions
tests/TestsPosterAnnonceTest.php
with
120 additions
and
1 deletion
templates/annonce_creation/creation.html.twig
+
1
−
1
View file @
c1028fd9
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
Date de début*
Date de début*
{{
form_widget
(
form.date_debut
,
{
'attr'
:
{
'required'
:
true
,
'class'
:
'form-control'
}}
) }}
{{
form_widget
(
form.date_debut
,
{
'attr'
:
{
'required'
:
true
,
'class'
:
'form-control'
}}
) }}
<button
type=
"submit"
class=
"creation_annonce"
>
Créer
</button>
<button
type=
"submit"
id=
"creer_annonce"
class=
"creation_annonce"
>
Créer
</button>
</div>
</div>
{{
form_end
(
form
)
}}
{{
form_end
(
form
)
}}
<a
href=
"
{{
path
(
"app_home_page"
)
}}
"
><button
class=
"btn-connexion2"
>
Retourner à l'accueil
</button></a>
<a
href=
"
{{
path
(
"app_home_page"
)
}}
"
><button
class=
"btn-connexion2"
>
Retourner à l'accueil
</button></a>
...
...
This diff is collapsed.
Click to expand it.
tests/TestsPosterAnnonceTest.php
0 → 100644
+
119
−
0
View file @
c1028fd9
<?php
namespace
App\Tests
;
use
Symfony\Bundle\FrameworkBundle\Test\WebTestCase
;
use
App\Repository\PersonneRepository
;
class
TestsPosterAnnonceTest
extends
WebTestCase
{
public
function
testPosterAnnonce
():
void
{
$client
=
static
::
createClient
();
$userRepository
=
static
::
getContainer
()
->
get
(
PersonneRepository
::
class
);
$user
=
$userRepository
->
findOneByLogin
(
'test'
);
$client
->
loginUser
(
$user
);
// Accéder à la page d'inscription
$client
->
request
(
'GET'
,
'/annonce/creation'
);
// Soumettre le formulaire de création avec des données valides
$client
->
submitForm
(
'creer_annonce'
,[
'annonce[type_prestation]'
=>
'pret'
,
'annonce[titre]'
=>
'testAnnonce'
,
'annonce[descr_prestation]'
=>
'ceci est une description'
,
'annonce[cout_prestation]'
=>
50
,
]);
$this
->
assertResponseRedirects
(
'/'
);
//On test si l'on peut créer deux fois la même annonce
$client
->
request
(
'GET'
,
'/annonce/creation'
);
// Soumettre le formulaire de création avec des données valides
$client
->
submitForm
(
'creer_annonce'
,[
'annonce[type_prestation]'
=>
'pret'
,
'annonce[titre]'
=>
'testAnnonce'
,
'annonce[descr_prestation]'
=>
'ceci est une description'
,
'annonce[cout_prestation]'
=>
50
,
]);
$this
->
assertResponseRedirects
(
'/'
);
//On test si le titre peut être vide
$client
->
request
(
'GET'
,
'/annonce/creation'
);
// Soumettre le formulaire de création avec des données valides
$client
->
submitForm
(
'creer_annonce'
,[
'annonce[type_prestation]'
=>
'pret'
,
'annonce[titre]'
=>
null
,
'annonce[descr_prestation]'
=>
'ceci est une description'
,
'annonce[cout_prestation]'
=>
50
,
]);
$this
->
assertFalse
(
$client
->
getResponse
()
->
isRedirect
());
//On test si le cout peut être nul
$client
->
request
(
'GET'
,
'/annonce/creation'
);
// Soumettre le formulaire de création avec des données valides
$client
->
submitForm
(
'creer_annonce'
,[
'annonce[type_prestation]'
=>
'pret'
,
'annonce[titre]'
=>
''
,
'annonce[descr_prestation]'
=>
'ceci est une description'
,
'annonce[cout_prestation]'
=>
null
,
]);
$this
->
assertFalse
(
$client
->
getResponse
()
->
isRedirect
());
}
public
function
testVisualisationAnnonce
():
void
{
$client
=
static
::
createClient
();
$userRepository
=
static
::
getContainer
()
->
get
(
PersonneRepository
::
class
);
$user
=
$userRepository
->
findOneByLogin
(
'test'
);
$client
->
loginUser
(
$user
);
// Accéder à la page de création d'annonce
$client
->
request
(
'GET'
,
'/annonce/creation'
);
// Soumettre le formulaire de création avec des données valides
$client
->
submitForm
(
'creer_annonce'
,[
'annonce[type_prestation]'
=>
'pret'
,
'annonce[titre]'
=>
'testPretAnnonce'
,
'annonce[descr_prestation]'
=>
'ceci est une description'
,
'annonce[cout_prestation]'
=>
50
,
]);
$this
->
assertResponseRedirects
(
'/'
);
// Accéder à la page de création d'annonce
$client
->
request
(
'GET'
,
'/annonce/creation'
);
// Soumettre le formulaire de création avec des données valides
$client
->
submitForm
(
'creer_annonce'
,[
'annonce[type_prestation]'
=>
'service'
,
'annonce[titre]'
=>
'testServiceAnnonce'
,
'annonce[descr_prestation]'
=>
'ceci est une description'
,
'annonce[cout_prestation]'
=>
100
,
]);
$this
->
assertResponseRedirects
(
'/'
);
$client
->
request
(
'GET'
,
''
);
$this
->
assertSelectorExists
(
'p'
,
'testPretAnnonce'
);
$this
->
assertSelectorExists
(
'p'
,
'50 florains'
);
$this
->
assertSelectorExists
(
'p'
,
'Prèt'
);
$this
->
assertSelectorExists
(
'p'
,
'testServiceAnnonce'
);
$this
->
assertSelectorExists
(
'p'
,
'100 florains'
);
$this
->
assertSelectorExists
(
'p'
,
'Service'
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment