Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Heure de repos pour l'employé #94

Merged
merged 10 commits into from
May 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Groupe/GroupeRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @author Wouldsmina
*
* @since 0.7
* @see \LibertAPI\Tests\Units\Planning\PlanningRepository
* @see \LibertAPI\Tests\Units\Groupe\GroupeRepository
*
* Ne devrait être contacté que par le GroupeController
* Ne devrait contacter que le GroupeEntite
Expand Down
90 changes: 90 additions & 0 deletions Heure/Repos/ReposEntite.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?php declare(strict_types = 1);
namespace LibertAPI\Heure\Repos;

use LibertAPI\Tools\Exceptions\MissingArgumentException;

/**
* @inheritDoc
*
* @author Prytoegrian <prytoegrian@protonmail.com>
* @author Wouldsmina
*
* @since 1.8
* @see \LibertAPI\Tests\Units\Heure\Repos\ReposEntite
*
* Ne devrait être contacté que par le ReposRepository
* Ne devrait contacter personne
*/
class ReposEntite extends \LibertAPI\Tools\Libraries\AEntite
{
/**
* Retourne la donnée la plus à jour du champ login
*/
public function getLogin() : string
{
return $this->getFreshData('login');
}

/**
* Retourne la donnée la plus à jour du champ debut
*/
public function getDebut() : int
{
return $this->getFreshData('debut');
}

/**
* Retourne la donnée la plus à jour du champ fin
*/
public function getFin() : int
{
return $this->getFreshData('fin');
}

/**
* Retourne la donnée la plus à jour du champ duree
*/
public function getDuree() : int
{
return $this->getFreshData('duree');
}

/**
* Retourne la donnée la plus à jour du champ type_periode
*/
public function getTypePeriode() : int
{
return $this->getFreshData('type_periode');
}

/**
* Retourne la donnée la plus à jour du champ statut
*/
public function getStatut() : int
{
return $this->getFreshData('statut');
}

/**
* Retourne la donnée la plus à jour du champ commentaire
*/
public function getCommentaire() : string
{
return $this->getFreshData('commentaire');
}

/**
* Retourne la donnée la plus à jour du champ commentaire_refus
*/
public function getCommentaireRefus() : string
{
return $this->getFreshData('commentaire_refus');
}

/**
* @inheritDoc
*/
public function populate(array $data)
{
}
}
96 changes: 96 additions & 0 deletions Heure/Repos/ReposRepository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?php declare(strict_types = 1);
namespace LibertAPI\Heure\Repos;

use LibertAPI\Tools\Libraries\AEntite;

/**
* {@inheritDoc}
*
* @author Prytoegrian <prytoegrian@protonmail.com>
* @author Wouldsmina
*
* @since 1.8
* @see \LibertAPI\Tests\Units\Heure\Repos\ReposRepository
*
* Ne devrait être contacté que par le HeureReposEmployeController
* Ne devrait contacter que le ReposEntite
*/
class ReposRepository extends \LibertAPI\Tools\Libraries\ARepository
{
final protected function getEntiteClass() : string
{
return ReposEntite::class;
}

/**
* @inheritDoc
*/
final protected function getParamsConsumer2Storage(array $paramsConsumer) : array
{
$results = [];
if (array_key_exists('login', $paramsConsumer)) {
$results['login'] = (string) $paramsConsumer['login'];
}

return $results;
}

/**
* @inheritDoc
*/
final protected function getStorage2Entite(array $dataStorage)
{
return [
'id' => $dataStorage['id_heure'],
'login' => $dataStorage['login'],
'debut' => (int) $dataStorage['debut'],
'fin' => (int) $dataStorage['fin'],
'duree' => (int) $dataStorage['duree'],
'type_periode' => (int) $dataStorage['type_periode'],
'statut' => (int) $dataStorage['statut'],
'commentaire' => $dataStorage['comment'],
'commentaire_refus' => $dataStorage['comment_refus'],
];
}

/**
* @inheritDoc
*/
final protected function setValues(array $values)
{
unset($values);
}

final protected function setSet(array $parametres)
{
unset($parametres);
}

/**
* @inheritDoc
*/
final protected function setWhere(array $parametres)
{
if (array_key_exists('login', $parametres)) {
$this->queryBuilder->andWhere('login = :login');
$this->queryBuilder->setParameter(':login', $parametres['login']);
}
}

/**
* @inheritDoc
*/
final protected function getEntite2Storage(AEntite $entite) : array
{
unset($entite);
return [];
}

/**
* @inheritDoc
*/
final protected function getTableName() : string
{
return 'heure_repos';
}
}
24 changes: 16 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,36 @@ define make_version
@git tag -a `semver tag` -m "Releasing `semver tag`"
endef

default : help
.DEFAULT_GOAL := help

#
# Thanks to https://blog.theodo.fr/2018/05/why-you-need-a-makefile-on-your-project/
#

help:
@echo 'help'
@grep -E '(^[a-zA-Z_-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}{printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m##/[33m/'


install:
## Installation
install: ## Installe les dépendances composer
php composer.phar install

major:
## Administration
major: ## Monte la version majeure du logiciel
$(call make_version,major)

minor:
minor: ## Monte la version mineure du logiciel
$(call make_version,minor)

patch:
patch: ## Monte la version patch du logiciel
$(call make_version,patch)

test: test-unit test-functional
## CI
test: test-unit test-functional ## Lance tous les tests applicatifs

test-unit: ## Lance les tests unitaires
Vendor/Bin/atoum -ulr

test-functional:
test-functional: ## Lance les tests fonctionnels
cp Tests/Functionals/_data/database.sqlite Tests/Functionals/_data/current.sqlite
Vendor/Bin/codecept run api -f
67 changes: 67 additions & 0 deletions Tests/Units/Heure/Repos/ReposEntite.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php declare(strict_types = 1);
namespace LibertAPI\Tests\Units\Heure\Repos;

/**
* Classe de test de l'entité d'heure de repos
*
* @author Prytoegrian <prytoegrian@protonmail.com>
* @author Wouldsmina
*
* @since 1.8
*/
final class ReposEntite extends \LibertAPI\Tests\Units\Tools\Libraries\AEntite
{
/**
* @inheritDoc
*/
public function testConstructWithId()
{
$id = 58;
$commentaire = 'Barry Allen';
$commentaireRefus = 'Barry Allen 2';

$this->newTestedInstance([
'id' => $id,
'login' => 'Abagnale',
'debut' => 1000,
'fin' => 1100,
'duree' => 10,
'type_periode' => 7,
'statut' => 10,
'commentaire' => $commentaire,
'commentaire_refus' => $commentaireRefus,
]);

$this->assertConstructWithId($this->testedInstance, $id);
$this->string($this->testedInstance->getLogin())->isIdenticalTo('Abagnale');
$this->integer($this->testedInstance->getDebut())->isIdenticalTo(1000);
$this->integer($this->testedInstance->getFin())->isIdenticalTo(1100);
$this->integer($this->testedInstance->getDuree())->isIdenticalTo(10);
$this->integer($this->testedInstance->getTypePeriode())->isIdenticalTo(7);
$this->integer($this->testedInstance->getStatut())->isIdenticalTo(10);
$this->string($this->testedInstance->getCommentaire())->isIdenticalTo($commentaire);
$this->string($this->testedInstance->getCommentaireRefus())->isIdenticalTo($commentaireRefus);
}

/**
* @inheritDoc
*/
public function testConstructWithoutId()
{
$this->newTestedInstance([
'login' => 'Abagnale',
'debut' => 1000,
]);
$this->variable($this->testedInstance->getId())->isNull();
}

/**
* @inheritDoc
*/
public function testReset()
{
$this->newTestedInstance(['login' => 'Abagnale', 'debut' => 1000,]);

$this->assertReset($this->testedInstance);
}
}
37 changes: 37 additions & 0 deletions Tests/Units/Heure/Repos/ReposRepository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php declare(strict_types = 1);
namespace LibertAPI\Tests\Units\Heure\Repos;

/**
* Classe de test du repository de l'heure de repos
*
* @author Prytoegrian <prytoegrian@protonmail.com>
* @author Wouldsmina
*
* @since 1.8
*/
final class ReposRepository extends \LibertAPI\Tests\Units\Tools\Libraries\ARepository
{
final protected function getStorageContent() : array
{
return [
'id_heure' => 42,
'login' => 'Sherlock',
'debut' => 7427,
'fin' => 4527,
'duree' => 78,
'type_periode' => 26,
'statut' => 3,
'comment' => 'Arsène',
'comment_refus' => 'Lupin',
];
}

protected function getConsumerContent() : array
{
return [
'login' => 'Watson',
'debut' => 77,
'fin' => 89432,
];
}
}
3 changes: 2 additions & 1 deletion Tools/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@
return $response->withJson('Hi there !');
});

require_once ROUTE_PATH . DS. 'Absence.php';
require_once ROUTE_PATH . DS . 'Absence.php';
require_once ROUTE_PATH . DS . 'Authentification.php';
require_once ROUTE_PATH . DS . 'Groupe.php';
require_once ROUTE_PATH . DS . 'Heure.php';
require_once ROUTE_PATH . DS . 'Journal.php';
require_once ROUTE_PATH . DS . 'JourFerie.php';
require_once ROUTE_PATH . DS . 'Planning.php';
Expand Down
Loading