Commit 502a0f9f authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Test unitaires : début des corrections et mises à jour. NB: modif de...

Test unitaires : début des corrections et mises à jour. NB: modif de AbstractMenu nécessaire pour réussite des tests de MenuContextuel.
Modif minimes du code (doc, identation, etc.)
parent fd2b07c5
Loading
Loading
Loading
Loading
+12 −11
Changes for src/UnicaenApp/Form/Element/DateInfSupInputFilter.php: 12 added lines, 11 removed lines.
Original line number Diff line number Diff line
<?php

namespace UnicaenApp\Form\Element;

use DateTime;
@@ -87,7 +88,7 @@ class DateInfSupInputFilter extends InputFilter
    /**
     * Construteur.
     * 
     * @parm string $datetimeFormat Format de date/heure à utiliser
     * @param string $datetimeFormat Format de date/heure à utiliser
     */
    public function __construct($datetimeFormat)
    {
@@ -107,10 +108,10 @@ class DateInfSupInputFilter extends InputFilter
    /**
     * Is the data set valid?
     *
     * @throws Exception\RuntimeException
     * @param  mixed|null $context
     * @return bool
     */
    public function isValid()
    public function isValid($context = null)
    {
        $this->init();
        
@@ -136,12 +137,12 @@ class DateInfSupInputFilter extends InputFilter
        
        // dates obligatoires (NB: les 'NotEmpty' doivent être les 1ers validateurs installés)
        if ($this->getDateInfRequired()) {
            $dateInfValidatorChain->addValidator(
            $dateInfValidatorChain->attach(
                    new NotEmpty(array('messages' => array('isEmpty' => _("La date inférieure est requise")))),
                    true);
        }
        if ($this->getDateSupRequired()) {
            $dateSupValidatorChain->addValidator(
            $dateSupValidatorChain->attach(
                    new NotEmpty(array('messages' => array('isEmpty' => _("La date supérieure est requise")))),
                    true);
        }
@@ -149,13 +150,13 @@ class DateInfSupInputFilter extends InputFilter
        $this->inputSup->setRequired($this->getDateSupRequired());

        // format requis pour les dates
        $dateInfValidatorChain->addValidator(
        $dateInfValidatorChain->attach(
                new DateValidator(array(
                    'format' => $this->getDatetimeFormat(), 
                    'messages' => array(DateValidator::INVALID_DATE => "La date inférieure spécifiée n'est pas valide"),
                )), 
                true);
        $dateSupValidatorChain->addValidator(
        $dateSupValidatorChain->attach(
                new DateValidator(array(
                    'format' => $this->getDatetimeFormat(), 
                    'messages' => array(DateValidator::INVALID_DATE => "La date supérieure spécifiée n'est pas valide"),
@@ -181,7 +182,7 @@ class DateInfSupInputFilter extends InputFilter
        
        // bornes sur les dates
        if (($date = $this->getDateInfMin())) {
            $dateInfValidatorChain->addValidator(
            $dateInfValidatorChain->attach(
                    new LaterThan(array(
                        'min' => $date,
                        'format' => $this->getDatetimeFormat(),
@@ -193,7 +194,7 @@ class DateInfSupInputFilter extends InputFilter
                    true);
        }
        if (($date = $this->getDateInfMax())) {
            $dateInfValidatorChain->addValidator(
            $dateInfValidatorChain->attach(
                    new EarlierThan(array(
                        'max' => $date,
                        'format' => $this->getDatetimeFormat(),
@@ -205,7 +206,7 @@ class DateInfSupInputFilter extends InputFilter
                    true);
        }
        if (($date = $this->getDateSupMin())) {
            $dateSupValidatorChain->addValidator(
            $dateSupValidatorChain->attach(
                    new LaterThan(array(
                        'min' => $date,
                        'format' => $this->getDatetimeFormat(),
@@ -217,7 +218,7 @@ class DateInfSupInputFilter extends InputFilter
                    true);
        }
        if (($date = $this->getDateSupMax())) {
            $dateSupValidatorChain->addValidator(
            $dateSupValidatorChain->attach(
                    new EarlierThan(array(
                        'max' => $date,
                        'format' => $this->getDatetimeFormat(),
+1
Changes for src/UnicaenApp/Form/View/Helper/FormDateInfSup.php: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
<?php

namespace UnicaenApp\Form\View\Helper;

use Zend\Form\Element\Text;
+4 −1
Changes for src/UnicaenApp/Message/MessageConfig.php: 4 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -39,8 +39,11 @@ class MessageConfig
     * @param MessageConfigNormalizer $normalizer
     * @return MessageConfig
     */
    static public function create(MessageConfigNormalizer $normalizer)
    static public function create(MessageConfigNormalizer $normalizer = null)
    {
        if (! $normalizer) {
            $normalizer = new MessageConfigNormalizer();
        }
        return new self($normalizer->getNormalizedConfig());
    }
}
 No newline at end of file
+2 −2
Changes for src/UnicaenApp/Message/MessageConfigNormalizer.php: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ class MessageConfigNormalizer
    /**
     * @param ServiceLocatorInterface $serviceLocator Utile pour les spécifications injectées dans le service manager
     */
    public function __construct(ServiceLocatorInterface $serviceLocator)
    public function __construct(ServiceLocatorInterface $serviceLocator = null)
    {
        $this->serviceLocator = $serviceLocator;
    }
@@ -120,7 +120,7 @@ class MessageConfigNormalizer

        // Si la spécification est le nom d'un service connu du service locator,
        // la spécification devient le service lui-même.
        if ($this->serviceLocator->has($specification)) {
        if ($this->serviceLocator && $this->serviceLocator->has($specification)) {
            return $this->serviceLocator->get($specification);
        }

+21 −12
Changes for src/UnicaenApp/View/Helper/Navigation/MenuContextuel.php: 21 added lines, 12 removed lines.
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@

namespace UnicaenApp\View\Helper\Navigation;

use Zend\Navigation\AbstractContainer;
use UnicaenApp\Exception\RuntimeException;
use Zend\Navigation\Page\AbstractPage;

/**
@@ -27,27 +27,32 @@ class MenuContextuel extends AbstractMenu
    protected $eventName;

    /**
     * View helper entry point:
     * Retrieves helper and optionally sets container to operate on
     *
     * @param AbstractContainer $container [optional] container to operate on
     * @return self
     * @param $container
     */
    public function __invoke($container = null)
    protected function populate($container)
    {
        $this->setContainer($container);
        $this->setRenderInvisible(true);

        $activePage = $this->getActivePage();
        if (!$activePage) {
            throw new \UnicaenApp\Exception\RuntimeException("Impossible d'afficher les liens de navigation: page de navigation active introuvable.");
            throw new RuntimeException("Impossible d'afficher les liens de navigation: page de navigation active introuvable.");
        }

        // replace pages
        $this->getContainer()->setPages($activePage->getPages());
    }
        $container = new \Zend\Navigation\Navigation($activePage->getPages());

        return parent::__invoke($container);
    public function render($container = null)
    {
        $this->populate($container);

        return parent::render();
    }

    /**
     * {@inheritedDoc}
     * @param array $attribs
     * @return string
     */
    protected function htmlAttribs($attribs)
    {
@@ -61,7 +66,10 @@ class MenuContextuel extends AbstractMenu
    }

    /**
     * {@inheritedDoc}
     * @param AbstractPage $page
     * @param bool         $escapeLabel
     * @param bool         $addClassToListItem
     * @return null|string
     */
    public function htmlify(AbstractPage $page, $escapeLabel = true, $addClassToListItem = false)
    {
@@ -77,6 +85,7 @@ class MenuContextuel extends AbstractMenu
     * la fenêtre modale est POSTé.
     *
     * @param AbstractPage $page
     * @return array|string
     */
    protected function createEventName(AbstractPage $page)
    {
Loading