Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Départements-Notaires
Départements-Notaires v2
Commits
565f99d2
Commit
565f99d2
authored
Jul 28, 2020
by
Cédric Girardot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Build : Ajoute tests Cypress dans Jenkins
Change-Id: I705baef3e04ac9107756c2b34fcbbe2f62f0a3e8
parent
a516d492
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
143 additions
and
6 deletions
+143
-6
Jenkinsfile.review
Jenkinsfile.review
+24
-0
appli_sf/tests/FunctionalTests/Controller/DefaultControllerTest.php
...ests/FunctionalTests/Controller/DefaultControllerTest.php
+11
-1
appli_sf/tests/FunctionalTests/TestCase/FixtureAwareWebTestCase.php
...ests/FunctionalTests/TestCase/FixtureAwareWebTestCase.php
+71
-0
docker/lamp/Dockerfile
docker/lamp/Dockerfile
+23
-5
docker/lamp/files/create_mysql_users.sh
docker/lamp/files/create_mysql_users.sh
+8
-0
docker/lamp/files/run.sh
docker/lamp/files/run.sh
+6
-0
No files found.
Jenkinsfile.review
View file @
565f99d2
...
...
@@ -68,6 +68,9 @@ pipeline {
stage
(
"Unit tests"
)
{
steps
{
dir
(
'appli_sf'
)
{
sh
'bin/console doctrine:schema:drop --force'
sh
'bin/console doctrine:schema:update --force'
sh
'bin/console cache:clear'
sh
'bin/phpunit tests/UnitTests'
}
}
...
...
@@ -75,10 +78,31 @@ pipeline {
stage
(
"Functional tests"
)
{
steps
{
dir
(
'appli_sf'
)
{
sh
'bin/console doctrine:schema:drop --force'
sh
'bin/console doctrine:schema:update --force'
sh
'bin/console cache:clear'
sh
'bin/phpunit tests/FunctionalTests'
}
}
}
stage
(
"E2E tests"
)
{
environment
{
CYPRESS_BASE_URL
=
"http://localhost"
}
steps
{
dir
(
'appli_sf'
)
{
sh
'bin/console doctrine:schema:drop --force'
sh
'bin/console doctrine:schema:update --force'
sh
'bin/console cache:clear'
sh
'bin/console import:individus imports/individus.csv --use-civil-name=1 --no-interaction --quiet'
sh
'bin/console user:add --username=admin --password=P@ssword12345 --email=test@deptnot.test --name=Administrateur --role=ROLE_ADMIN --no-interaction'
dir
(
'tests/E2E'
)
{
sh
'yarn'
sh
' cypress run'
}
}
}
}
}
}
}
...
...
appli_sf/tests/FunctionalTests/Controller/DefaultControllerTest.php
View file @
565f99d2
...
...
@@ -2,15 +2,19 @@
namespace
App\Tests\FunctionalTests\Controller
;
use
App\DataFixtures\PersonCivilNameFixtures
;
use
App\DataFixtures\UserFixtures
;
use
App\Entity\User
;
use
App\Helper\UserHelper
;
use
App\Repository\UserRepository
;
use
App\Tests\FunctionalTests\TestCase\FixtureAwareWebTestCase
;
use
Symfony\Bundle\FrameworkBundle\Test\WebTestCase
;
use
Symfony\Component\BrowserKit\Cookie
;
use
Symfony\Component\HttpFoundation\Response
;
use
Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken
;
use
Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface
;
class
DefaultControllerTest
extends
WebTestCase
class
DefaultControllerTest
extends
FixtureAware
WebTestCase
{
/**
* @var \Doctrine\ORM\EntityManager
...
...
@@ -33,6 +37,12 @@ class DefaultControllerTest extends WebTestCase
$this
->
entityManager
=
$kernel
->
getContainer
()
->
get
(
'doctrine'
)
->
getManager
();
$encoder
=
self
::
$container
->
get
(
UserPasswordEncoderInterface
::
class
);
// Chargement des fixtures
$this
->
addFixture
(
new
UserFixtures
(
$encoder
));
$this
->
addFixture
(
new
PersonCivilNameFixtures
());
$this
->
executeFixtures
();
}
/**
...
...
appli_sf/tests/FunctionalTests/TestCase/FixtureAwareWebTestCase.php
0 → 100644
View file @
565f99d2
<?php
namespace
App\Tests\FunctionalTests\TestCase
;
use
Doctrine\Common\DataFixtures\Executor\ORMExecutor
;
use
Doctrine\Common\DataFixtures\FixtureInterface
;
use
Doctrine\Common\DataFixtures\Purger\ORMPurger
;
use
Symfony\Bridge\Doctrine\DataFixtures\ContainerAwareLoader
;
use
Symfony\Bundle\FrameworkBundle\Test\WebTestCase
;
abstract
class
FixtureAwareWebTestCase
extends
WebTestCase
{
/**
* @var ORMExecutor
*/
private
$fixtureExecutor
;
/**
* @var ContainerAwareLoader
*/
private
$fixtureLoader
;
public
function
setUp
()
{
self
::
bootKernel
();
}
/**
* Adds a new fixture to be loaded.
*
* @param FixtureInterface $fixture
*/
protected
function
addFixture
(
FixtureInterface
$fixture
)
{
$this
->
getFixtureLoader
()
->
addFixture
(
$fixture
);
}
/**
* Executes all the fixtures that have been loaded so far.
*/
protected
function
executeFixtures
()
{
$this
->
getFixtureExecutor
()
->
execute
(
$this
->
getFixtureLoader
()
->
getFixtures
());
}
/**
* @return ORMExecutor
*/
private
function
getFixtureExecutor
()
{
if
(
!
$this
->
fixtureExecutor
)
{
/** @var \Doctrine\ORM\EntityManager $entityManager */
$entityManager
=
self
::
$kernel
->
getContainer
()
->
get
(
'doctrine'
)
->
getManager
();
$this
->
fixtureExecutor
=
new
ORMExecutor
(
$entityManager
,
new
ORMPurger
(
$entityManager
));
}
return
$this
->
fixtureExecutor
;
}
/**
* @return ContainerAwareLoader
*/
private
function
getFixtureLoader
()
{
if
(
!
$this
->
fixtureLoader
)
{
$this
->
fixtureLoader
=
new
ContainerAwareLoader
(
self
::
$kernel
->
getContainer
());
}
return
$this
->
fixtureLoader
;
}
}
docker/lamp/Dockerfile
View file @
565f99d2
...
...
@@ -16,7 +16,7 @@ RUN groupmod -g ${BOOT2DOCKER_GID} staff
ENV
DEBIAN_FRONTEND noninteractive
RUN
set
-eux
;
\
apt-get update
;
\
apt-get
install
-y
\
apt-get
install
-y
--no-install-recommends
\
supervisor
\
wget
\
apache2
\
...
...
@@ -31,14 +31,29 @@ RUN set -eux; \
php-zip
\
libapache2-mod-php
\
curl
\
gnupg2
\
gnupg
\
ca-certificates
\
libgtk2.0-0
\
libgtk-3-0
\
libnotify-dev
\
libgconf-2-4
\
libnss3
\
libxss1
\
libasound2
\
libxtst6
\
xauth
\
xvfb
\
jq
;
\
echo
"ServerName localhost"
>>
/etc/apache2/apache2.conf
;
# Install yarn
RUN
curl
-sS
https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
&&
\
echo
"deb https://dl.yarnpkg.com/debian/ stable main"
|
tee
/etc/apt/sources.list.d/yarn.list
&&
\
apt-get update
&&
apt-get
install
-y
yarn
ENV
APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=DontWarn
RUN
set
-eux
;
\
apt-get update
&&
apt-get
install
-y
gnupg
;
\
curl
-sS
https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
;
\
echo
"deb https://dl.yarnpkg.com/debian/ stable main"
|
tee
/etc/apt/sources.list.d/yarn.list
;
\
apt-get update
;
\
apt-get
install
-y
--no-install-recommends
nodejs yarn
;
# Add image configuration and scripts
ADD
files/start-apache2.sh /start-apache2.sh
...
...
@@ -71,6 +86,9 @@ ENV PHP_UPLOAD_MAX_FILESIZE 10M
ENV
PHP_POST_MAX_SIZE 10M
ENV
PHP_VERSION 7.2
# Install Cypress
RUN
yarn global add
--pure-lockfile
cypress@4.11.0
;
WORKDIR
/app
CMD
["/run.sh"]
docker/lamp/files/create_mysql_users.sh
View file @
565f99d2
...
...
@@ -3,11 +3,19 @@
/usr/bin/mysqld_safe
>
/dev/null 2>&1 &
RET
=
1
COUNT_ATTEMPT
=
0
NB_MAX_ATTEMPT
=
15
while
[[
RET
-ne
0
]]
;
do
echo
"=> Waiting for confirmation of MySQL service startup"
sleep
5
mysql
-uroot
-e
"status"
>
/dev/null 2>&1
RET
=
$?
((
COUNT_ATTEMPT
=
COUNT_ATTEMPT+1
))
echo
"=> Tentative
$COUNT_ATTEMPT
sur
$NB_MAX_ATTEMPT
"
if
[[
COUNT_ATTEMPT
-ge
NB_MAX_ATTEMPT
]]
;
then
exit
5
;
fi
done
mysql
-uroot
-e
"CREATE USER 'notaires'@'localhost' IDENTIFIED BY 'password'"
...
...
docker/lamp/files/run.sh
View file @
565f99d2
...
...
@@ -82,6 +82,12 @@ if [[ ! -d $VOLUME_HOME/mysql ]]; then
echo
"=> Done!"
/create_mysql_users.sh
RET
=
$?
if
[[
RET
-ne
0
]]
;
then
echo
"=> Échec du démarrage de la BDD"
exit
$?
fi
else
echo
"=> Using an existing volume of MySQL"
fi
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment