Commit 6146bc13cbdcab8e489562cb96ea8b68cdbe79e4
1 parent
c630247a
Exists in
master
and in
2 other branches
IMPORTANTE MISE A JOUR
- LDAP authentified bugfix - Recherche Matériels : Bugfixes et améliorations - Bugfix Recherche générale sur plusieurs mots : fait un AND de ces mots et non pas un OR !!! - Bugfix Recherche générale d'une date - Ajout recherche générale d'une catégorie - Bugfix recherche sur un montant à virgule... - Complète refactorisation de MaterielsController::find(), y avait besoin ! - Ajout de tests - ... - Adaptations pour cakephp 3.7
Showing
13 changed files
with
655 additions
and
134 deletions
Show diff stats
README.md
... | ... | @@ -53,17 +53,21 @@ Logiciel testé et validé sur les configurations suivantes : |
53 | 53 | |
54 | 54 | VERSION ACTUELLE |
55 | 55 | |
56 | -Date: 21/01/2019 | |
57 | -Version: 2.10.2 | |
56 | +Date: 22/01/2019 | |
57 | +Version: 2.10.3 | |
58 | 58 | Author: EP |
59 | - Mise à jour framework cakephp et amélioration recherche matériel: | |
60 | - - Mise à jour du framework cakephp à la version courante : passage de v3.5 à v3.7 | |
61 | - ($ php composer.phar require --update-with-dependencies "cakephp/cakephp:3.7.*") | |
62 | - - Bugfixes et améliorations recherche matériel : | |
63 | - - ajout du fournisseur dans la recherche globale | |
64 | - - bugfix désignation (si elle contient plusieurs mots) | |
65 | - - refactorisation et optimisation du code (bcp plus court...) | |
59 | + IMPORTANTE MISE A JOUR | |
60 | + - Recherche Matériels : Bugfixes et améliorations | |
61 | + - Bugfix Recherche générale sur plusieurs mots : fait un AND de ces mots et non pas un OR !!! | |
62 | + - Bugfix Recherche générale d'une date | |
63 | + - Ajout recherche générale d'une catégorie | |
64 | + - Bugfix recherche sur un montant à virgule... | |
65 | + - Complète refactorisation de MaterielsController::find(), y avait besoin ! | |
66 | + - Ajout de tests | |
66 | 67 | - ... |
68 | + - LDAP authentified bugfix | |
69 | + - Adaptations pour cakephp 3.7 | |
70 | + | |
67 | 71 | |
68 | 72 | Version majeure en cours : 2.10 (https://projects.irap.omp.eu/versions/207) |
69 | 73 | |
... | ... | @@ -84,16 +88,21 @@ CHANGEMENTS IMPORTANTS (MILESTONES) |
84 | 88 | Liste complète des évolutions: https://gitlab.irap.omp.eu/epallier/labinvent/commits/master |
85 | 89 | |
86 | 90 | ----------------------------------------------------------------------------------------------------------- |
87 | -17/01/2019 Version: 2.10.1 (EP) | |
88 | - Mise à jour framework cakephp et amélioration recherche matériel: | |
91 | +17/01/2019 Version: 2.10.1, 2, et 3 (EP) | |
92 | + Mise à jour framework cakephp et amélioration recherche matériel et bugfix ldap: | |
89 | 93 | - Mise à jour du framework cakephp à la version courante : passage de v3.5 à v3.7 |
90 | 94 | ($ php composer.phar require --update-with-dependencies "cakephp/cakephp:3.7.*") |
91 | - - Bugfixes et améliorations recherche matériel : | |
92 | - - ajout du fournisseur dans la recherche globale | |
93 | - - bugfix désignation (si elle contient plusieurs mots) | |
94 | - - optimisation du code (bcp plus court...) | |
95 | + - Adaptations pour cakephp 3.7 | |
96 | + - Recherche Matériels : Bugfixes et améliorations | |
97 | + - Bugfix Recherche générale sur plusieurs mots : fait un AND de ces mots et non pas un OR !!! | |
98 | + - Bugfix Recherche générale d'une date | |
99 | + - Ajout recherche générale d'une catégorie | |
100 | + - Bugfix recherche sur un montant à virgule... | |
101 | + - Complète refactorisation de MaterielsController::find(), y avait besoin ! | |
102 | + - Ajout de tests | |
95 | 103 | - ... |
96 | - | |
104 | + - LDAP authentified bugfix | |
105 | + | |
97 | 106 | 15/01/2019 Version: 2.9.2 (EP) |
98 | 107 | Nouveau script "install/update.sh" pour mettre à jour automatiquement le logiciel (git pull) ET la BD (si besoin) |
99 | 108 | ... | ... |
TESTS.sh
... | ... | @@ -2,6 +2,10 @@ |
2 | 2 | sudo chmod o+w tmp/cache/persistent/myapp_cake_core_translations_* |
3 | 3 | |
4 | 4 | vendor/bin/phpunit |
5 | +# Plus de details: | |
6 | +#vendor/bin/phpunit --debug | |
7 | +#vendor/bin/phpunit --verbose --log-tap tap.log | |
8 | +#vendor/bin/phpunit --testdox | |
5 | 9 | |
6 | 10 | # Si ca ne marche pas, essayer plutot: |
7 | 11 | #vendor/phpunit/phpunit/phpunit | ... | ... |
config/bootstrap.php
... | ... | @@ -59,7 +59,14 @@ use Cake\Datasource\ConnectionManager; |
59 | 59 | use Cake\Error\ErrorHandler; |
60 | 60 | use Cake\Log\Log; |
61 | 61 | use Cake\Mailer\Email; |
62 | -use Cake\Network\Request; | |
62 | + | |
63 | +//(EP added) | |
64 | +use Cake\Mailer\TransportFactory; | |
65 | + | |
66 | +//(EP) | |
67 | +//use Cake\Network\Request; | |
68 | +use Cake\Http\ServerRequest; | |
69 | + | |
63 | 70 | use Cake\Routing\DispatcherFactory; |
64 | 71 | use Cake\Utility\Inflector; |
65 | 72 | use Cake\Utility\Security; |
... | ... | @@ -143,17 +150,24 @@ if (!Configure::read('App.fullBaseUrl')) { |
143 | 150 | unset($httpHost, $s); |
144 | 151 | } |
145 | 152 | |
146 | -//EP 16/1/19 for 3.6 | |
153 | +//(EP) 16/1/19 for 3.7 | |
154 | + | |
147 | 155 | //Cache::config(Configure::consume('Cache')); |
148 | 156 | Cache::setConfig(Configure::consume('Cache')); |
157 | + | |
149 | 158 | //ConnectionManager::config(Configure::consume('Datasources')); |
150 | 159 | ConnectionManager::setConfig(Configure::consume('Datasources')); |
160 | + | |
151 | 161 | //Email::configTransport(Configure::consume('EmailTransport')); |
152 | -Email::setConfigTransport(Configure::consume('EmailTransport')); | |
162 | +//Email::setConfigTransport(Configure::consume('EmailTransport')); | |
163 | +TransportFactory::setConfig(Configure::consume('EmailTransport')); | |
164 | + | |
153 | 165 | //Email::config(Configure::consume('Email')); |
154 | 166 | Email::setConfig(Configure::consume('Email')); |
167 | + | |
155 | 168 | //Log::config(Configure::consume('Log')); |
156 | 169 | Log::setConfig(Configure::consume('Log')); |
170 | + | |
157 | 171 | //Security::salt(Configure::consume('Security.salt')); |
158 | 172 | Security::setSalt(Configure::consume('Security.salt')); |
159 | 173 | |
... | ... | @@ -167,11 +181,15 @@ Security::setSalt(Configure::consume('Security.salt')); |
167 | 181 | /** |
168 | 182 | * Setup detectors for mobile and tablet. |
169 | 183 | */ |
170 | -Request::addDetector('mobile', function ($request) { | |
184 | +//(EP) | |
185 | +//Request::addDetector('mobile', function ($request) { | |
186 | +ServerRequest::addDetector('mobile', function ($request) { | |
171 | 187 | $detector = new \Detection\MobileDetect(); |
172 | 188 | return $detector->isMobile(); |
173 | 189 | }); |
174 | -Request::addDetector('tablet', function ($request) { | |
190 | +//(EP) | |
191 | +//Request::addDetector('tablet', function ($request) { | |
192 | +ServerRequest::addDetector('tablet', function ($request) { | |
175 | 193 | $detector = new \Detection\MobileDetect(); |
176 | 194 | return $detector->isTablet(); |
177 | 195 | }); |
... | ... | @@ -197,14 +215,19 @@ Request::addDetector('tablet', function ($request) { |
197 | 215 | * |
198 | 216 | */ |
199 | 217 | |
218 | +/* (EP) | |
219 | + * TODO: | |
220 | + * Depuis cakephp3.7 les plugins sont à mettre dans src/Application.php | |
221 | + * cf https://book.cakephp.org/3.0/en/migrations.html | |
222 | + */ | |
200 | 223 | Plugin::load('Migrations'); |
201 | - | |
202 | 224 | // Only try to load DebugKit in development mode |
203 | 225 | // Debug Kit should not be installed on a production system |
204 | 226 | if (Configure::read('debug')) { |
205 | 227 | Plugin::load('DebugKit', ['bootstrap' => true]); |
206 | 228 | } |
207 | 229 | |
230 | + | |
208 | 231 | /** |
209 | 232 | * Connect middleware/dispatcher filters. |
210 | 233 | */ | ... | ... |
... | ... | @@ -0,0 +1,206 @@ |
1 | +<?php | |
2 | +/** | |
3 | + * CakePHP(tm) : Rapid Development Framework (https://cakephp.org) | |
4 | + * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org) | |
5 | + * | |
6 | + * Licensed under The MIT License | |
7 | + * For full copyright and license information, please see the LICENSE.txt | |
8 | + * Redistributions of files must retain the above copyright notice. | |
9 | + * | |
10 | + * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org) | |
11 | + * @link https://cakephp.org CakePHP(tm) Project | |
12 | + * @since 0.10.8 | |
13 | + * @license https://opensource.org/licenses/mit-license.php MIT License | |
14 | + */ | |
15 | + | |
16 | +/* | |
17 | + * Configure paths required to find CakePHP + general filepath constants | |
18 | + */ | |
19 | +require __DIR__ . '/paths.php'; | |
20 | + | |
21 | +// Use composer to load the autoloader. | |
22 | +require ROOT . DS . 'vendor' . DS . 'autoload.php'; | |
23 | + | |
24 | +/* | |
25 | + * Bootstrap CakePHP. | |
26 | + * | |
27 | + * Does the various bits of setup that CakePHP needs to do. | |
28 | + * This includes: | |
29 | + * | |
30 | + * - Registering the CakePHP autoloader. | |
31 | + * - Setting the default application paths. | |
32 | + */ | |
33 | +require CORE_PATH . 'config' . DS . 'bootstrap.php'; | |
34 | + | |
35 | +use Cake\Cache\Cache; | |
36 | +use Cake\Console\ConsoleErrorHandler; | |
37 | +use Cake\Core\Configure; | |
38 | +use Cake\Core\Configure\Engine\PhpConfig; | |
39 | +use Cake\Core\Plugin; | |
40 | +use Cake\Database\Type; | |
41 | +use Cake\Datasource\ConnectionManager; | |
42 | +use Cake\Error\ErrorHandler; | |
43 | +use Cake\Http\ServerRequest; | |
44 | +use Cake\Log\Log; | |
45 | +use Cake\Mailer\Email; | |
46 | +use Cake\Mailer\TransportFactory; | |
47 | +use Cake\Utility\Inflector; | |
48 | +use Cake\Utility\Security; | |
49 | + | |
50 | +/** | |
51 | + * Uncomment block of code below if you want to use `.env` file during development. | |
52 | + * You should copy `config/.env.default to `config/.env` and set/modify the | |
53 | + * variables as required. | |
54 | + * | |
55 | + * It is HIGHLY discouraged to use a .env file in production, due to security risks | |
56 | + * and decreased performance on each request. The purpose of the .env file is to emulate | |
57 | + * the presence of the environment variables like they would be present in production. | |
58 | + */ | |
59 | +// if (!env('APP_NAME') && file_exists(CONFIG . '.env')) { | |
60 | +// $dotenv = new \josegonzalez\Dotenv\Loader([CONFIG . '.env']); | |
61 | +// $dotenv->parse() | |
62 | +// ->putenv() | |
63 | +// ->toEnv() | |
64 | +// ->toServer(); | |
65 | +// } | |
66 | + | |
67 | +/* | |
68 | + * Read configuration file and inject configuration into various | |
69 | + * CakePHP classes. | |
70 | + * | |
71 | + * By default there is only one configuration file. It is often a good | |
72 | + * idea to create multiple configuration files, and separate the configuration | |
73 | + * that changes from configuration that does not. This makes deployment simpler. | |
74 | + */ | |
75 | +try { | |
76 | + Configure::config('default', new PhpConfig()); | |
77 | + Configure::load('app', 'default', false); | |
78 | +} catch (\Exception $e) { | |
79 | + exit($e->getMessage() . "\n"); | |
80 | +} | |
81 | + | |
82 | +/* | |
83 | + * Load an environment local configuration file. | |
84 | + * You can use a file like app_local.php to provide local overrides to your | |
85 | + * shared configuration. | |
86 | + */ | |
87 | +//Configure::load('app_local', 'default'); | |
88 | + | |
89 | +/* | |
90 | + * When debug = true the metadata cache should only last | |
91 | + * for a short time. | |
92 | + */ | |
93 | +if (Configure::read('debug')) { | |
94 | + Configure::write('Cache._cake_model_.duration', '+2 minutes'); | |
95 | + Configure::write('Cache._cake_core_.duration', '+2 minutes'); | |
96 | + // disable router cache during development | |
97 | + Configure::write('Cache._cake_routes_.duration', '+2 seconds'); | |
98 | +} | |
99 | + | |
100 | +/* | |
101 | + * Set the default server timezone. Using UTC makes time calculations / conversions easier. | |
102 | + * Check http://php.net/manual/en/timezones.php for list of valid timezone strings. | |
103 | + */ | |
104 | +date_default_timezone_set(Configure::read('App.defaultTimezone')); | |
105 | + | |
106 | +/* | |
107 | + * Configure the mbstring extension to use the correct encoding. | |
108 | + */ | |
109 | +mb_internal_encoding(Configure::read('App.encoding')); | |
110 | + | |
111 | +/* | |
112 | + * Set the default locale. This controls how dates, number and currency is | |
113 | + * formatted and sets the default language to use for translations. | |
114 | + */ | |
115 | +ini_set('intl.default_locale', Configure::read('App.defaultLocale')); | |
116 | + | |
117 | +/* | |
118 | + * Register application error and exception handlers. | |
119 | + */ | |
120 | +$isCli = PHP_SAPI === 'cli'; | |
121 | +if ($isCli) { | |
122 | + (new ConsoleErrorHandler(Configure::read('Error')))->register(); | |
123 | +} else { | |
124 | + (new ErrorHandler(Configure::read('Error')))->register(); | |
125 | +} | |
126 | + | |
127 | +/* | |
128 | + * Include the CLI bootstrap overrides. | |
129 | + */ | |
130 | +if ($isCli) { | |
131 | + require __DIR__ . '/bootstrap_cli.php'; | |
132 | +} | |
133 | + | |
134 | +/* | |
135 | + * Set the full base URL. | |
136 | + * This URL is used as the base of all absolute links. | |
137 | + * | |
138 | + * If you define fullBaseUrl in your config file you can remove this. | |
139 | + */ | |
140 | +if (!Configure::read('App.fullBaseUrl')) { | |
141 | + $s = null; | |
142 | + if (env('HTTPS')) { | |
143 | + $s = 's'; | |
144 | + } | |
145 | + | |
146 | + $httpHost = env('HTTP_HOST'); | |
147 | + if (isset($httpHost)) { | |
148 | + Configure::write('App.fullBaseUrl', 'http' . $s . '://' . $httpHost); | |
149 | + } | |
150 | + unset($httpHost, $s); | |
151 | +} | |
152 | + | |
153 | +Cache::setConfig(Configure::consume('Cache')); | |
154 | +ConnectionManager::setConfig(Configure::consume('Datasources')); | |
155 | +TransportFactory::setConfig(Configure::consume('EmailTransport')); | |
156 | +Email::setConfig(Configure::consume('Email')); | |
157 | +Log::setConfig(Configure::consume('Log')); | |
158 | +Security::setSalt(Configure::consume('Security.salt')); | |
159 | + | |
160 | +/* | |
161 | + * The default crypto extension in 3.0 is OpenSSL. | |
162 | + * If you are migrating from 2.x uncomment this code to | |
163 | + * use a more compatible Mcrypt based implementation | |
164 | + */ | |
165 | +//Security::engine(new \Cake\Utility\Crypto\Mcrypt()); | |
166 | + | |
167 | +/* | |
168 | + * Setup detectors for mobile and tablet. | |
169 | + */ | |
170 | +ServerRequest::addDetector('mobile', function ($request) { | |
171 | + $detector = new \Detection\MobileDetect(); | |
172 | + | |
173 | + return $detector->isMobile(); | |
174 | +}); | |
175 | +ServerRequest::addDetector('tablet', function ($request) { | |
176 | + $detector = new \Detection\MobileDetect(); | |
177 | + | |
178 | + return $detector->isTablet(); | |
179 | +}); | |
180 | + | |
181 | +/* | |
182 | + * Enable immutable time objects in the ORM. | |
183 | + * | |
184 | + * You can enable default locale format parsing by adding calls | |
185 | + * to `useLocaleParser()`. This enables the automatic conversion of | |
186 | + * locale specific date formats. For details see | |
187 | + * @link https://book.cakephp.org/3.0/en/core-libraries/internationalization-and-localization.html#parsing-localized-datetime-data | |
188 | + */ | |
189 | +Type::build('time') | |
190 | + ->useImmutable(); | |
191 | +Type::build('date') | |
192 | + ->useImmutable(); | |
193 | +Type::build('datetime') | |
194 | + ->useImmutable(); | |
195 | +Type::build('timestamp') | |
196 | + ->useImmutable(); | |
197 | + | |
198 | +/* | |
199 | + * Custom Inflector rules, can be set to correctly pluralize or singularize | |
200 | + * table, model, controller names or whatever other string is passed to the | |
201 | + * inflection functions. | |
202 | + */ | |
203 | +//Inflector::rules('plural', ['/^(inflect)or$/i' => '\1ables']); | |
204 | +//Inflector::rules('irregular', ['red' => 'redlings']); | |
205 | +//Inflector::rules('uninflected', ['dontinflectme']); | |
206 | +//Inflector::rules('transliteration', ['/å/' => 'aa']); | ... | ... |
... | ... | @@ -0,0 +1,28 @@ |
1 | +<?php | |
2 | +/** | |
3 | + * CakePHP(tm) : Rapid Development Framework (https://cakephp.org) | |
4 | + * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org) | |
5 | + * | |
6 | + * Licensed under The MIT License | |
7 | + * For full copyright and license information, please see the LICENSE.txt | |
8 | + * Redistributions of files must retain the above copyright notice. | |
9 | + * | |
10 | + * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org) | |
11 | + * @link https://cakephp.org CakePHP(tm) Project | |
12 | + * @since 3.0.0 | |
13 | + * @license https://opensource.org/licenses/mit-license.php MIT License | |
14 | + */ | |
15 | +use Cake\Core\Configure; | |
16 | + | |
17 | +/** | |
18 | + * Additional bootstrapping and configuration for CLI environments should | |
19 | + * be put here. | |
20 | + */ | |
21 | + | |
22 | +// Set the fullBaseUrl to allow URLs to be generated in shell tasks. | |
23 | +// This is useful when sending email from shells. | |
24 | +//Configure::write('App.fullBaseUrl', php_uname('n')); | |
25 | + | |
26 | +// Set logs to different files so they don't have permission conflicts. | |
27 | +Configure::write('Log.debug.file', 'cli-debug'); | |
28 | +Configure::write('Log.error.file', 'cli-error'); | ... | ... |
... | ... | @@ -0,0 +1,39 @@ |
1 | +<?php | |
2 | +/** | |
3 | + * CakePHP(tm) : Rapid Development Framework (https://cakephp.org) | |
4 | + * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org) | |
5 | + * | |
6 | + * Licensed under The MIT License | |
7 | + * For full copyright and license information, please see the LICENSE.txt | |
8 | + * Redistributions of files must retain the above copyright notice. | |
9 | + * | |
10 | + * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org) | |
11 | + * @link https://cakephp.org CakePHP(tm) Project | |
12 | + * @since 3.5.0 | |
13 | + * @license https://opensource.org/licenses/mit-license.php MIT License | |
14 | + */ | |
15 | + | |
16 | +/* | |
17 | + * You can empty out this file, if you are certain that you match all requirements. | |
18 | + */ | |
19 | + | |
20 | +/* | |
21 | + * You can remove this if you are confident that your PHP version is sufficient. | |
22 | + */ | |
23 | +if (version_compare(PHP_VERSION, '5.6.0') < 0) { | |
24 | + trigger_error('Your PHP version must be equal or higher than 5.6.0 to use CakePHP.' . PHP_EOL, E_USER_ERROR); | |
25 | +} | |
26 | + | |
27 | +/* | |
28 | + * You can remove this if you are confident you have intl installed. | |
29 | + */ | |
30 | +if (!extension_loaded('intl')) { | |
31 | + trigger_error('You must enable the intl extension to use CakePHP.' . PHP_EOL, E_USER_ERROR); | |
32 | +} | |
33 | + | |
34 | +/* | |
35 | + * You can remove this if you are confident you have mbstring installed. | |
36 | + */ | |
37 | +if (!extension_loaded('mbstring')) { | |
38 | + trigger_error('You must enable the mbstring extension to use CakePHP.' . PHP_EOL, E_USER_ERROR); | |
39 | +} | ... | ... |
... | ... | @@ -0,0 +1,86 @@ |
1 | +<?php | |
2 | +/** | |
3 | + * CakePHP(tm) : Rapid Development Framework (https://cakephp.org) | |
4 | + * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org) | |
5 | + * | |
6 | + * Licensed under The MIT License | |
7 | + * For full copyright and license information, please see the LICENSE.txt | |
8 | + * Redistributions of files must retain the above copyright notice. | |
9 | + * | |
10 | + * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org) | |
11 | + * @link https://cakephp.org CakePHP(tm) Project | |
12 | + * @since 3.3.0 | |
13 | + * @license https://opensource.org/licenses/mit-license.php MIT License | |
14 | + */ | |
15 | +namespace App; | |
16 | + | |
17 | +use Cake\Core\Configure; | |
18 | +use Cake\Core\Exception\MissingPluginException; | |
19 | +use Cake\Error\Middleware\ErrorHandlerMiddleware; | |
20 | +use Cake\Http\BaseApplication; | |
21 | +use Cake\Routing\Middleware\AssetMiddleware; | |
22 | +use Cake\Routing\Middleware\RoutingMiddleware; | |
23 | + | |
24 | +/** | |
25 | + * Application setup class. | |
26 | + * | |
27 | + * This defines the bootstrapping logic and middleware layers you | |
28 | + * want to use in your application. | |
29 | + */ | |
30 | +class Application extends BaseApplication | |
31 | +{ | |
32 | + /** | |
33 | + * {@inheritDoc} | |
34 | + */ | |
35 | + public function bootstrap() | |
36 | + { | |
37 | + // Call parent to load bootstrap from files. | |
38 | + parent::bootstrap(); | |
39 | + | |
40 | + if (PHP_SAPI === 'cli') { | |
41 | + try { | |
42 | + $this->addPlugin('Bake'); | |
43 | + } catch (MissingPluginException $e) { | |
44 | + // Do not halt if the plugin is missing | |
45 | + } | |
46 | + | |
47 | + $this->addPlugin('Migrations'); | |
48 | + } | |
49 | + | |
50 | + /* | |
51 | + * Only try to load DebugKit in development mode | |
52 | + * Debug Kit should not be installed on a production system | |
53 | + */ | |
54 | + if (Configure::read('debug')) { | |
55 | + $this->addPlugin(\DebugKit\Plugin::class); | |
56 | + } | |
57 | + | |
58 | + } | |
59 | + | |
60 | + /** | |
61 | + * Setup the middleware queue your application will use. | |
62 | + * | |
63 | + * @param \Cake\Http\MiddlewareQueue $middlewareQueue The middleware queue to setup. | |
64 | + * @return \Cake\Http\MiddlewareQueue The updated middleware queue. | |
65 | + */ | |
66 | + public function middleware($middlewareQueue) | |
67 | + { | |
68 | + $middlewareQueue | |
69 | + // Catch any exceptions in the lower layers, | |
70 | + // and make an error page/response | |
71 | + ->add(new ErrorHandlerMiddleware(null, Configure::read('Error'))) | |
72 | + | |
73 | + // Handle plugin/theme assets like CakePHP normally does. | |
74 | + ->add(new AssetMiddleware([ | |
75 | + 'cacheTime' => Configure::read('Asset.cacheTime') | |
76 | + ])) | |
77 | + | |
78 | + // Add routing middleware. | |
79 | + // Routes collection cache enabled by default, to disable route caching | |
80 | + // pass null as cacheConfig, example: `new RoutingMiddleware($this)` | |
81 | + // you might want to disable this cache in case your routing is extremely simple | |
82 | + ->add(new RoutingMiddleware($this, '_cake_routes_')); | |
83 | + | |
84 | + return $middlewareQueue; | |
85 | + } | |
86 | +} | ... | ... |
src/Controller/MaterielsController.php
... | ... | @@ -1329,10 +1329,7 @@ class MaterielsController extends AppController |
1329 | 1329 | { |
1330 | 1330 | $searchFieldName = 's_' . $fieldName; |
1331 | 1331 | //if ($this->request->getData($searchFieldName) !== null && ($this->request->getData($searchFieldName) != '')) |
1332 | - if ($this->request->getData($searchFieldName)) | |
1333 | - return [ | |
1334 | - "Materiels.$fieldName LIKE" => '%' . $this->request->getData($searchFieldName) . '%' | |
1335 | - ]; | |
1332 | + if ($this->request->getData($searchFieldName)) return [ "Materiels.$fieldName LIKE" => '%' . $this->request->getData($searchFieldName) . '%' ]; | |
1336 | 1333 | return NULL; |
1337 | 1334 | } |
1338 | 1335 | |
... | ... | @@ -1345,29 +1342,29 @@ class MaterielsController extends AppController |
1345 | 1342 | private function getConditionForFieldNumber($fieldName) |
1346 | 1343 | { |
1347 | 1344 | $searchFieldName = 's_' . $fieldName; |
1348 | - if ($this->request->getData($searchFieldName) !== null && ($this->request->getData($searchFieldName) != '')) | |
1349 | - return [ | |
1350 | - "Materiels.$fieldName =" => $this->request->getData($searchFieldName) | |
1351 | - ]; | |
1345 | + //if ($this->request->getData($searchFieldName) !== null && ($this->request->getData($searchFieldName) != '')) | |
1346 | + //if ($this->request->getData($searchFieldName)) return [ "Materiels.$fieldName =" => $this->request->getData($searchFieldName) ]; | |
1347 | + if ($this->request->getData($searchFieldName)) return [ "Materiels.$fieldName LIKE" => $this->request->getData($searchFieldName) ]; | |
1352 | 1348 | return NULL; |
1353 | 1349 | } |
1354 | 1350 | |
1355 | 1351 | |
1352 | + /* | |
1353 | + * @param string $general_search_field_name : 's_all' or 's_all2' | |
1354 | + */ | |
1356 | 1355 | private function find_general($general_search_field_name) { |
1357 | - // $general_search_field_name equals 's_all' or 's_all2' | |
1358 | 1356 | |
1357 | + $all = $this->request->getData($general_search_field_name); // 's_all' or 's_all2' | |
1359 | 1358 | //$generalFieldConditions = NULL; |
1360 | 1359 | |
1361 | - $all = $this->request->getData($general_search_field_name); | |
1362 | - //debug($all); exit; | |
1363 | 1360 | // Check for a date |
1364 | - foreach ([ | |
1365 | - "/", | |
1366 | - "-" | |
1367 | - ] as $symb) { | |
1368 | - $pos1 = strpos($all, $symb); // Première occurence | |
1369 | - $pos2 = strrchr($all, $symb); // Dernière occurence | |
1370 | - if ($pos1 !== false && $pos2 !== false && $pos1 != $pos2) { | |
1361 | + foreach ( [ "/", "-" ] as $symb) { | |
1362 | + $nbocc = substr_count($all, $symb); | |
1363 | + //$pos1 = strpos($all, $symb); // Première occurence | |
1364 | + //$pos2 = strripos($all, $symb); // Dernière occurence | |
1365 | + //debug($nbocc); debug($symb); | |
1366 | + //if ($pos1 !== false && $pos2 !== false && $pos2 != $pos1) { | |
1367 | + if ($nbocc == 2) { | |
1371 | 1368 | list ($dd, $mm, $yyyy) = explode($symb, $all); |
1372 | 1369 | if (checkdate((int) $mm, (int) $dd, (int) $yyyy)) { |
1373 | 1370 | $all = "$yyyy-$mm-$dd"; |
... | ... | @@ -1377,65 +1374,73 @@ class MaterielsController extends AppController |
1377 | 1374 | } |
1378 | 1375 | // End datecheck |
1379 | 1376 | |
1377 | + // Si $all = "dell pallier", ça va chercher les lignes de la table matériel qui contiennent "dell" ET "pallier" dans n'importe quelle colonne | |
1380 | 1378 | $tabSearch = explode(' ', $all); |
1381 | - | |
1382 | 1379 | $merge = []; |
1383 | 1380 | foreach ($tabSearch as $word) { |
1384 | - $FieldConditions = [ | |
1385 | - // Utilisation de array() pour pouvoir mettre plusieurs fois la meme clé. | |
1386 | - // Exemple : la clé "Materiels.designation LIKE" pourra apparaître plusieurs fois si on fait une recherche de "mac pc" | |
1387 | - // On aura : "Materiels.designation LIKE" => '%mac%' et "Materiels.designation LIKE" => '%pc%' | |
1388 | - // Sinon on aurait uniquement eu : "Materiels.designation LIKE" => '%pc%' | |
1389 | - array( | |
1390 | - 'Materiels.designation LIKE' => '%' . $word . '%' | |
1391 | - ), | |
1392 | - array( | |
1393 | - 'Materiels.numero_laboratoire LIKE' => '%' . $word . '%' | |
1394 | - ), | |
1395 | - array( | |
1381 | + $field_conditions = [ | |
1382 | + /* (EP) : | |
1383 | + * Utilisation de array() [] pour pouvoir mettre plusieurs fois la meme clé. | |
1384 | + * Exemple : la clé "Materiels.designation LIKE" pourra apparaître plusieurs fois si on fait une recherche de "mac pc" | |
1385 | + * On aura : "Materiels.designation LIKE" => '%mac%' et "Materiels.designation LIKE" => '%pc%' | |
1386 | + * Sinon on aurait uniquement eu : "Materiels.designation LIKE" => '%pc%' | |
1387 | + */ | |
1388 | + | |
1389 | + // 1) Materiels table direct (straight) columns | |
1390 | + [ 'Materiels.designation LIKE' => '%' . $word . '%' ], | |
1391 | + [ 'Materiels.numero_laboratoire LIKE' => '%' . $word . '%' ], | |
1392 | + [ | |
1396 | 1393 | 'Materiels.numero_inventaire_organisme LIKE' => '%' . $word . '%' |
1397 | - ), | |
1398 | - array( | |
1394 | + ], | |
1395 | + [ | |
1399 | 1396 | 'Materiels.numero_inventaire_old LIKE' => '%' . $word . '%' |
1400 | - ), | |
1401 | - array( | |
1397 | + ], | |
1398 | + [ | |
1402 | 1399 | 'Materiels.numero_commande LIKE' => '%' . $word . '%' |
1403 | - ), | |
1404 | - array( | |
1400 | + ], | |
1401 | + [ | |
1405 | 1402 | 'Materiels.description LIKE' => '%' . $word . '%' |
1406 | - ), | |
1407 | - /*TODO: comment gérer fournisseur ???*/ | |
1408 | - array( | |
1409 | - //'Materiels.fournisseur_id LIKE' => '%' . $word . '%' | |
1410 | - //'Materiels.fournisseur_id =' => $word | |
1411 | - 'Fournisseurs.nom LIKE' => '%' . $word . '%' | |
1412 | - ), | |
1413 | - array( | |
1403 | + ], | |
1404 | + [ | |
1414 | 1405 | 'Materiels.nom_responsable LIKE' => '%' . $word . '%' |
1415 | - ), | |
1416 | - array( | |
1406 | + ], | |
1407 | + [ | |
1417 | 1408 | 'Materiels.email_responsable LIKE' => '%' . $word . '%' |
1418 | - ), | |
1419 | - array( | |
1409 | + ], | |
1410 | + [ | |
1420 | 1411 | 'Materiels.code_comptable LIKE' => '%' . $word . '%' |
1421 | - ), | |
1422 | - array( | |
1412 | + ], | |
1413 | + [ | |
1423 | 1414 | 'Materiels.numero_serie LIKE' => '%' . $word . '%' |
1424 | - ), | |
1425 | - array( | |
1415 | + ], | |
1416 | + [ | |
1426 | 1417 | 'Materiels.date_acquisition LIKE' => '%' . $word . '%' |
1427 | - ), | |
1428 | - array( | |
1418 | + ], | |
1419 | + [ | |
1429 | 1420 | 'Materiels.lieu_detail LIKE' => '%' . $word . '%' |
1430 | - ) | |
1421 | + ], | |
1422 | + | |
1423 | + // 2) Materiels table foreign keys | |
1424 | + [ 'Fournisseurs.nom LIKE' => '%' . $word . '%' ], | |
1425 | + [ 'Categories.nom LIKE' => '%' . $word . '%' ], | |
1426 | + | |
1431 | 1427 | ]; |
1432 | - $merge = array_merge($merge, $FieldConditions); | |
1428 | + | |
1429 | + /* (EP) | |
1430 | + * For N words in $tabSearch, this will return $merge1 AND $merge2 AND ... $mergeN | |
1431 | + * (each merge being a list of OR conditions) | |
1432 | + * Ex: | |
1433 | + * Si $tabSearch = "dell pallier", ça va chercher les lignes de la table matériel qui contiennent "dell" ET "pallier" dans n'importe quelle colonne | |
1434 | + * | |
1435 | + * Utilisation de array() [] pour pouvoir mettre plusieurs fois la meme clé "AND". | |
1436 | + */ | |
1437 | + $merge = array_merge($merge, [[ 'AND' => ['OR' => $field_conditions] ]] ); | |
1438 | + //$merge = array_merge($merge, $field_conditions); | |
1433 | 1439 | } |
1434 | - $generalFieldConditions = [ | |
1435 | - 'OR' => $merge | |
1436 | - ]; | |
1437 | - | |
1438 | - return $generalFieldConditions; | |
1440 | + | |
1441 | + //debug($merge); | |
1442 | + return $merge; | |
1443 | + //return [ 'OR' => $merge ]; | |
1439 | 1444 | } |
1440 | 1445 | |
1441 | 1446 | |
... | ... | @@ -1542,6 +1547,7 @@ class MaterielsController extends AppController |
1542 | 1547 | $matostypeRequest, |
1543 | 1548 | $this->getConditionForField('status'), |
1544 | 1549 | ]; |
1550 | + //debug($specificFieldsConditions); | |
1545 | 1551 | |
1546 | 1552 | return $specificFieldsConditions; |
1547 | 1553 | ... | ... |
src/Model/Table/LdapConnectionsTable.php
... | ... | @@ -182,6 +182,10 @@ class LdapConnectionsTable extends AppTable |
182 | 182 | $ldapConnection = ldap_connect($this->host, $this->port); |
183 | 183 | ldap_set_option($ldapConnection, LDAP_OPT_PROTOCOL_VERSION, 3); |
184 | 184 | |
185 | + // Binding optionnel | |
186 | + if ($this->ldap_authentified) $ldapbind = ldap_bind($ldapConnection, $this->bindDn, $this->bindPass) | |
187 | + or die("Could not bind to LDAP server.". ldap_error($ldapConnection) ); | |
188 | + | |
185 | 189 | $results = ldap_search($ldapConnection, $this->baseDn, $this->filter); |
186 | 190 | |
187 | 191 | $res = ldap_get_entries($ldapConnection, $results); |
... | ... | @@ -397,6 +401,7 @@ class LdapConnectionsTable extends AppTable |
397 | 401 | // Binding optionnel |
398 | 402 | if ($this->ldap_authentified) $ldapbind = ldap_bind($ldapConnection, $this->bindDn, $this->bindPass) |
399 | 403 | or die("Could not bind to LDAP server.". ldap_error($ldapConnection) ); |
404 | + | |
400 | 405 | $search = $this->getUserAttributes($user_login, $ldapConnection, $filter, $just_these); |
401 | 406 | if ($search === false) die("Could not get user attributes from LDAP server, response was: " . ldap_error($ldapConnection) ); |
402 | 407 | return $search[0]; | ... | ... |
tests/Fixture/FournisseursFixture.php
... | ... | @@ -37,11 +37,11 @@ class FournisseursFixture extends TestFixture |
37 | 37 | public $records = [ |
38 | 38 | [ |
39 | 39 | 'id' => 1, |
40 | - 'nom' => 'Premier Fournisseur' | |
40 | + 'nom' => 'Fournisseur1' | |
41 | 41 | ], |
42 | 42 | [ |
43 | 43 | 'id' => 2, |
44 | - 'nom' => 'Deuxieme Fournisseur' | |
44 | + 'nom' => 'Fournisseur2' | |
45 | 45 | ], |
46 | 46 | ]; |
47 | 47 | } | ... | ... |
tests/Fixture/MaterielsFixture.php
... | ... | @@ -637,7 +637,7 @@ class MaterielsFixture extends TestFixture { |
637 | 637 | 'organisme_id' => 1, |
638 | 638 | 'site_id' => 1, |
639 | 639 | 'metrologie' => 0, |
640 | - 'fournisseur_id' => 1 | |
640 | + 'fournisseur_id' => 2 | |
641 | 641 | ], |
642 | 642 | [ |
643 | 643 | 'id' => 2, |
... | ... | @@ -673,7 +673,7 @@ class MaterielsFixture extends TestFixture { |
673 | 673 | 'organisme_id' => 1, |
674 | 674 | 'site_id' => 1, |
675 | 675 | 'metrologie' => 0, |
676 | - 'fournisseur_id' => 1 | |
676 | + 'fournisseur_id' => 2 | |
677 | 677 | ], |
678 | 678 | [ |
679 | 679 | 'id' => 3, |
... | ... | @@ -709,7 +709,7 @@ class MaterielsFixture extends TestFixture { |
709 | 709 | 'organisme_id' => 1, |
710 | 710 | 'site_id' => 1, |
711 | 711 | 'metrologie' => 0, |
712 | - 'fournisseur_id' => 1 | |
712 | + 'fournisseur_id' => 2 | |
713 | 713 | ], |
714 | 714 | [ |
715 | 715 | 'id' => 11, |
... | ... | @@ -830,7 +830,7 @@ class MaterielsFixture extends TestFixture { |
830 | 830 | 'materiel_administratif' => 1, |
831 | 831 | 'materiel_technique' => 1, |
832 | 832 | 'status' => 'ARCHIVED', |
833 | - 'date_acquisition' => '2016-05-11', | |
833 | + 'date_acquisition' => '2016-05-10', | |
834 | 834 | 'prix_ht' => 75, |
835 | 835 | 'eotp' => 'Lorem ipsum dolor sit amet', |
836 | 836 | 'numero_commande' => 'Lorem ipsum dolor sit amet', | ... | ... |
tests/TestCase/Controller/MaterielsControllerTest.php
... | ... | @@ -760,11 +760,10 @@ class MaterielsControllerTest extends General { |
760 | 760 | * |
761 | 761 | * @return void |
762 | 762 | */ |
763 | - public function testFind() { | |
764 | - $this->authSuperAdmin(); | |
765 | - | |
766 | - $dataSearch = [ | |
767 | - 's_designation' => 'Test', | |
763 | + private function get_specific_fields() { | |
764 | + return [ | |
765 | + //'s_designation' => 'Test', | |
766 | + 's_designation' => '', | |
768 | 767 | 's_matostype' => '', |
769 | 768 | 's_sur_categorie_id' => '', |
770 | 769 | 's_categorie_id' => '', |
... | ... | @@ -787,87 +786,163 @@ class MaterielsControllerTest extends General { |
787 | 786 | 's_fournisseur_id' => '', |
788 | 787 | 's_salle' => '' |
789 | 788 | ]; |
789 | + | |
790 | + } | |
791 | + public function testFind() { | |
792 | + $this->authSuperAdmin(); | |
793 | + | |
794 | + $dataSearch = $this->get_specific_fields(); | |
790 | 795 | |
791 | - // Test sans aucun champ | |
796 | + /* | |
797 | + * 1. Test sans aucun champ | |
798 | + */ | |
792 | 799 | $this->get('/materiels/find'); |
793 | 800 | $this->assertResponseContains("Aucun résultats pour cette recherche.", "Le contenu de la recherche devrait être vide."); |
794 | 801 | |
795 | - // Test champ générale formulaire | |
796 | - $this->post('/materiels/find', [ | |
797 | - 's_all' => 'TEST-2016-0002' | |
798 | - ]); | |
802 | + | |
803 | + /* | |
804 | + * 2. Test champ global "s_all_2" dans le menu latéral de gauche | |
805 | + */ | |
806 | + $this->post('/materiels/find', | |
807 | + ['s_all_2' => 'TEST-2016-0002'] | |
808 | + ); | |
809 | + $this->assertResponseContains("Résultats (1)", "Le nb de materiels pour la recherche général du menu latéral est incorrecte."); | |
810 | + | |
811 | + | |
812 | + /* | |
813 | + * 3. Test champ général "s_all" en haut du formulaire | |
814 | + */ | |
815 | + $this->post( '/materiels/find', ['s_all' => 'TEST-2016-0002'] ); | |
799 | 816 | $this->assertResponseContains("Résultats (1)", "Le nb de materiels pour la recherche générale du formulaire est incorrecte."); |
800 | 817 | |
801 | - // Test champ générale menu latéral | |
802 | - $this->post('/materiels/find', [ | |
803 | - 's_all_2' => 'TEST-2016-0002' | |
804 | - ]); | |
805 | - $this->assertResponseContains("Résultats (1)", "Le nb de materiels pour la recherche général du menu latéral est incorrecte."); | |
818 | + $this->post( '/materiels/find', ['s_all' => 'Fournisseur'] ); | |
819 | + $this->assertResponseContains("Résultats (7)", "Le nb de materiels pour la recherche générale du formulaire est incorrecte."); | |
820 | + | |
821 | + $this->post( '/materiels/find', ['s_all' => 'Fournisseur1'] ); | |
822 | + $this->assertResponseContains("Résultats (4)", "Le nb de materiels pour la recherche générale du formulaire est incorrecte."); | |
823 | + $this->post( '/materiels/find', ['s_all' => 'Fournisseur2'] ); | |
824 | + $this->assertResponseContains("Résultats (3)", "Le nb de materiels pour la recherche générale du formulaire est incorrecte."); | |
806 | 825 | |
807 | - // Test champ designation | |
826 | + $this->post( '/materiels/find', ['s_all' => 'Fournisseur Test'] ); | |
827 | + $this->assertResponseContains("Résultats (7)", "Le nb de materiels pour la recherche générale du formulaire est incorrecte."); | |
828 | + | |
829 | + // les matériels trouvés doivent contenir "Fournisseur" ET "Test" ET "(C)" | |
830 | + $this->post( '/materiels/find', ['s_all' => 'Fournisseur Test (C)'] ); | |
831 | + $this->assertResponseContains("Résultats (3)", "Le nb de materiels pour la recherche générale du formulaire est incorrecte."); | |
832 | + | |
833 | + | |
834 | + /* | |
835 | + * 4. Recherche dans les champs spécifiques du formulaire | |
836 | + */ | |
837 | + | |
838 | + // 4.1 Test champs individuels (un seul champ) | |
839 | + | |
840 | + // - Test champ designation | |
841 | + // -- un mot | |
842 | + $dataSearch['s_designation'] = 'Test'; | |
808 | 843 | $this->post('/materiels/find', $dataSearch); |
809 | 844 | $this->assertResponseContains("Résultats (6)", "Le nb de materiels pour la recherche par désignation est incorrecte."); |
810 | - | |
811 | - // Test champ numero_laboratoire | |
845 | + // -- N mots | |
846 | + $dataSearch['s_designation'] = 'Test TBA'; // = contient "Test" ET "TBA" => devrait trouver "Test 13 (TBA)" | |
847 | + $this->post('/materiels/find', $dataSearch); | |
848 | + $this->assertResponseContains("Résultats (1)", "Le nb de materiels pour la recherche par désignation est incorrecte."); | |
849 | + $dataSearch['s_designation'] = 'Test 13 TBA'; // = contient "Test" ET "TBA" => devrait trouver "Test 13 (TBA)" | |
850 | + $this->post('/materiels/find', $dataSearch); | |
851 | + $this->assertResponseContains("Résultats (1)", "Le nb de materiels pour la recherche par désignation est incorrecte."); | |
812 | 852 | $dataSearch['s_designation'] = ''; |
853 | + | |
854 | + // - Test champ numero_laboratoire | |
813 | 855 | $dataSearch['s_numero_laboratoire'] = 'TEST-2016-0003'; |
814 | 856 | $this->post('/materiels/find', $dataSearch); |
815 | 857 | $this->assertResponseContains("Résultats (1)", "Le nb de materiels pour la recherche par numero de laboratoire est incorrecte."); |
816 | - | |
817 | - // Test champ status | |
818 | 858 | $dataSearch['s_numero_laboratoire'] = ''; |
859 | + | |
860 | + // - Test champ status | |
819 | 861 | $dataSearch['s_status'] = 'CREATED'; |
820 | 862 | $this->post('/materiels/find', $dataSearch); |
821 | 863 | $this->assertResponseContains("Résultats (3)", "Le nb de materiels pour la recherche par statut est incorrecte."); |
822 | - | |
823 | - // Test champ date_acquisition | |
824 | 864 | $dataSearch['s_status'] = ''; |
865 | + | |
866 | + // - Test champ date_acquisition | |
825 | 867 | $dataSearch['s_date_acquisition'] = '2016-05-11'; |
826 | 868 | $this->post('/materiels/find', $dataSearch); |
827 | - $this->assertResponseContains("Résultats (5)", "Le nb de materiels pour la recherche par date d'acquisition est incorrecte."); | |
828 | - /*TODO: | |
829 | - * //Test champ fournisseur_id | |
830 | - * $dataSearch['s_fournisseur_id'] = 1; | |
831 | - * $this->post('/materiels/find', $dataSearch); | |
832 | - * $this->assertResponseContains("Résultats (4)", "Le nb de materiels pour la recherche par fournisseur_id est incorrecte."); | |
833 | - * //Test champ salle | |
869 | + $this->assertResponseContains("Résultats (4)", "Le nb de materiels pour la recherche par date d'acquisition est incorrecte."); | |
870 | + $dataSearch['s_date_acquisition'] = ''; | |
871 | + | |
872 | + // - Test champ fournisseur_id | |
873 | + $dataSearch['s_fournisseur_id'] = 1; | |
874 | + $dataSearch['s_date_acquisition'] = '2016-05-11'; | |
875 | + $this->post('/materiels/find', $dataSearch); | |
876 | + $this->assertResponseContains("Résultats (3)", "Le nb de materiels pour la recherche par fournisseur_id est incorrecte."); | |
877 | + $dataSearch['s_date_acquisition'] = ''; | |
878 | + $this->post('/materiels/find', $dataSearch); | |
879 | + $this->assertResponseContains("Résultats (4)", "Le nb de materiels pour la recherche par fournisseur_id est incorrecte."); | |
880 | + $dataSearch['s_fournisseur_id'] = ''; | |
881 | + $dataSearch['s_date_acquisition'] = ''; | |
882 | + | |
883 | + //- Test champ salle | |
884 | + /* | |
834 | 885 | * $dataSearch['s_salle'] = 'I203'; |
835 | 886 | * $this->post('/materiels/find', $dataSearch); |
836 | 887 | * $this->assertResponseContains("Résultats (2)", "Le nb de materiels pour la recherche par detaille lieu est incorrecte."); |
837 | 888 | */ |
838 | - // Test champ periode_acquisition1 (debut) | |
839 | - $dataSearch['s_date_acquisition'] = ''; | |
889 | + | |
890 | + // - Test champ periode_acquisition1 (debut) | |
840 | 891 | $dataSearch['s_periode_acquisition1'] = '2015-01-01'; |
841 | 892 | $this->post('/materiels/find', $dataSearch); |
842 | 893 | $this->assertResponseContains("Résultats (6)", "Le nb de materiels pour la recherche par debut de periode d'acquisition est incorrecte."); |
843 | - | |
844 | - // Test champ periode_acquisition1 (debut) && champ periode_acquisition2 (fin) | |
894 | + // - Test champ periode_acquisition1 (debut) && champ periode_acquisition2 (fin) | |
845 | 895 | $dataSearch['s_periode_acquisition2'] = '2016-01-01'; |
846 | 896 | $this->post('/materiels/find', $dataSearch); |
847 | 897 | $this->assertResponseContains("Résultats (1)", "Le nb de materiels pour la recherche par intervalle entre la periode d'acquisition (debut) et la periode d'acquisition (fin) est incorrecte."); |
848 | - | |
849 | - // Test champ periode_acquisition2 (fin) | |
898 | + // - Test champ periode_acquisition2 (fin) | |
850 | 899 | $dataSearch['s_periode_acquisition1'] = ''; |
851 | 900 | $this->post('/materiels/find', $dataSearch); |
852 | 901 | $this->assertResponseContains("Résultats (2)", "Le nb de materiels pour la recherche par fin de periode d'acquisition est incorrecte."); |
853 | - | |
854 | - // Test champ prix_ht | |
855 | 902 | $dataSearch['s_periode_acquisition2'] = ''; |
903 | + | |
904 | + // - Test champ prix_ht | |
856 | 905 | $dataSearch['s_prix_ht'] = '50'; |
857 | 906 | $this->post('/materiels/find', $dataSearch); |
858 | - $this->assertResponseContains("Résultats (1)", "Le nb de materiels pour la recherche par prix ht est incorrecte."); | |
859 | - | |
860 | - // Test champ prix_ht_sup | |
907 | + $this->assertResponseContains("Résultats (1)", "Le nb de materiels pour la recherche par prix ht est incorrecte (v1)."); | |
861 | 908 | $dataSearch['s_prix_ht'] = ''; |
862 | - $dataSearch['s_prix_ht_sup'] = '30'; | |
909 | + // - Meme test mais avec autres champs | |
910 | + $dataSearch['s_prix_ht_sup'] = '50'; // >= 50 | |
911 | + $dataSearch['s_prix_ht_inf'] = '50'; // <= 50 | |
912 | + $this->post('/materiels/find', $dataSearch); | |
913 | + $this->assertResponseContains("Résultats (1)", "Le nb de materiels pour la recherche par prix ht est incorrecte (v2)."); | |
914 | + $dataSearch['s_prix_ht_inf'] = ''; | |
915 | + $dataSearch['s_prix_ht_sup'] = ''; | |
916 | + $dataSearch['s_prix_ht'] = '75'; | |
917 | + $this->post('/materiels/find', $dataSearch); | |
918 | + $this->assertResponseContains("Résultats (5)", "Le nb de materiels pour la recherche par prix ht est incorrecte (v1)."); | |
919 | + $dataSearch['s_prix_ht'] = ''; | |
920 | + | |
921 | + // - Test champ prix_ht_sup | |
922 | + $dataSearch['s_prix_ht_sup'] = '30'; // >= 30 | |
863 | 923 | $this->post('/materiels/find', $dataSearch); |
864 | 924 | $this->assertResponseContains("Résultats (6)", "Le nb de materiels pour la recherche par prix ht superieur est incorrecte."); |
865 | - | |
866 | - // Test champ prix_ht_inf | |
867 | 925 | $dataSearch['s_prix_ht_sup'] = ''; |
868 | - $dataSearch['s_prix_ht_inf'] = '70'; | |
926 | + // - Test champ prix_ht_inf | |
927 | + $dataSearch['s_prix_ht_inf'] = '70'; // <=70 | |
869 | 928 | $this->post('/materiels/find', $dataSearch); |
870 | 929 | $this->assertResponseContains("Résultats (2)", "Le nb de materiels pour la recherche par prix ht inferieur est incorrecte."); |
930 | + $dataSearch['s_prix_ht_inf'] = ''; | |
931 | + // - Test champ prix_ht_inf et sup | |
932 | + $dataSearch['s_prix_ht_sup'] = '30'; // >= 30 | |
933 | + $dataSearch['s_prix_ht_inf'] = '70'; // <=70 | |
934 | + $this->post('/materiels/find', $dataSearch); | |
935 | + $this->assertResponseContains("Résultats (1)", "Le nb de materiels pour la recherche par prix ht inf et sup est incorrecte."); | |
936 | + $dataSearch['s_prix_ht_sup'] = '25'; // >= 30 | |
937 | + $dataSearch['s_prix_ht_inf'] = '75'; // <=70 | |
938 | + $this->post('/materiels/find', $dataSearch); | |
939 | + $this->assertResponseContains("Résultats (7)", "Le nb de materiels pour la recherche par prix ht inf et sup est incorrecte."); | |
940 | + $dataSearch['s_prix_ht_inf'] = ''; | |
941 | + $dataSearch['s_prix_ht_sup'] = ''; | |
942 | + | |
943 | + // 4.2 Test champs multiples (plusieurs champs à la fois) | |
944 | + //$dataSearch = $this->get_specific_fields(); | |
945 | + | |
871 | 946 | } |
872 | 947 | |
873 | 948 | /** | ... | ... |
... | ... | @@ -0,0 +1,40 @@ |
1 | +<?php | |
2 | +/** | |
3 | + * The Front Controller for handling every request | |
4 | + * | |
5 | + * CakePHP(tm) : Rapid Development Framework (https://cakephp.org) | |
6 | + * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org) | |
7 | + * | |
8 | + * Licensed under The MIT License | |
9 | + * For full copyright and license information, please see the LICENSE.txt | |
10 | + * Redistributions of files must retain the above copyright notice. | |
11 | + * | |
12 | + * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org) | |
13 | + * @link https://cakephp.org CakePHP(tm) Project | |
14 | + * @since 0.2.9 | |
15 | + * @license MIT License (https://opensource.org/licenses/mit-license.php) | |
16 | + */ | |
17 | + | |
18 | +// Check platform requirements | |
19 | +require dirname(__DIR__) . '/config/requirements.php'; | |
20 | + | |
21 | +// For built-in server | |
22 | +if (PHP_SAPI === 'cli-server') { | |
23 | + $_SERVER['PHP_SELF'] = '/' . basename(__FILE__); | |
24 | + | |
25 | + $url = parse_url(urldecode($_SERVER['REQUEST_URI'])); | |
26 | + $file = __DIR__ . $url['path']; | |
27 | + if (strpos($url['path'], '..') === false && strpos($url['path'], '.') !== false && is_file($file)) { | |
28 | + return false; | |
29 | + } | |
30 | +} | |
31 | +require dirname(__DIR__) . '/vendor/autoload.php'; | |
32 | + | |
33 | +use App\Application; | |
34 | +use Cake\Http\Server; | |
35 | + | |
36 | +// Bind your application to the server. | |
37 | +$server = new Server(new Application(dirname(__DIR__) . '/config')); | |
38 | + | |
39 | +// Run the request/response through the application and emit the response. | |
40 | +$server->emit($server->run()); | ... | ... |