diff --git a/src/UnicaenApp/Controller/Plugin/Exception/IllegalStateException.php b/src/UnicaenApp/Controller/Plugin/Exception/IllegalStateException.php index ade7c90fbefa5a3b207828c7523599bfb7895847..8aa3cfa86102260e4d2f0f793a2c1a1db23799af 100644 --- a/src/UnicaenApp/Controller/Plugin/Exception/IllegalStateException.php +++ b/src/UnicaenApp/Controller/Plugin/Exception/IllegalStateException.php @@ -1,14 +1,14 @@ <?php namespace UnicaenApp\Controller\Plugin\Exception; -use UnicaenApp\Exception; +use UnicaenApp\Exception\LogicException; /** * Description of IllegalStateException * * @author Bertrand GAUTHIER <bertrand.gauthier at unicaen.fr> */ -class IllegalStateException extends Exception +class IllegalStateException extends LogicException { } diff --git a/src/UnicaenApp/Entity/Ldap/AbstractEntity.php b/src/UnicaenApp/Entity/Ldap/AbstractEntity.php index 53836447661c1d5a23e6f85158fe7c1730cd35be..cfc48efdf22e34cfd13d57394131e23b992fdfde 100644 --- a/src/UnicaenApp/Entity/Ldap/AbstractEntity.php +++ b/src/UnicaenApp/Entity/Ldap/AbstractEntity.php @@ -1,6 +1,7 @@ <?php namespace UnicaenApp\Entity\Ldap; +use UnicaenApp\Exception\LogicException; use UnicaenApp\Exception\MandatoryValueException; /** @@ -37,7 +38,7 @@ abstract class AbstractEntity { if ($key) { if (!array_key_exists($key, $this->data)) { - throw new \UnicaenApp\Exception("Attribut introuvable: '$key'."); + throw new LogicException("Attribut introuvable: '$key'."); } return $this->data[$key]; } diff --git a/src/UnicaenApp/Entity/Ldap/People.php b/src/UnicaenApp/Entity/Ldap/People.php index c65fb83bf73f007c56184e210bb0661267947a56..40b686c65df82d6550e3ea6122b965f84776a90c 100644 --- a/src/UnicaenApp/Entity/Ldap/People.php +++ b/src/UnicaenApp/Entity/Ldap/People.php @@ -3,6 +3,8 @@ namespace UnicaenApp\Entity\Ldap; use InvalidArgumentException; use UnicaenApp\Exception\MandatoryValueException; +use UnicaenApp\Exception\LogicException; +use UnicaenApp\Exception\RuntimeException; /** * Classe de représentation d'un individu de l'annuaire LDAP. @@ -282,7 +284,7 @@ class People extends AbstractEntity $cn = ldap_explode_dn($dn, 1); $cn = next($cn); if (!($group = $mapper->findOneByCn($cn))) { - throw new \UnicaenApp\Exception("Groupe LDAP introuvable avec le CN '$cn'."); + throw new RuntimeException("Groupe LDAP introuvable avec le CN '$cn'."); } if ($dateObservation && $dateObservation > $group->getSupannGroupeDateFin()) { continue; @@ -314,7 +316,7 @@ class People extends AbstractEntity // si les groupes sont spécifiés par des CN ou DN, on les fetch pour pouvoir les filtrer selon leur date de fin if (!is_object(current($group))) { if (null === $mapper) { - throw new \UnicaenApp\Exception( + throw new LogicException( "Le mapper est requis car une date d'observation a été spécifiée et les groupes fournis ne sont pas des entités."); } foreach ($group as $key => $cnOuDn) { diff --git a/src/UnicaenApp/Form/MultipageForm.php b/src/UnicaenApp/Form/MultipageForm.php index c1486464318f4c8c9ae3b9d602965f8fa631472b..07e1a23909b01cc1dd21e02d83f4bf5724a712f2 100644 --- a/src/UnicaenApp/Form/MultipageForm.php +++ b/src/UnicaenApp/Form/MultipageForm.php @@ -1,6 +1,8 @@ <?php namespace UnicaenApp\Form; +use UnicaenApp\Exception\LogicException; + /** * Classe mère des formulaire multi-pages (saisie en plusieurs étapes). * @@ -113,7 +115,7 @@ abstract class MultipageForm extends \Zend\Form\Form } else { if (in_array($fieldset->getName(), $this->fieldsetNames)) { - throw new \UnicaenApp\Exception("Ce fieldset a déjà été ajouté."); + throw new LogicException("Ce fieldset a déjà été ajouté."); } $navigationElement = new Element\MultipageFormNav(self::NAME_NAV); @@ -303,16 +305,16 @@ abstract class MultipageForm extends \Zend\Form\Form $fieldset = $fieldset->getName(); } if (!is_string($fieldset)) { - throw new \UnicaenApp\Exception("Format de fieldset spécifié invalide."); + throw new LogicException("Format de fieldset spécifié invalide."); } if (!$this->has($name = $fieldset)) { - throw new \UnicaenApp\Exception("Le fieldset '$name' spécifié n'a pas été trouvé dans le formulaire."); + throw new LogicException("Le fieldset '$name' spécifié n'a pas été trouvé dans le formulaire."); } $fieldset = $this->get($name); if (!$fieldset->has(self::NAME_NAV)) { - throw new \UnicaenApp\Exception("L'élément de navigation n'a pas été trouvé dans le fieldset spécifié."); + throw new LogicException("L'élément de navigation n'a pas été trouvé dans le fieldset spécifié."); } $nav = $fieldset->get(self::NAME_NAV); /* @var $nav Element\MultipageFormNav */ diff --git a/src/UnicaenApp/Form/View/Helper/FormDateInfSup.php b/src/UnicaenApp/Form/View/Helper/FormDateInfSup.php index 857239e91b33422aae090409a47c6de133d7309a..7644d9299d8e45520be004e1f2955c7e392c4a84 100644 --- a/src/UnicaenApp/Form/View/Helper/FormDateInfSup.php +++ b/src/UnicaenApp/Form/View/Helper/FormDateInfSup.php @@ -2,6 +2,7 @@ namespace UnicaenApp\Form\View\Helper; use Zend\Form\Element\Text; +use UnicaenApp\Exception\LogicException; use UnicaenApp\Form\Element\DateInfSup; /** @@ -258,7 +259,7 @@ EOS; public function getJavascript() { if (!$this->element) { - throw new \UnicaenApp\Exception("Aucun élément spécifié, appelez render() auparavant."); + throw new LogicException("Aucun élément spécifié, appelez render() auparavant."); } $dateFormat = DateInfSup::DATE_FORMAT_JAVASCRIPT; diff --git a/src/UnicaenApp/Form/View/Helper/FormSearchAndSelect.php b/src/UnicaenApp/Form/View/Helper/FormSearchAndSelect.php index b8c5e67f595ade23fa23c7052661dba84c754cac..770709a44caf455c1866b5cd99dcb0e30500767e 100644 --- a/src/UnicaenApp/Form/View/Helper/FormSearchAndSelect.php +++ b/src/UnicaenApp/Form/View/Helper/FormSearchAndSelect.php @@ -1,6 +1,7 @@ <?php namespace UnicaenApp\Form\View\Helper; +use UnicaenApp\Exception\LogicException; use UnicaenApp\Form\Element\SearchAndSelect; use Zend\Form\Element\Text; use Zend\Form\ElementInterface; @@ -115,12 +116,12 @@ EOS; /** * * @return string - * @throws \UnicaenApp\Exception + * @throws LogicException */ public function getJavascript() { if (!$this->element) { - throw new \UnicaenApp\Exception("Aucun élément spécifié, appelez render() auparavant."); + throw new LogicException("Aucun élément spécifié, appelez render() auparavant."); } $elementDomId = $this->element->getAttribute('id'); diff --git a/src/UnicaenApp/Mapper/Ldap/AbstractMapper.php b/src/UnicaenApp/Mapper/Ldap/AbstractMapper.php index 0b5bad4417467e22855a00e2b5410400de25fbfa..64aa53b417e97d3cc0a35ce74f9f9888fdd44446 100644 --- a/src/UnicaenApp/Mapper/Ldap/AbstractMapper.php +++ b/src/UnicaenApp/Mapper/Ldap/AbstractMapper.php @@ -2,6 +2,7 @@ namespace UnicaenApp\Mapper\Ldap; use Zend\Ldap\Ldap; +use UnicaenApp\Exception\RuntimeException; /** * Classe mère des services d'accès à l'annuaire LDAP. @@ -73,7 +74,7 @@ abstract class AbstractMapper } $entries = $this->getLdap()->searchEntries($filter, $baseDn, $scope, $attributes, $sort); if (count($entries) > 1) { - throw new \UnicaenApp\Exception("Plus d'une entrée trouvée avec ce filtre: " . $filter); + throw new RuntimeException("Plus d'une entrée trouvée avec ce filtre: " . $filter); } if (!$entries) { return null; diff --git a/src/UnicaenApp/Mapper/Ldap/Group.php b/src/UnicaenApp/Mapper/Ldap/Group.php index 98209120e8eb73df56336c0a53a25230a421373b..c56ca81fad2a3075123da8e07079cd692c47d899 100644 --- a/src/UnicaenApp/Mapper/Ldap/Group.php +++ b/src/UnicaenApp/Mapper/Ldap/Group.php @@ -1,6 +1,8 @@ <?php namespace UnicaenApp\Mapper\Ldap; +use UnicaenApp\Exception\LogicException; +use UnicaenApp\Exception\RuntimeException; use UnicaenApp\Entity\Ldap\Group as LdapGroupModel; /** @@ -134,12 +136,12 @@ class Group extends AbstractMapper foreach ($groups as $group) { if (!is_object($group)) { if (!$mapper) { - throw new \UnicaenApp\Exception("Le mapper est requis car un groupe n'est pas fourni au format objet."); + throw new LogicException("Le mapper est requis car un groupe n'est pas fourni au format objet."); } $cn = count($tmp = ldap_explode_dn($group, 1)) > 1 ? $tmp[0] : $group; $group = $mapper->findOneByCn($cn); if (!$group) { - throw new \UnicaenApp\Exception("Groupe LDAP introuvable avec le CN '$cn'."); + throw new RuntimeException("Groupe LDAP introuvable avec le CN '$cn'."); } } if ($dateObservation > $group->getSupannGroupeDateFin()) { diff --git a/src/UnicaenApp/Mapper/Ldap/People.php b/src/UnicaenApp/Mapper/Ldap/People.php index 636d47b20137c49805c82f096f12e4c8046e9f30..47b624e1dbaef6374eb670ad300e37bb9df50dfa 100644 --- a/src/UnicaenApp/Mapper/Ldap/People.php +++ b/src/UnicaenApp/Mapper/Ldap/People.php @@ -1,6 +1,10 @@ <?php + namespace UnicaenApp\Mapper\Ldap; +use UnicaenApp\Exception\LogicException; +use UnicaenApp\Exception\RuntimeException; + /** * Classe regroupant les opérations de recherche d'individu dans l'annuaire LDAP. * @@ -222,7 +226,7 @@ class People extends AbstractMapper $s = $this->getMapperStructure()->findOneByCodeEntite($code); // 2e tentative : on suppose que la structure est spécifiée par un code Harpege (ex: 'C68') if (!$s && !($s = $this->getMapperStructure()->findOneByCodeStructure($code))) { - throw new \UnicaenApp\Exception("Structure introuvable, '$code' n'est ni un code entité Supann ni un code Harpege valide."); + throw new RuntimeException("Structure introuvable, '$code' n'est ni un code entité Supann ni un code Harpege valide."); } } $structures[] = $s; @@ -275,7 +279,7 @@ class People extends AbstractMapper // on s'assure que la structure éventuelle est au format objet if (is_string($structure)) { if (!($structure = $this->getMapperStructure()->findOneByDnOrCodeEntite($id = $structure))) { - throw new \UnicaenApp\Exception("Structure introuvable dans l'annuaire avec le DN ou code entité '$id'."); + throw new RuntimeException("Structure introuvable dans l'annuaire avec le DN ou code entité '$id'."); } /* @var $structure \UnicaenApp\Entity\Ldap\Structure */ } @@ -330,7 +334,7 @@ class People extends AbstractMapper if ($structure) { if (is_string($structure)) { if (!($structure = $this->getMapperStructure()->findOneByDnOrCodeEntite($id = $structure))) { - throw new \UnicaenApp\Exception("Structure introuvable dans l'annuaire avec le DN ou code entité '$id'."); + throw new RuntimeException("Structure introuvable dans l'annuaire avec le DN ou code entité '$id'."); } } $codeEntite = $structure->getSupannCodeEntite(); @@ -375,7 +379,7 @@ class People extends AbstractMapper // on s'assure que la structure est au format objet if (is_string($structure)) { if (!($structure = $this->getMapperStructure()->findOneByDnOrCodeEntite($id = $structure))) { - throw new \UnicaenApp\Exception("Structure introuvable dans l'annuaire avec le DN ou code entité '$id'."); + throw new RuntimeException("Structure introuvable dans l'annuaire avec le DN ou code entité '$id'."); } } /* @var $structure \UnicaenApp\Entity\Ldap\Structure */ diff --git a/src/UnicaenApp/Service/Doctrine/MultipleDbAbstractFactory.php b/src/UnicaenApp/Service/Doctrine/MultipleDbAbstractFactory.php index 6d67c287446971f6adf5bbc7d8a9f2f37d269137..8bc2ea02c8eac76a0dfc086dcb4bacf66f15dec1 100644 --- a/src/UnicaenApp/Service/Doctrine/MultipleDbAbstractFactory.php +++ b/src/UnicaenApp/Service/Doctrine/MultipleDbAbstractFactory.php @@ -13,7 +13,7 @@ use DoctrineORMModule\Service\EntityManagerFactory; use DoctrineORMModule\Service\EntityResolverFactory; use DoctrineORMModule\Service\SQLLoggerCollectorFactory; use DoctrineORMModule\Collector\MappingCollector; -use UnicaenApp\Exception; +use UnicaenApp\Exception\LogicException; use Zend\ServiceManager\AbstractFactoryInterface; use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; @@ -176,7 +176,7 @@ class MultipleDbAbstractFactory implements AbstractFactoryInterface $factory = new AuthenticationServiceFactory($serviceName); break; default: - throw new Exception("Type de service imprévu : '$serviceType'."); + throw new LogicException("Type de service imprévu : '$serviceType'."); break; } // "DoctrineORMModule\Form\Annotation\AnnotationBuilder" => function(Zend\Di\ServiceLocatorInterface $sl) { diff --git a/src/UnicaenApp/Util.php b/src/UnicaenApp/Util.php index fea1decf6705283b8112dc54589b9fb066dc9d46..36485a5f35371cc39807bde62dc94751972f4a30 100644 --- a/src/UnicaenApp/Util.php +++ b/src/UnicaenApp/Util.php @@ -1,6 +1,10 @@ <?php + namespace UnicaenApp; +use UnicaenApp\Exception\LogicException; +use UnicaenApp\Exception\RuntimeException; + /** * Regroupe des méthodes statiques utilitaires. * @@ -109,10 +113,10 @@ class Util static public function getObjectAttributeFromPath($object, $path) { if (!is_object($object)) { - throw new Exception("Le premier argument doit être un objet."); + throw new LogicException("Le premier argument doit être un objet."); } if (!is_string($path)) { - throw new Exception("Le deuxième argument doit être une chaîne de caractère (ex: 'poste.no_poste')."); + throw new LogicException("Le deuxième argument doit être une chaîne de caractère (ex: 'poste.no_poste')."); } $value = $object; @@ -129,11 +133,11 @@ class Util $value = $value->$attr(); } else { - throw new Exception( + throw new LogicException( "L'attribut '$attr' spécifié dans le chemin '$path' n'est ni un attribut accessible ni une méthode existante."); } if ((!$value || !is_object($value)) && $index !== count($attributes) - 1) { - throw new Exception( + throw new LogicException( "L'attribut non terminal '$attr' spécifié dans le chemin '$path' retourne une valeur nulle ou un scalaire."); } } @@ -189,21 +193,20 @@ class Util * @param string $source Chemin complet de la source * @param string $destination Chemin complet de l'archive à créer. * @return \ZipArchive - * @throws \InvalidArgumentException - * @throws \RuntimeException + * @throws RuntimeException */ public static function zip($source, $destination) { if (!extension_loaded('zip')) { - throw new \RuntimeException("Extension PHP 'zip' non chargée."); + throw new RuntimeException("Extension PHP 'zip' non chargée."); } if (!file_exists($source)) { - throw new \InvalidArgumentException("Le fichier ou répertoire source spécifié n'existe pas."); + throw new RuntimeException("Le fichier ou répertoire source spécifié n'existe pas."); } $zip = new \ZipArchive(); if (true !== $res = $zip->open($destination, \ZipArchive::CREATE)) { - throw new \RuntimeException("Impossible de créer l'archive '$destination'."); + throw new RuntimeException("Impossible de créer l'archive '$destination'."); } $source = str_replace('\\', '/', realpath($source)); @@ -240,7 +243,7 @@ class Util static public function removeFile($fileOrDirectoryPath) { if (!file_exists($fileOrDirectoryPath)) { - throw new \InvalidArgumentException("Le fichier ou répertoire '$fileOrDirectoryPath' n'existe pas."); + throw new RuntimeException("Le fichier ou répertoire '$fileOrDirectoryPath' n'existe pas."); } if (is_file($fileOrDirectoryPath)) { @@ -253,7 +256,7 @@ class Util $ouverture = @opendir($fileOrDirectoryPath); if (!$ouverture) { - throw new \RuntimeException("Impossible d'ouvrir le répertoire <$fileOrDirectoryPath>."); + throw new RuntimeException("Impossible d'ouvrir le répertoire <$fileOrDirectoryPath>."); } while ($fichier = readdir($ouverture)) { if ($fichier == '.' || $fichier == '..') { diff --git a/src/UnicaenApp/View/Helper/AppInfos.php b/src/UnicaenApp/View/Helper/AppInfos.php index 3447e09d0ae64f65e6e8e1e19a130561bb505889..0d469a9dba167767336f907065577f673d4744f4 100644 --- a/src/UnicaenApp/View/Helper/AppInfos.php +++ b/src/UnicaenApp/View/Helper/AppInfos.php @@ -2,7 +2,7 @@ namespace UnicaenApp\View\Helper; use Traversable; -use UnicaenApp\Exception; +use UnicaenApp\Exception\LogicException; use UnicaenApp\View\Helper\AppInfos; use Zend\Config\Config; use Zend\I18n\View\Helper\AbstractTranslatorHelper; @@ -173,10 +173,10 @@ class AppInfos extends AbstractTranslatorHelper $config = $config->toArray(); } else if (!is_array($config)) { - throw new Exception("La configuration spécifiée est invalide."); + throw new LogicException("La configuration spécifiée est invalide."); } if (!$config) { - throw new Exception("La configuration spécifiée est vide."); + throw new LogicException("La configuration spécifiée est vide."); } $valid = array(); foreach ($config as $key => $value) { diff --git a/src/UnicaenApp/View/Helper/AppLink.php b/src/UnicaenApp/View/Helper/AppLink.php index 9089d3ba79012f9b00c6dcb712ff52c8c8a5bace..3cc7881eacf37e730406482515182ffb47d02197 100644 --- a/src/UnicaenApp/View/Helper/AppLink.php +++ b/src/UnicaenApp/View/Helper/AppLink.php @@ -4,6 +4,7 @@ namespace UnicaenApp\View\Helper; use Zend\I18n\View\Helper\AbstractTranslatorHelper; use Zend\Mvc\Router\RouteMatch; use Zend\Mvc\Router\RouteStackInterface; +use UnicaenApp\Exception\LogicException; /** * Aide de vue dessinant le titre (de niveau 1) de l'application sous forme d'un lien @@ -65,7 +66,7 @@ class AppLink extends AbstractTranslatorHelper protected function render() { if (!$this->title) { - throw new \UnicaenApp\Exception("Aucun titre spécifié."); + throw new LogicException("Aucun titre spécifié."); } $appName = $this->title; diff --git a/src/UnicaenApp/View/Helper/Messenger.php b/src/UnicaenApp/View/Helper/Messenger.php index d4ec33dee64d16ad25a23fcfb21128fa46f184ef..89db5dbdbd0eae6ac0c6d1667fbe1443eea50143 100644 --- a/src/UnicaenApp/View/Helper/Messenger.php +++ b/src/UnicaenApp/View/Helper/Messenger.php @@ -1,7 +1,7 @@ <?php namespace UnicaenApp\View\Helper; -use UnicaenApp\Exception; +use UnicaenApp\Exception\LogicException; use UnicaenApp\View\Helper\Messenger; use Zend\View\Helper\AbstractHelper; @@ -66,8 +66,13 @@ class Messenger extends AbstractHelper */ public function __toString() { - return $this->render(); - } + try { + return $this->render(); + } + catch (\Exception $exc) { + var_dump($exc->getMessage(), $exc->getTraceAsString());die; + } + } /** * Génère le code HTML. @@ -247,7 +252,7 @@ class Messenger extends AbstractHelper public function getTemplate($severity, $containerId = null) { if (!isset($this->uiClasses[$severity])) { - throw new Exception("Sévérité inconnue: " . $severity); + throw new LogicException("Sévérité inconnue: " . $severity); } $innerTemplate = $this->containerInnerTemplate ?: '%s'; diff --git a/src/UnicaenApp/View/Helper/Navigation/MenuContextuel.php b/src/UnicaenApp/View/Helper/Navigation/MenuContextuel.php index 68636fe4557b93f45df9504e581b4688e14f8324..174acce6b097f6e279092175ca0e0e7f3ec6f421 100644 --- a/src/UnicaenApp/View/Helper/Navigation/MenuContextuel.php +++ b/src/UnicaenApp/View/Helper/Navigation/MenuContextuel.php @@ -6,6 +6,7 @@ use Zend\Navigation\AbstractContainer; use Zend\View\Helper\Navigation\Menu; use Zend\Navigation\Navigation; use Zend\Navigation\Page\AbstractPage; +use UnicaenApp\Exception\LogicException; use UnicaenApp\Exception\RuntimeException; /** @@ -418,7 +419,7 @@ class MenuContextuel extends Menu } if (!$criteres) { - throw new RuntimeException ("Aucun critère d'inclusion de pages fourni"); + throw new LogicException ("Aucun critère d'inclusion de pages fourni"); } $this->updated = true; @@ -469,7 +470,7 @@ class MenuContextuel extends Menu } if (!$criteres) { - throw new RuntimeException ("Aucun critère d'exclusion de pages fourni"); + throw new LogicException ("Aucun critère d'exclusion de pages fourni"); } $this->updated = true; diff --git a/tests/Bootstrap.php b/tests/Bootstrap.php index a11a63e174307cecb916b5ef5dd3b1ec90a32160..e29b5770ca2e2073d2a3d48d2d1893648f819bcd 100644 --- a/tests/Bootstrap.php +++ b/tests/Bootstrap.php @@ -18,17 +18,28 @@ class Bootstrap public static function init() { - $zf2ModulePaths = array(dirname(dirname(__DIR__))); + $zf2ModulePaths = array(dirname(__DIR__)); if (($path = static::findParentPath('vendor'))) { $zf2ModulePaths[] = $path; } - if (($path = static::findParentPath('module')) !== $zf2ModulePaths[0]) { - $zf2ModulePaths[] = $path; - } - $zf2ModulePaths[] = __DIR__; static::initAutoloader(); +// // use ModuleManager to load this module and it's dependencies +// $config = array( +// 'module_listener_options' => array( +// 'module_paths' => $zf2ModulePaths, +// ), +// 'modules' => array( +// 'UnicaenApp' +// ) +// ); +// +// $serviceManager = new ServiceManager(new ServiceManagerConfig()); +// $serviceManager->setService('ApplicationConfig', $config); +// $serviceManager->get('ModuleManager')->loadModules(); +// static::$serviceManager = $serviceManager; + static::$serviceManager = new ServiceManager(new ServiceManagerConfig()); } diff --git a/tests/UnicaenAppTest/Entity/Ldap/GroupTest.php b/tests/UnicaenAppTest/Entity/Ldap/GroupTest.php index 1c9ee728d1f7fdafd1d2b50f92ceeb40e47a6b6b..fac14dbea1883d291f7ad852a377c4cdfb827775 100644 --- a/tests/UnicaenAppTest/Entity/Ldap/GroupTest.php +++ b/tests/UnicaenAppTest/Entity/Ldap/GroupTest.php @@ -122,7 +122,7 @@ class GroupTest extends PHPUnit_Framework_TestCase /** * @depends testConstructWithValidData * @dataProvider provideConstructorValidData - * @expectedException \UnicaenApp\Exception + * @expectedException \UnicaenApp\Exception\LogicException */ public function testGettingDataWithNonExistingSpecificKeyThrowsException($data) { diff --git a/tests/UnicaenAppTest/Entity/Ldap/PeopleTest.php b/tests/UnicaenAppTest/Entity/Ldap/PeopleTest.php index 5e69a29bbf61d80640d235c15ce4218e648567c9..1a632fa926ac97fa06f9478a2a80d1688fbd8dd5 100644 --- a/tests/UnicaenAppTest/Entity/Ldap/PeopleTest.php +++ b/tests/UnicaenAppTest/Entity/Ldap/PeopleTest.php @@ -607,7 +607,7 @@ class PeopleTest extends PHPUnit_Framework_TestCase } /** - * @expectedException \UnicaenApp\Exception + * @expectedException \UnicaenApp\Exception\RuntimeException */ public function testGetMemberOfGroupThrowsExceptionWhenNoGroupFound() { @@ -699,7 +699,7 @@ class PeopleTest extends PHPUnit_Framework_TestCase } /** - * @expectedException \UnicaenApp\Exception + * @expectedException \UnicaenApp\Exception\LogicException */ public function testIsMemberOfWithDateButNoMapperSpecifiedThrowsException() { diff --git a/tests/UnicaenAppTest/Exporter/PdfTest.php b/tests/UnicaenAppTest/Exporter/PdfTest.php index f17988c179df307c822f689fcbaa50d7333bc8db..f784efafe5c27f178630657f64a627818b8a7c2a 100644 --- a/tests/UnicaenAppTest/Exporter/PdfTest.php +++ b/tests/UnicaenAppTest/Exporter/PdfTest.php @@ -312,7 +312,7 @@ class PdfTest extends PHPUnit_Framework_TestCase } /** - * @expectedException \UnicaenApp\Exception + * @expectedException \UnicaenApp\Exception\LogicException * @expectedExceptionMessage Aucun script spécifié. */ public function testExportingThrowsExceptionIfNoScriptSpecified() @@ -321,7 +321,7 @@ class PdfTest extends PHPUnit_Framework_TestCase } /** - * @expectedException \UnicaenApp\Exception + * @expectedException \UnicaenApp\Exception\LogicException */ public function testExportingWithoutSpecifyingPdfFilenameThrowsException() { diff --git a/tests/UnicaenAppTest/Form/MultipageFormTest.php b/tests/UnicaenAppTest/Form/MultipageFormTest.php index 15e0c4e5ad3a9b4058eb15030de4cd7d5de0dc3a..f0347486511ac76648ed39c16ef84141b70fd09f 100644 --- a/tests/UnicaenAppTest/Form/MultipageFormTest.php +++ b/tests/UnicaenAppTest/Form/MultipageFormTest.php @@ -2,7 +2,7 @@ namespace UnicaenAppTest\Form; use PHPUnit_Framework_TestCase; -use UnicaenApp\Exception; +use UnicaenApp\Exception\LogicException; use UnicaenApp\Form\MultipageForm; use Zend\Form\Element\Checkbox; use Zend\Form\Element\Select; @@ -41,7 +41,7 @@ class MultipageFormTest extends PHPUnit_Framework_TestCase } /** - * @expectedException Exception + * @expectedException LogicException */ public function testAddingSameFirstFieldsetTwiceThrowsException() { @@ -51,7 +51,7 @@ class MultipageFormTest extends PHPUnit_Framework_TestCase } /** - * @expectedException Exception + * @expectedException LogicException */ public function testAddingSameNextFieldsetAsFirstOneThrowsException() { @@ -75,7 +75,7 @@ class MultipageFormTest extends PHPUnit_Framework_TestCase } /** - * @expectedException Exception + * @expectedException LogicException */ public function testAddingSameNextFieldsetTwiceThrowsException() { @@ -87,7 +87,7 @@ class MultipageFormTest extends PHPUnit_Framework_TestCase } /** - * @expectedException Exception + * @expectedException LogicException */ public function testAddingSameLastFieldsetAsFirstOneThrowsException() { @@ -97,7 +97,7 @@ class MultipageFormTest extends PHPUnit_Framework_TestCase } /** - * @expectedException Exception + * @expectedException LogicException */ public function testAddingSameLastFieldsetAsNextOneThrowsException() { @@ -109,7 +109,7 @@ class MultipageFormTest extends PHPUnit_Framework_TestCase } /** - * @expectedException Exception + * @expectedException LogicException */ public function testAddingSameLastFieldsetTwiceThrowsException() { diff --git a/tests/UnicaenAppTest/Form/View/Helper/FormDateInfSupTest.php b/tests/UnicaenAppTest/Form/View/Helper/FormDateInfSupTest.php index a24a4a857a373395299a26312cdd337fa3cc18d1..752fe27452f0ceb5fe65dc62e611c6b2acc9807b 100644 --- a/tests/UnicaenAppTest/Form/View/Helper/FormDateInfSupTest.php +++ b/tests/UnicaenAppTest/Form/View/Helper/FormDateInfSupTest.php @@ -62,7 +62,7 @@ class FormDateInfSupTest extends PHPUnit_Framework_TestCase } /** - * @expectedException \UnicaenApp\Exception + * @expectedException \UnicaenApp\Exception\LogicException */ public function testGettingJavascriptThrowsExceptionIfNoElementSet() { diff --git a/tests/UnicaenAppTest/Form/View/Helper/FormLdapPeopleTest.php b/tests/UnicaenAppTest/Form/View/Helper/FormLdapPeopleTest.php index 472867cef516c1fcdd63ed3ceb4a890fc9e08b45..5fb0a72e4dd7111bb7237be42732455112fdbf9b 100644 --- a/tests/UnicaenAppTest/Form/View/Helper/FormLdapPeopleTest.php +++ b/tests/UnicaenAppTest/Form/View/Helper/FormLdapPeopleTest.php @@ -117,7 +117,7 @@ class FormLdapPeopleTest extends PHPUnit_Framework_TestCase } /** - * @expectedException \UnicaenApp\Exception + * @expectedException \UnicaenApp\Exception\LogicException */ public function testGettingJavascriptThrowsExceptionIfNoElementSet() { diff --git a/tests/UnicaenAppTest/Mapper/Ldap/AbstractMapperTest.php b/tests/UnicaenAppTest/Mapper/Ldap/AbstractMapperTest.php index 4d5b8749af6ca09f8cc81f97f15aa4fef7fb0372..3a2ab9216f5b6e35017211916d12f0b2acb25ecd 100644 --- a/tests/UnicaenAppTest/Mapper/Ldap/AbstractMapperTest.php +++ b/tests/UnicaenAppTest/Mapper/Ldap/AbstractMapperTest.php @@ -131,7 +131,7 @@ class AbstractMapperTest extends CommonTest } /** - * @expectedException \UnicaenApp\Exception + * @expectedException \UnicaenApp\Exception\RuntimeException * @expectedExceptionMessage Plus d'une entrée trouvée */ public function testSearchSimplifiedEntryThrowsExceptionWhenMoreThanOneEntryFound() diff --git a/tests/UnicaenAppTest/Mapper/Ldap/GroupTest.php b/tests/UnicaenAppTest/Mapper/Ldap/GroupTest.php index a80f4017b4c0dd4f5fc949d7b62cf22363aa77c2..0e1fcf61762eb0f8e7ee6b68153adf5f122efa45 100644 --- a/tests/UnicaenAppTest/Mapper/Ldap/GroupTest.php +++ b/tests/UnicaenAppTest/Mapper/Ldap/GroupTest.php @@ -148,7 +148,7 @@ class GroupTest extends CommonTest } /** - * @expectedException \UnicaenApp\Exception + * @expectedException \UnicaenApp\Exception\LogicException */ public function testFilterGroupsByEndDateWithNoMapperSpecifiedThrowsException() { @@ -157,7 +157,7 @@ class GroupTest extends CommonTest } /** - * @expectedException \UnicaenApp\Exception + * @expectedException \UnicaenApp\Exception\RuntimeException */ public function testFilterGroupsByEndDateThrowsExceptionIfGroupNotFound() { diff --git a/tests/UnicaenAppTest/Service/Doctrine/MultipleDbAbstractFactoryTest.php b/tests/UnicaenAppTest/Service/Doctrine/MultipleDbAbstractFactoryTest.php index 744e7c1582aae06fd42d0eb6a19bb5f45891a774..daac47d5c9e0550a559d3ade86457ce5e72c3b6c 100644 --- a/tests/UnicaenAppTest/Service/Doctrine/MultipleDbAbstractFactoryTest.php +++ b/tests/UnicaenAppTest/Service/Doctrine/MultipleDbAbstractFactoryTest.php @@ -120,7 +120,7 @@ class MultipleDbAbstractFactoryTest extends PHPUnit_Framework_TestCase } /** - * @expectedException \UnicaenApp\Exception + * @expectedException \UnicaenApp\Exception\LogicException */ public function testCreateServiceWithNameThrowsExceptionIfUnknownServiceTypeSpecified() { diff --git a/tests/UnicaenAppTest/UtilTest.php b/tests/UnicaenAppTest/UtilTest.php index b76850120425bd501f7754d3a9cf32cb01ee1621..f2a894f9f92876f9692d83e327a2a493fb066a67 100644 --- a/tests/UnicaenAppTest/UtilTest.php +++ b/tests/UnicaenAppTest/UtilTest.php @@ -217,7 +217,7 @@ class UtilTest extends PHPUnit_Framework_TestCase } /** - * @expectedException \UnicaenApp\Exception + * @expectedException \UnicaenApp\Exception\LogicException */ public function testGetObjectAttributeFromPathThrowsExceptionIfInvalidObjectSpecified() { @@ -225,7 +225,7 @@ class UtilTest extends PHPUnit_Framework_TestCase } /** - * @expectedException \UnicaenApp\Exception + * @expectedException \UnicaenApp\Exception\LogicException */ public function testGetObjectAttributeFromPathThrowsExceptionIfInvalidPathSpecified() { @@ -307,7 +307,7 @@ class UtilTest extends PHPUnit_Framework_TestCase /** * @dataProvider getInvalidObjectPath - * @expectedException \UnicaenApp\Exception + * @expectedException \UnicaenApp\Exception\LogicException * @param mixed $object * @param string $path */ @@ -359,7 +359,7 @@ class UtilTest extends PHPUnit_Framework_TestCase } /** - * @expectedException \InvalidArgumentException + * @expectedException \UnicaenApp\Exception\RuntimeException */ public function testRemoveFileThrowsExceptionIfFileDoesNotExist() { @@ -388,7 +388,7 @@ class UtilTest extends PHPUnit_Framework_TestCase } /** - * @expectedException \RuntimeException + * @expectedException \UnicaenApp\Exception\RuntimeException */ public function testRemoveDirectoryThrowsExceptionIfCannotOpenDirectory() { @@ -426,7 +426,7 @@ class UtilTest extends PHPUnit_Framework_TestCase } /** - * @expectedException \RuntimeException + * @expectedException \UnicaenApp\Exception\RuntimeException */ public function testZipThrowsExceptionIfZipExtensionIsNotLoaded() { @@ -435,7 +435,7 @@ class UtilTest extends PHPUnit_Framework_TestCase } /** - * @expectedException \InvalidArgumentException + * @expectedException \UnicaenApp\Exception\RuntimeException */ public function testZipThrowsExceptionIfSourceDosNotExist() { @@ -443,7 +443,7 @@ class UtilTest extends PHPUnit_Framework_TestCase } /** - * @expectedException \RuntimeException + * @expectedException \UnicaenApp\Exception\RuntimeException */ public function testZipThrowsExceptionIfDestinationCreationFails() { diff --git a/tests/UnicaenAppTest/View/Helper/AppInfosTest.php b/tests/UnicaenAppTest/View/Helper/AppInfosTest.php index 99214c0bc68b9b4215d9cde7364f8538577ab64f..20662086189fff07d4f0c552a985a7e54d29e714 100644 --- a/tests/UnicaenAppTest/View/Helper/AppInfosTest.php +++ b/tests/UnicaenAppTest/View/Helper/AppInfosTest.php @@ -2,7 +2,7 @@ namespace UnicaenAppTest\View\Helper; use stdClass; -use UnicaenApp\Exception; +use UnicaenApp\Exception\LogicException; use UnicaenApp\View\Helper\AppInfos; use Zend\Config\Config; use Zend\I18n\Translator\Translator; @@ -102,7 +102,7 @@ class AppInfosTest extends AbstractTest /** * @dataProvider getInvalidConfig - * @expectedException Exception + * @expectedException LogicException * @expectedExceptionMessage invalide */ public function testThrowsExceptionWhenSettingInvalidConfig($config) @@ -120,7 +120,7 @@ class AppInfosTest extends AbstractTest /** * @dataProvider getEmptyConfig - * @expectedException Exception + * @expectedException LogicException * @expectedExceptionMessage vide */ public function testThrowsExceptionWhenSettingEmptyConfig($config) diff --git a/tests/UnicaenAppTest/View/Helper/AppLinkTest.php b/tests/UnicaenAppTest/View/Helper/AppLinkTest.php index 1846d32ff8f57de31c6882d467619b373e7a1143..ebf6c6c50f0ec336747e5aba00d116efc1d17631 100644 --- a/tests/UnicaenAppTest/View/Helper/AppLinkTest.php +++ b/tests/UnicaenAppTest/View/Helper/AppLinkTest.php @@ -33,7 +33,7 @@ class AppLinkText extends AbstractTest } /** - * @expectedException \UnicaenApp\Exception + * @expectedException \UnicaenApp\Exception\LogicException */ public function testThrowsExceptionIfNoTitleSpecified() { diff --git a/tests/UnicaenAppTest/View/Helper/MessengerTest.php b/tests/UnicaenAppTest/View/Helper/MessengerTest.php index 312e0965ee4a31f01e95f79e49d368be1ad5e4db..a2a707302288de362a004dd99c95da2686591086 100644 --- a/tests/UnicaenAppTest/View/Helper/MessengerTest.php +++ b/tests/UnicaenAppTest/View/Helper/MessengerTest.php @@ -41,18 +41,18 @@ class MessengerText extends AbstractTest 'messages' => array( 'info' => $info, 'success' => $success, - 'error' => $error), + 'danger' => $error), 'expected' => array( 'info' => array($info), 'success' => array($success), - 'error' => array($error)), + 'danger' => array($error)), ), array( 'severity' => null, 'messages' => $messages = array( 'info' => array($info, $info . ' n°2'), 'success' => array($success), - 'error' => array($error)), + 'danger' => array($error)), 'expected' => $messages, ), array( @@ -81,8 +81,8 @@ class MessengerText extends AbstractTest 'expected' => array($success), ), array( - 'severity' => 'error', - 'messages' => array('error' => $error), + 'severity' => 'danger', + 'messages' => array('danger' => $error), 'expected' => array($error), ), ); @@ -102,7 +102,7 @@ class MessengerText extends AbstractTest { $this->helper->setMessages(array( 'info' => "Information message.", - 'error' => "Error message.")); + 'danger' => "Error message.")); $this->helper->setMessage(array('info' => $message = "Unique information message.")); $this->assertEquals(array('info' => array($message)), $this->helper->getMessages()); @@ -112,20 +112,20 @@ class MessengerText extends AbstractTest { $this->helper->setMessages(array( 'info' => "Information message.", - 'error' => "Error message.")); + 'danger' => "Error message.")); $this->helper->addMessage("Success message.", 'success'); $expected = array( 'info' => array("Information message."), 'success' => array("Success message."), - 'error' => array("Error message.")); + 'danger' => array("Error message.")); $this->assertEquals($expected, $this->helper->getMessages()); $this->helper->addMessage("Another information message."); $expected = array( 'info' => array("Information message.", "Another information message."), 'success' => array("Success message."), - 'error' => array("Error message.")); + 'danger' => array("Error message.")); $this->assertEquals($expected, $this->helper->getMessages()); } @@ -134,13 +134,13 @@ class MessengerText extends AbstractTest $this->helper->setMessages(array( 'info' => "Information message.", 'success' => "Success message.", - 'error' => "Error message.")); + 'danger' => "Error message.")); $this->helper->clearMessages('info'); $expected = array( 'info' => array(), 'success' => array("Success message."), - 'error' => array("Error message.")); + 'danger' => array("Error message.")); $this->assertEquals($expected, $this->helper->getMessages()); $this->helper->clearMessages(); @@ -165,13 +165,13 @@ class MessengerText extends AbstractTest $this->helper->setMessages(array( 'info' => "Information message.", 'success' => "Success message.", - 'error' => "Error message.")); + 'danger' => "Error message.")); $this->helper->__invoke(true); $expected = array( 'info' => array("Information message.", "Information message from FlashMessenger."), 'success' => array("Success message.", "Success message from FlashMessenger."), - 'error' => array("Error message.", "Error message from FlashMessenger.")); + 'danger' => array("Error message.", "Error message from FlashMessenger.")); $this->assertEquals($expected, $this->helper->getMessages()); } @@ -189,14 +189,14 @@ class MessengerText extends AbstractTest ), 'two-errors' => array( array( - 'error' => array("Error message.", "Another error message.")), + 'danger' => array("Error message.", "Another error message.")), 'messenger/two-errors.phtml' ), 'all' => array( array( 'info' => "Information message.", 'success' => "Success message.", - 'error' => "Error message."), + 'danger' => "Error message."), 'messenger/all.phtml' ), ); @@ -213,7 +213,7 @@ class MessengerText extends AbstractTest } /** - * @expectedException \UnicaenApp\Exception + * @expectedException \UnicaenApp\Exception\LogicException */ public function testGettingTemplateForUnknownSeverityThrowsException() { diff --git a/tests/UnicaenAppTest/View/Helper/Navigation/MenuContextuelTest.php b/tests/UnicaenAppTest/View/Helper/Navigation/MenuContextuelTest.php index 9e491a7f8f1c29ce18a9d143c8700b964b8c8181..0dc679bca96ae746023ad5afbbf39de4cc55d090 100644 --- a/tests/UnicaenAppTest/View/Helper/Navigation/MenuContextuelTest.php +++ b/tests/UnicaenAppTest/View/Helper/Navigation/MenuContextuelTest.php @@ -67,7 +67,7 @@ class MenuContextuelTest extends AbstractTest /** * @dataProvider getIncludeOrExcudeMethod - * @expectedException \UnicaenApp\Exception\RuntimeException + * @expectedException \UnicaenApp\Exception\LogicException * @param string $method * @param boolean $condition */