From 3d7360371751ce947ee097a01d6d589cad1e4ebc Mon Sep 17 00:00:00 2001 From: Johan Cwiklinski Date: Sat, 6 Nov 2021 10:05:36 +0100 Subject: [PATCH] Check MySQL warning in tests suite --- galette/lib/Galette/Core/Db.php | 17 +++++++++++ .../Controllers/tests/units/PdfController.php | 18 ++++++++++-- .../Galette/Core/tests/units/CheckModules.php | 15 ++++++++++ tests/Galette/Core/tests/units/Db.php | 29 +++++++++++++++++-- tests/Galette/Core/tests/units/I18n.php | 20 +++++++++++-- tests/Galette/Core/tests/units/Install.php | 19 ++++++++++-- tests/Galette/Core/tests/units/L10n.php | 11 ++++--- tests/Galette/Core/tests/units/Links.php | 9 ++++-- tests/Galette/Core/tests/units/Logo.php | 18 ++++++++++-- tests/Galette/Core/tests/units/Password.php | 18 ++++++++++-- tests/Galette/Core/tests/units/Picture.php | 20 +++++++++++-- tests/Galette/Core/tests/units/Plugins.php | 17 +++++++++-- .../Galette/Core/tests/units/Preferences.php | 18 ++++++++++-- tests/Galette/Core/tests/units/PrintLogo.php | 18 ++++++++++-- .../DynamicFields/tests/units/Boolean.php | 4 +-- .../DynamicFields/tests/units/Separator.php | 4 +-- tests/Galette/Entity/tests/units/Adherent.php | 6 ++-- .../Entity/tests/units/Contribution.php | 8 +++-- .../Entity/tests/units/FieldsConfig.php | 4 +-- .../Entity/tests/units/ListsConfig.php | 11 ++++--- .../Entity/tests/units/PaymentType.php | 11 ++++--- tests/Galette/Entity/tests/units/PdfModel.php | 12 ++++---- .../Galette/Entity/tests/units/SavedSeach.php | 11 ++++--- tests/Galette/Entity/tests/units/Status.php | 11 ++++--- tests/Galette/Entity/tests/units/Title.php | 11 ++++--- .../Entity/tests/units/Transaction.php | 8 +++-- tests/Galette/IO/tests/units/CsvIn.php | 12 ++++---- tests/Galette/IO/tests/units/News.php | 4 +-- .../Middleware/tests/unit/CheckAcls.php | 4 +-- .../Repository/tests/units/Members.php | 12 ++++---- .../Repository/tests/units/PaymentTypes.php | 11 +++---- .../Repository/tests/units/PdfModels.php | 11 +++---- .../Repository/tests/units/Reminders.php | 11 +++---- tests/Galette/Util/tests/units/Password.php | 7 +++-- tests/Galette/Util/tests/units/Telemetry.php | 8 +++-- tests/GaletteTestCase.php | 19 ++++++++++-- .../Core/tests/units/Install.php | 18 ++++++++++-- 37 files changed, 361 insertions(+), 104 deletions(-) diff --git a/galette/lib/Galette/Core/Db.php b/galette/lib/Galette/Core/Db.php index b35791efa..ef45d7b75 100644 --- a/galette/lib/Galette/Core/Db.php +++ b/galette/lib/Galette/Core/Db.php @@ -980,4 +980,21 @@ class Db : null ); } + + /** + * Get MySQL warnings + * + * @return array + */ + public function getWarnings(): array + { + $results = $this->db->query('SHOW WARNINGS', Adapter::QUERY_MODE_EXECUTE); + + $warnings = []; + foreach ($results as $result) { + $warnings[] = $result; + } + + return $warnings; + } } diff --git a/tests/Galette/Controllers/tests/units/PdfController.php b/tests/Galette/Controllers/tests/units/PdfController.php index 9b1ea39da..dc6171993 100644 --- a/tests/Galette/Controllers/tests/units/PdfController.php +++ b/tests/Galette/Controllers/tests/units/PdfController.php @@ -73,11 +73,11 @@ class PdfController extends atoum /** * Set up tests * - * @param string $testMethod Calling method + * @param string $method Calling method * * @return void */ - public function beforeTestMethod($testMethod) + public function beforeTestMethod($method) { $this->zdb = new \Galette\Core\Db(); $this->preferences = new \Galette\Core\Preferences($this->zdb); @@ -150,6 +150,20 @@ class PdfController extends atoum $hist = $this->history; } + /** + * Tear down tests + * + * @param string $method Calling method + * + * @return void + */ + public function afterTestMethod($method) + { + if (TYPE_DB === 'mysql') { + $this->array($this->zdb->getWarnings())->isIdenticalTo([]); + } + } + /** * Test store models * diff --git a/tests/Galette/Core/tests/units/CheckModules.php b/tests/Galette/Core/tests/units/CheckModules.php index 57b606c48..3d97aedea 100644 --- a/tests/Galette/Core/tests/units/CheckModules.php +++ b/tests/Galette/Core/tests/units/CheckModules.php @@ -53,6 +53,21 @@ use atoum; */ class CheckModules extends atoum { + /** + * Tear down tests + * + * @param string $method Calling method + * + * @return void + */ + public function afterTestMethod($method) + { + if (TYPE_DB === 'mysql') { + $zdb = new \Galette\Core\Db(); + $this->array($zdb->getWarnings())->isIdenticalTo([]); + } + } + /** * Test modules, all should be ok * diff --git a/tests/Galette/Core/tests/units/Db.php b/tests/Galette/Core/tests/units/Db.php index c7ec1360f..6fd7d4164 100644 --- a/tests/Galette/Core/tests/units/Db.php +++ b/tests/Galette/Core/tests/units/Db.php @@ -58,15 +58,29 @@ class Db extends atoum /** * Set up tests * - * @param stgring $testMethod Method tested + * @param stgring $method Method tested * * @return void */ - public function beforeTestMethod($testMethod) + public function beforeTestMethod($method) { $this->db = new \Galette\Core\Db(); } + /** + * Tear down tests + * + * @param string $method Calling method + * + * @return void + */ + public function afterTestMethod($method) + { + if (TYPE_DB === 'mysql' and $method !== 'testExecuteWException') { + $this->array($this->db->getWarnings())->isIdenticalTo([]); + } + } + /** * Cleanup after tests * @@ -611,6 +625,17 @@ class Db extends atoum $this->object($results) ->isInstanceOf('\Zend\Db\ResultSet\ResultSet'); + } + + /** + * Test execute Method + * + * @return void + */ + public function testExecuteWException() + { + $select = $this->db->select('preferences', 'p'); + $select->where(['p.nom_pref' => 'azerty']); $this->exception( function () use ($select) { diff --git a/tests/Galette/Core/tests/units/I18n.php b/tests/Galette/Core/tests/units/I18n.php index cf4ca5e73..d61f41279 100644 --- a/tests/Galette/Core/tests/units/I18n.php +++ b/tests/Galette/Core/tests/units/I18n.php @@ -53,22 +53,38 @@ use atoum; */ class I18n extends atoum { + private $zdb; private $i18n = null; /** * Set up tests * - * @param string $testMethod Tested method name + * @param string $method Tested method name * * @return void */ - public function beforeTestMethod($testMethod) + public function beforeTestMethod($method) { + $this->zdb = new \Galette\Core\Db(); $this->i18n = new \Galette\Core\I18n( \Galette\Core\I18n::DEFAULT_LANG ); } + /** + * Tear down tests + * + * @param string $method Calling method + * + * @return void + */ + public function afterTestMethod($method) + { + if (TYPE_DB === 'mysql') { + $this->array($this->zdb->getWarnings())->isIdenticalTo([]); + } + } + /** * Test lang autodetect * diff --git a/tests/Galette/Core/tests/units/Install.php b/tests/Galette/Core/tests/units/Install.php index 261e95dcc..b3efd802e 100644 --- a/tests/Galette/Core/tests/units/Install.php +++ b/tests/Galette/Core/tests/units/Install.php @@ -58,16 +58,31 @@ class Install extends atoum /** * Set up tests * - * @param stgring $testMethod Method tested + * @param stgring $method Method tested * * @return void */ - public function beforeTestMethod($testMethod) + public function beforeTestMethod($method) { setlocale(LC_ALL, 'en_US'); $this->install = new \Galette\Core\Install(); } + /** + * Tear down tests + * + * @param string $method Calling method + * + * @return void + */ + public function afterTestMethod($method) + { + if (TYPE_DB === 'mysql') { + $zdb = new \Galette\Core\Db(); + $this->array($zdb->getWarnings())->isIdenticalTo([]); + } + } + /** * Test constructor * diff --git a/tests/Galette/Core/tests/units/L10n.php b/tests/Galette/Core/tests/units/L10n.php index b77c04e73..1507b1826 100644 --- a/tests/Galette/Core/tests/units/L10n.php +++ b/tests/Galette/Core/tests/units/L10n.php @@ -59,11 +59,11 @@ class L10n extends atoum /** * Set up tests * - * @param string $testMethod Tested method name + * @param string $method Tested method name * * @return void */ - public function beforeTestMethod($testMethod) + public function beforeTestMethod($method) { $this->zdb = new \Galette\Core\Db(); $this->i18n = new \Galette\Core\I18n( @@ -78,12 +78,15 @@ class L10n extends atoum /** * Tear down tests * - * @param string $testMethod Calling method + * @param string $method Calling method * * @return void */ - public function afterTestMethod($testMethod) + public function afterTestMethod($method) { + if (TYPE_DB === 'mysql') { + $this->array($this->zdb->getWarnings())->isIdenticalTo([]); + } //cleanup dynamic translations $delete = $this->zdb->delete(\Galette\Core\L10n::TABLE); $delete diff --git a/tests/Galette/Core/tests/units/Links.php b/tests/Galette/Core/tests/units/Links.php index 1b8202b16..fbe8aa6ac 100644 --- a/tests/Galette/Core/tests/units/Links.php +++ b/tests/Galette/Core/tests/units/Links.php @@ -56,17 +56,18 @@ class Links extends GaletteTestCase protected $seed = 95842355; private $links; private $ids = []; + protected $excluded_after_methods = ['testDuplicateLinkTarget']; /** * Set up tests * - * @param string $testMethod Method name + * @param string $method Method name * * @return void */ - public function beforeTestMethod($testMethod) + public function beforeTestMethod($method) { - parent::beforeTestMethod($testMethod); + parent::beforeTestMethod($method); $this->initStatus(); $this->initContributionsTypes(); @@ -90,6 +91,8 @@ class Links extends GaletteTestCase */ public function afterTestMethod($method) { + parent::afterTestMethod($method); + $delete = $this->zdb->delete(\Galette\Entity\Contribution::TABLE); $delete->where(['info_cotis' => 'FAKER' . $this->seed]); $this->zdb->execute($delete); diff --git a/tests/Galette/Core/tests/units/Logo.php b/tests/Galette/Core/tests/units/Logo.php index d1fd13831..7507c5301 100644 --- a/tests/Galette/Core/tests/units/Logo.php +++ b/tests/Galette/Core/tests/units/Logo.php @@ -58,17 +58,31 @@ class Logo extends atoum /** * Set up tests * - * @param string $testMethod Method name + * @param string $method Method name * * @return void */ - public function beforeTestMethod($testMethod) + public function beforeTestMethod($method) { global $zdb; $this->zdb = new \Galette\Core\Db(); $zdb = $this->zdb; } + /** + * Tear down tests + * + * @param string $method Calling method + * + * @return void + */ + public function afterTestMethod($method) + { + if (TYPE_DB === 'mysql') { + $this->array($this->zdb->getWarnings())->isIdenticalTo([]); + } + } + /** * Test defaults after initialization * diff --git a/tests/Galette/Core/tests/units/Password.php b/tests/Galette/Core/tests/units/Password.php index 2f9e605c3..27507c718 100644 --- a/tests/Galette/Core/tests/units/Password.php +++ b/tests/Galette/Core/tests/units/Password.php @@ -59,16 +59,30 @@ class Password extends atoum /** * Set up tests * - * @param string $testMethod Method name + * @param string $method Method name * * @return void */ - public function beforeTestMethod($testMethod) + public function beforeTestMethod($method) { $this->zdb = new \Galette\Core\Db(); $this->pass = new \Galette\Core\Password($this->zdb, false); } + /** + * Tear down tests + * + * @param string $method Calling method + * + * @return void + */ + public function afterTestMethod($method) + { + if (TYPE_DB === 'mysql') { + $this->array($this->zdb->getWarnings())->isIdenticalTo([]); + } + } + /** * Test unique password generator * diff --git a/tests/Galette/Core/tests/units/Picture.php b/tests/Galette/Core/tests/units/Picture.php index 671583ac7..a4af6e793 100644 --- a/tests/Galette/Core/tests/units/Picture.php +++ b/tests/Galette/Core/tests/units/Picture.php @@ -53,6 +53,7 @@ use atoum; */ class Picture extends atoum { + private $zdb; private $picture; private $expected_badchars = [ '.', @@ -72,15 +73,30 @@ class Picture extends atoum /** * Set up tests * - * @param string $testMethod Method name + * @param string $method Method name * * @return void */ - public function beforeTestMethod($testMethod) + public function beforeTestMethod($method) { + $this->zdb = new \Galette\Core\Db(); $this->picture = new \Galette\Core\Picture(); } + /** + * Tear down tests + * + * @param string $method Calling method + * + * @return void + */ + public function afterTestMethod($method) + { + if (TYPE_DB === 'mysql') { + $this->array($this->zdb->getWarnings())->isIdenticalTo([]); + } + } + /** * Test defaults after initialization * diff --git a/tests/Galette/Core/tests/units/Plugins.php b/tests/Galette/Core/tests/units/Plugins.php index 93adda18c..e8b13ead1 100644 --- a/tests/Galette/Core/tests/units/Plugins.php +++ b/tests/Galette/Core/tests/units/Plugins.php @@ -89,11 +89,11 @@ class Plugins extends atoum /** * Set up tests * - * @param string $testMethod Method tested + * @param string $method Method tested * * @return void */ - public function beforeTestMethod($testMethod) + public function beforeTestMethod($method) { $this->zdb = new \Galette\Core\Db(); $this->preferences = new \Galette\Core\Preferences($this->zdb); @@ -104,6 +104,19 @@ class Plugins extends atoum $this->plugin2['root']; } + /** + * Tear down tests + * + * @param string $method Calling method + * + * @return void + */ + public function afterTestMethod($method) + { + if (TYPE_DB === 'mysql') { + $this->array($this->zdb->getWarnings())->isIdenticalTo([]); + } + } /** * Tests plugins load diff --git a/tests/Galette/Core/tests/units/Preferences.php b/tests/Galette/Core/tests/units/Preferences.php index e77f10320..9e60112dd 100644 --- a/tests/Galette/Core/tests/units/Preferences.php +++ b/tests/Galette/Core/tests/units/Preferences.php @@ -59,11 +59,11 @@ class Preferences extends atoum /** * Set up tests * - * @param string $testMethod Calling method + * @param string $method Calling method * * @return void */ - public function beforeTestMethod($testMethod) + public function beforeTestMethod($method) { $this->zdb = new \Galette\Core\Db(); $this->preferences = new \Galette\Core\Preferences( @@ -71,6 +71,20 @@ class Preferences extends atoum ); } + /** + * Tear down tests + * + * @param string $method Calling method + * + * @return void + */ + public function afterTestMethod($method) + { + if (TYPE_DB === 'mysql') { + $this->array($this->zdb->getWarnings())->isIdenticalTo([]); + } + } + /** * Test preferences initialization * diff --git a/tests/Galette/Core/tests/units/PrintLogo.php b/tests/Galette/Core/tests/units/PrintLogo.php index 5e93aebd9..0d017f907 100644 --- a/tests/Galette/Core/tests/units/PrintLogo.php +++ b/tests/Galette/Core/tests/units/PrintLogo.php @@ -58,17 +58,31 @@ class PrintLogo extends atoum /** * Set up tests * - * @param string $testMethod Method name + * @param string $method Method name * * @return void */ - public function beforeTestMethod($testMethod) + public function beforeTestMethod($method) { global $zdb; $this->zdb = new \Galette\Core\Db(); $zdb = $this->zdb; } + /** + * Tear down tests + * + * @param string $method Calling method + * + * @return void + */ + public function afterTestMethod($method) + { + if (TYPE_DB === 'mysql') { + $this->array($this->zdb->getWarnings())->isIdenticalTo([]); + } + } + /** * Test defaults after initialization * diff --git a/tests/Galette/DynamicFields/tests/units/Boolean.php b/tests/Galette/DynamicFields/tests/units/Boolean.php index babf9a544..efe5301d3 100644 --- a/tests/Galette/DynamicFields/tests/units/Boolean.php +++ b/tests/Galette/DynamicFields/tests/units/Boolean.php @@ -59,11 +59,11 @@ class Boolean extends atoum /** * Set up tests * - * @param string $testMethod Current test method + * @param string $method Current test method * * @return void */ - public function beforeTestMethod($testMethod) + public function beforeTestMethod($method) { $this->zdb = new \Galette\Core\Db(); $this->bool = new \Galette\DynamicFields\Boolean($this->zdb); diff --git a/tests/Galette/DynamicFields/tests/units/Separator.php b/tests/Galette/DynamicFields/tests/units/Separator.php index 497046fd4..7efb432a0 100644 --- a/tests/Galette/DynamicFields/tests/units/Separator.php +++ b/tests/Galette/DynamicFields/tests/units/Separator.php @@ -59,11 +59,11 @@ class Separator extends atoum /** * Set up tests * - * @param string $testMethod Current test method + * @param string $method Current test method * * @return void */ - public function beforeTestMethod($testMethod) + public function beforeTestMethod($method) { $this->zdb = new \Galette\Core\Db(); $this->separator = new \Galette\DynamicFields\Separator($this->zdb); diff --git a/tests/Galette/Entity/tests/units/Adherent.php b/tests/Galette/Entity/tests/units/Adherent.php index 58fb83771..54ac7b621 100644 --- a/tests/Galette/Entity/tests/units/Adherent.php +++ b/tests/Galette/Entity/tests/units/Adherent.php @@ -80,13 +80,13 @@ class Adherent extends GaletteTestCase /** * Set up tests * - * @param string $testMethod Calling method + * @param string $method Calling method * * @return void */ - public function beforeTestMethod($testMethod) + public function beforeTestMethod($method) { - parent::beforeTestMethod($testMethod); + parent::beforeTestMethod($method); $this->initStatus(); $this->initTitles(); diff --git a/tests/Galette/Entity/tests/units/Contribution.php b/tests/Galette/Entity/tests/units/Contribution.php index 6e03bd068..eab885717 100644 --- a/tests/Galette/Entity/tests/units/Contribution.php +++ b/tests/Galette/Entity/tests/units/Contribution.php @@ -64,6 +64,8 @@ class Contribution extends GaletteTestCase */ public function afterTestMethod($method) { + parent::afterTestMethod($method); + $this->zdb = new \Galette\Core\Db(); $delete = $this->zdb->delete(\Galette\Entity\Contribution::TABLE); $delete->where(['info_cotis' => 'FAKER' . $this->seed]); @@ -84,13 +86,13 @@ class Contribution extends GaletteTestCase /** * Set up tests * - * @param string $testMethod Calling method + * @param string $method Calling method * * @return void */ - public function beforeTestMethod($testMethod) + public function beforeTestMethod($method) { - parent::beforeTestMethod($testMethod); + parent::beforeTestMethod($method); $this->initContributionsTypes(); $this->contrib = new \Galette\Entity\Contribution($this->zdb, $this->login); diff --git a/tests/Galette/Entity/tests/units/FieldsConfig.php b/tests/Galette/Entity/tests/units/FieldsConfig.php index a6623604f..df4916cf2 100644 --- a/tests/Galette/Entity/tests/units/FieldsConfig.php +++ b/tests/Galette/Entity/tests/units/FieldsConfig.php @@ -61,11 +61,11 @@ class FieldsConfig extends atoum /** * Set up tests * - * @param string $testMethod Calling method + * @param string $method Calling method * * @return void */ - public function beforeTestMethod($testMethod) + public function beforeTestMethod($method) { $this->zdb = new \Galette\Core\Db(); diff --git a/tests/Galette/Entity/tests/units/ListsConfig.php b/tests/Galette/Entity/tests/units/ListsConfig.php index e24f48d2f..6cc0f020c 100644 --- a/tests/Galette/Entity/tests/units/ListsConfig.php +++ b/tests/Galette/Entity/tests/units/ListsConfig.php @@ -69,11 +69,11 @@ class ListsConfig extends atoum /** * Set up tests * - * @param string $testMethod Calling method + * @param string $method Calling method * * @return void */ - public function beforeTestMethod($testMethod) + public function beforeTestMethod($method) { $this->zdb = new \Galette\Core\Db(); @@ -94,12 +94,15 @@ class ListsConfig extends atoum /** * Tear down tests * - * @param string $testMethod Calling method + * @param string $method Calling method * * @return void */ - public function afterTestMethod($testMethod) + public function afterTestMethod($method) { + if (TYPE_DB === 'mysql') { + $this->array($this->zdb->getWarnings())->isIdenticalTo([]); + } $this->resetListsConfig(); } diff --git a/tests/Galette/Entity/tests/units/PaymentType.php b/tests/Galette/Entity/tests/units/PaymentType.php index fd8d477e6..693f1eb9e 100644 --- a/tests/Galette/Entity/tests/units/PaymentType.php +++ b/tests/Galette/Entity/tests/units/PaymentType.php @@ -62,11 +62,11 @@ class PaymentType extends atoum /** * Set up tests * - * @param string $testMethod Calling method + * @param string $method Calling method * * @return void */ - public function beforeTestMethod($testMethod) + public function beforeTestMethod($method) { $this->zdb = new \Galette\Core\Db(); $this->preferences = new \Galette\Core\Preferences($this->zdb); @@ -83,12 +83,15 @@ class PaymentType extends atoum /** * Tear down tests * - * @param string $testMethod Calling method + * @param string $method Calling method * * @return void */ - public function afterTestMethod($testMethod) + public function afterTestMethod($method) { + if (TYPE_DB === 'mysql') { + $this->array($this->zdb->getWarnings())->isIdenticalTo([]); + } $this->deletePaymentType(); } diff --git a/tests/Galette/Entity/tests/units/PdfModel.php b/tests/Galette/Entity/tests/units/PdfModel.php index 17fe39cec..42d03d1ff 100644 --- a/tests/Galette/Entity/tests/units/PdfModel.php +++ b/tests/Galette/Entity/tests/units/PdfModel.php @@ -61,13 +61,13 @@ class PdfModel extends GaletteTestCase /** * Set up tests * - * @param string $testMethod Calling method + * @param string $method Calling method * * @return void */ - public function beforeTestMethod($testMethod) + public function beforeTestMethod($method) { - parent::beforeTestMethod($testMethod); + parent::beforeTestMethod($method); $models = new \Galette\Repository\PdfModels($this->zdb, $this->preferences, $this->login); $res = $models->installInit(false); @@ -85,12 +85,14 @@ class PdfModel extends GaletteTestCase /** * Tear down tests * - * @param string $testMethod Calling method + * @param string $method Calling method * * @return void */ - public function afterTestMethod($testMethod) + public function afterTestMethod($method) { + parent::afterTestMethod($method); + $delete = $this->zdb->delete(\Galette\Entity\Contribution::TABLE); $delete->where(['info_cotis' => 'FAKER' . $this->seed]); $this->zdb->execute($delete); diff --git a/tests/Galette/Entity/tests/units/SavedSeach.php b/tests/Galette/Entity/tests/units/SavedSeach.php index 317e66825..22ea8e465 100644 --- a/tests/Galette/Entity/tests/units/SavedSeach.php +++ b/tests/Galette/Entity/tests/units/SavedSeach.php @@ -61,11 +61,11 @@ class SavedSearch extends atoum /** * Set up tests * - * @param string $testMethod Calling method + * @param string $method Calling method * * @return void */ - public function beforeTestMethod($testMethod) + public function beforeTestMethod($method) { $this->zdb = new \Galette\Core\Db(); $this->i18n = new \Galette\Core\I18n(); @@ -79,12 +79,15 @@ class SavedSearch extends atoum /** * Tear down tests * - * @param string $testMethod Calling method + * @param string $method Calling method * * @return void */ - public function afterTestMethod($testMethod) + public function afterTestMethod($method) { + if (TYPE_DB === 'mysql') { + $this->array($this->zdb->getWarnings())->isIdenticalTo([]); + } $this->deleteCreated(); } diff --git a/tests/Galette/Entity/tests/units/Status.php b/tests/Galette/Entity/tests/units/Status.php index 8f5c4045d..ead4c896e 100644 --- a/tests/Galette/Entity/tests/units/Status.php +++ b/tests/Galette/Entity/tests/units/Status.php @@ -61,11 +61,11 @@ class Status extends atoum /** * Set up tests * - * @param string $testMethod Calling method + * @param string $method Calling method * * @return void */ - public function beforeTestMethod($testMethod) + public function beforeTestMethod($method) { $this->zdb = new \Galette\Core\Db(); $this->i18n = new \Galette\Core\I18n( @@ -76,12 +76,15 @@ class Status extends atoum /** * Tear down tests * - * @param string $testMethod Calling method + * @param string $method Calling method * * @return void */ - public function afterTestMethod($testMethod) + public function afterTestMethod($method) { + if (TYPE_DB === 'mysql') { + $this->array($this->zdb->getWarnings())->isIdenticalTo([]); + } $this->deleteStatus(); } diff --git a/tests/Galette/Entity/tests/units/Title.php b/tests/Galette/Entity/tests/units/Title.php index 91c4bed08..9a79f738a 100644 --- a/tests/Galette/Entity/tests/units/Title.php +++ b/tests/Galette/Entity/tests/units/Title.php @@ -60,11 +60,11 @@ class Title extends atoum /** * Set up tests * - * @param string $testMethod Calling method + * @param string $method Calling method * * @return void */ - public function beforeTestMethod($testMethod) + public function beforeTestMethod($method) { $this->zdb = new \Galette\Core\Db(); } @@ -72,12 +72,15 @@ class Title extends atoum /** * Tear down tests * - * @param string $testMethod Calling method + * @param string $method Calling method * * @return void */ - public function afterTestMethod($testMethod) + public function afterTestMethod($method) { + if (TYPE_DB === 'mysql') { + $this->array($this->zdb->getWarnings())->isIdenticalTo([]); + } $this->deleteTitle(); } diff --git a/tests/Galette/Entity/tests/units/Transaction.php b/tests/Galette/Entity/tests/units/Transaction.php index 7040657bf..0137a264d 100644 --- a/tests/Galette/Entity/tests/units/Transaction.php +++ b/tests/Galette/Entity/tests/units/Transaction.php @@ -65,6 +65,8 @@ class Transaction extends GaletteTestCase */ public function afterTestMethod($method) { + parent::afterTestMethod($method); + $this->zdb = new \Galette\Core\Db(); //first, remove contributions @@ -94,13 +96,13 @@ class Transaction extends GaletteTestCase /** * Set up tests * - * @param string $testMethod Calling method + * @param string $method Calling method * * @return void */ - public function beforeTestMethod($testMethod) + public function beforeTestMethod($method) { - parent::beforeTestMethod($testMethod); + parent::beforeTestMethod($method); $this->initContributionsTypes(); $this->contrib = new \Galette\Entity\Contribution($this->zdb, $this->login); diff --git a/tests/Galette/IO/tests/units/CsvIn.php b/tests/Galette/IO/tests/units/CsvIn.php index 2d09f17f3..254157542 100644 --- a/tests/Galette/IO/tests/units/CsvIn.php +++ b/tests/Galette/IO/tests/units/CsvIn.php @@ -61,25 +61,27 @@ class CsvIn extends GaletteTestCase /** * Set up tests * - * @param string $testMethod Calling method + * @param string $method Calling method * * @return void */ - public function beforeTestMethod($testMethod) + public function beforeTestMethod($method) { - parent::beforeTestMethod($testMethod); + parent::beforeTestMethod($method); $this->contents_table = null; } /** * Tear down tests * - * @param string $testMethod Calling method + * @param string $method Calling method * * @return void */ - public function afterTestMethod($testMethod) + public function afterTestMethod($method) { + parent::afterTestMethod($method); + $delete = $this->zdb->delete(\Galette\Entity\Adherent::TABLE); $this->zdb->execute($delete); $delete = $this->zdb->delete(\Galette\Entity\DynamicFieldsHandle::TABLE); diff --git a/tests/Galette/IO/tests/units/News.php b/tests/Galette/IO/tests/units/News.php index f225a4305..cfaf16dcf 100644 --- a/tests/Galette/IO/tests/units/News.php +++ b/tests/Galette/IO/tests/units/News.php @@ -58,11 +58,11 @@ class News extends atoum /** * Set up tests * - * @param string $testMethod Method name + * @param string $method Method name * * @return void */ - public function beforeTestMethod($testMethod) + public function beforeTestMethod($method) { $this->i18n = new \Galette\Core\I18n(); global $i18n; diff --git a/tests/Galette/Middleware/tests/unit/CheckAcls.php b/tests/Galette/Middleware/tests/unit/CheckAcls.php index 976847868..43657a200 100644 --- a/tests/Galette/Middleware/tests/unit/CheckAcls.php +++ b/tests/Galette/Middleware/tests/unit/CheckAcls.php @@ -58,11 +58,11 @@ class CheckAcls extends atoum /** * Set up tests * - * @param stgring $testMethod Method tested + * @param stgring $method Method tested * * @return void */ - public function beforeTestMethod($testMethod) + public function beforeTestMethod($method) { $app = new \Galette\Core\SlimApp(); require GALETTE_ROOT . 'includes/core_acls.php'; diff --git a/tests/Galette/Repository/tests/units/Members.php b/tests/Galette/Repository/tests/units/Members.php index 507597f8d..8f3c48955 100644 --- a/tests/Galette/Repository/tests/units/Members.php +++ b/tests/Galette/Repository/tests/units/Members.php @@ -59,25 +59,27 @@ class Members extends GaletteTestCase /** * Set up tests * - * @param string $testMethod Calling method + * @param string $method Calling method * * @return void */ - public function beforeTestMethod($testMethod) + public function beforeTestMethod($method) { - parent::beforeTestMethod($testMethod); + parent::beforeTestMethod($method); $this->createMembers(); } /** * Tear down tests * - * @param string $testMethod Calling method + * @param string $method Calling method * * @return void */ - public function afterTestMethod($testMethod) + public function afterTestMethod($method) { + parent::afterTestMethod($method); + $this->deleteGroups(); $this->deleteMembers(); } diff --git a/tests/Galette/Repository/tests/units/PaymentTypes.php b/tests/Galette/Repository/tests/units/PaymentTypes.php index a65877bb6..842766958 100644 --- a/tests/Galette/Repository/tests/units/PaymentTypes.php +++ b/tests/Galette/Repository/tests/units/PaymentTypes.php @@ -58,13 +58,13 @@ class PaymentTypes extends GaletteTestCase /** * Set up tests * - * @param string $testMethod Calling method + * @param string $method Calling method * * @return void */ - public function beforeTestMethod($testMethod) + public function beforeTestMethod($method) { - parent::beforeTestMethod($testMethod); + parent::beforeTestMethod($method); $types = new \Galette\Repository\PaymentTypes($this->zdb, $this->preferences, $this->login); $res = $types->installInit(false); @@ -74,12 +74,13 @@ class PaymentTypes extends GaletteTestCase /** * Tear down tests * - * @param string $testMethod Calling method + * @param string $method Calling method * * @return void */ - public function afterTestMethod($testMethod) + public function afterTestMethod($method) { + parent::afterTestMethod($method); $this->deletePaymentType(); } diff --git a/tests/Galette/Repository/tests/units/PdfModels.php b/tests/Galette/Repository/tests/units/PdfModels.php index f41966bbd..7dafc7ed4 100644 --- a/tests/Galette/Repository/tests/units/PdfModels.php +++ b/tests/Galette/Repository/tests/units/PdfModels.php @@ -58,13 +58,13 @@ class PdfModels extends GaletteTestCase /** * Set up tests * - * @param string $testMethod Calling method + * @param string $method Calling method * * @return void */ - public function beforeTestMethod($testMethod) + public function beforeTestMethod($method) { - parent::beforeTestMethod($testMethod); + parent::beforeTestMethod($method); $models = new \Galette\Repository\PdfModels($this->zdb, $this->preferences, $this->login); $res = $models->installInit(false); @@ -74,12 +74,13 @@ class PdfModels extends GaletteTestCase /** * Tear down tests * - * @param string $testMethod Calling method + * @param string $method Calling method * * @return void */ - public function afterTestMethod($testMethod) + public function afterTestMethod($method) { + parent::afterTestMethod($method); $this->deletePdfModels(); } diff --git a/tests/Galette/Repository/tests/units/Reminders.php b/tests/Galette/Repository/tests/units/Reminders.php index f003669b3..be1dd4ebf 100644 --- a/tests/Galette/Repository/tests/units/Reminders.php +++ b/tests/Galette/Repository/tests/units/Reminders.php @@ -60,13 +60,13 @@ class Reminders extends GaletteTestCase /** * Set up tests * - * @param string $testMethod Calling method + * @param string $method Calling method * * @return void */ - public function beforeTestMethod($testMethod) + public function beforeTestMethod($method) { - parent::beforeTestMethod($testMethod); + parent::beforeTestMethod($method); $this->initStatus(); $this->initContributionsTypes(); @@ -83,12 +83,13 @@ class Reminders extends GaletteTestCase /** * Tear down tests * - * @param string $testMethod Calling method + * @param string $method Calling method * * @return void */ - public function afterTestMethod($testMethod) + public function afterTestMethod($method) { + parent::afterTestMethod($method); $this->cleanContributions(); $delete = $this->zdb->delete(\Galette\Entity\Adherent::TABLE); diff --git a/tests/Galette/Util/tests/units/Password.php b/tests/Galette/Util/tests/units/Password.php index c8eea2e32..5ceabf4ee 100644 --- a/tests/Galette/Util/tests/units/Password.php +++ b/tests/Galette/Util/tests/units/Password.php @@ -65,6 +65,9 @@ class Password extends atoum */ public function afterTestMethod($method) { + if (TYPE_DB === 'mysql') { + $this->array($this->zdb->getWarnings())->isIdenticalTo([]); + } $this->preferences->pref_password_strength = Preferences::PWD_NONE; $this->preferences->pref_password_length = 6; $this->preferences->pref_password_blacklist = false; @@ -74,11 +77,11 @@ class Password extends atoum /** * Set up tests * - * @param string $testMethod Method tested + * @param string $method Method tested * * @return void */ - public function beforeTestMethod($testMethod) + public function beforeTestMethod($method) { $this->zdb = new \Galette\Core\Db(); $this->preferences = new \Galette\Core\Preferences($this->zdb); diff --git a/tests/Galette/Util/tests/units/Telemetry.php b/tests/Galette/Util/tests/units/Telemetry.php index 3b5018813..19d23993d 100644 --- a/tests/Galette/Util/tests/units/Telemetry.php +++ b/tests/Galette/Util/tests/units/Telemetry.php @@ -66,6 +66,10 @@ class Telemetry extends atoum */ public function afterTestMethod($method) { + if (TYPE_DB === 'mysql') { + $this->array($this->zdb->getWarnings())->isIdenticalTo([]); + } + $this->preferences->pref_instance_uuid = ''; $this->preferences->pref_registration_uuid = ''; $this->preferences->store(); @@ -74,11 +78,11 @@ class Telemetry extends atoum /** * Set up tests * - * @param string $testMethod Method tested + * @param string $method Method tested * * @return void */ - public function beforeTestMethod($testMethod) + public function beforeTestMethod($method) { $this->zdb = new \Galette\Core\Db(); $this->preferences = new \Galette\Core\Preferences($this->zdb); diff --git a/tests/GaletteTestCase.php b/tests/GaletteTestCase.php index e103ebb15..6497ef888 100644 --- a/tests/GaletteTestCase.php +++ b/tests/GaletteTestCase.php @@ -90,15 +90,16 @@ abstract class GaletteTestCase extends atoum protected $request; protected $response; protected $seed; + protected $excluded_after_methods = []; /** * Set up tests * - * @param stgring $testMethod Method tested + * @param stgring $method Method tested * * @return void */ - public function beforeTestMethod($testMethod) + public function beforeTestMethod($method) { $this->mocked_router = new \mock\Slim\Router(); $this->calling($this->mocked_router)->pathFor = function ($name, $params) { @@ -140,6 +141,20 @@ abstract class GaletteTestCase extends atoum $galette_log_var = $this->logger_storage; } + /** + * Tear down tests + * + * @param string $method Calling method + * + * @return void + */ + public function afterTestMethod($method) + { + if (TYPE_DB === 'mysql' && !in_array($method, $this->excluded_after_methods)) { + $this->array($this->zdb->getWarnings())->isIdenticalTo([]); + } + } + /** * Loads member from a resultset * diff --git a/tests/GaletteUpdate/Core/tests/units/Install.php b/tests/GaletteUpdate/Core/tests/units/Install.php index b07c7e131..4ee9408f4 100644 --- a/tests/GaletteUpdate/Core/tests/units/Install.php +++ b/tests/GaletteUpdate/Core/tests/units/Install.php @@ -63,11 +63,11 @@ class Install extends atoum /** * Set up tests * - * @param stgring $testMethod Method tested + * @param stgring $method Method tested * * @return void */ - public function beforeTestMethod($testMethod) + public function beforeTestMethod($method) { setlocale(LC_ALL, 'en_US'); @@ -95,6 +95,20 @@ class Install extends atoum $this->zdb = $container->get('zdb'); } + /** + * Tear down tests + * + * @param string $method Calling method + * + * @return void + */ + public function afterTestMethod($method) + { + if (TYPE_DB === 'mysql') { + $this->array($this->zdb->getWarnings())->isIdenticalTo([]); + } + } + /** * Test updates * -- 2.39.2