From 8156b555d1fc8964f3101b4ab80f707f957156a1 Mon Sep 17 00:00:00 2001 From: Shobi P P Date: Sun, 19 Apr 2020 19:36:19 +0300 Subject: [PATCH 1/7] autoload test classes so that we don't need to require files manually --- composer.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/composer.json b/composer.json index 4628c039..ba2b52b1 100644 --- a/composer.json +++ b/composer.json @@ -20,6 +20,11 @@ "MeiliSearch\\": "src/" } }, + "autoload-dev": { + "psr-4": { + "Tests\\": "tests/" + } + }, "require-dev": { "phpunit/phpunit": "^8.5", "friendsofphp/php-cs-fixer": "^2.16" From ded12a42172189a997651ad45590979fbdb103b3 Mon Sep 17 00:00:00 2001 From: Shobi P P Date: Sun, 19 Apr 2020 19:43:30 +0300 Subject: [PATCH 2/7] added phpunit.xml to bootstrap tests, so single phpunit command would automatically bootstrap the application and start running tests on `tests/` directory --- phpunit.xml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 phpunit.xml diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 00000000..6e77a94b --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,9 @@ + + + + + ./tests + + + \ No newline at end of file From 88119ff2cbe4de3834101f895156897574abe82e Mon Sep 17 00:00:00 2001 From: Shobi P P Date: Sun, 19 Apr 2020 19:45:26 +0300 Subject: [PATCH 3/7] add additional flags to make sure the notices and warnings are converted to exceptions --- phpunit.xml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/phpunit.xml b/phpunit.xml index 6e77a94b..5cf89a47 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,6 +1,10 @@ + convertErrorsToExceptions="true" + convertNoticesToExceptions="true" + convertWarningsToExceptions="true" + stopOnFailure="false" + colors="true"> ./tests From 7080ba501f7345fc739dd51c8b4b1772c6cbd579 Mon Sep 17 00:00:00 2001 From: Shobi P P Date: Sun, 19 Apr 2020 19:48:53 +0300 Subject: [PATCH 4/7] prevent phpunit cache being generated --- phpunit.xml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/phpunit.xml b/phpunit.xml index 5cf89a47..bd4bddc6 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,10 +1,11 @@ + convertErrorsToExceptions="true" + convertNoticesToExceptions="true" + convertWarningsToExceptions="true" + stopOnFailure="false" + cacheResult="false" + colors="true"> ./tests From 5460efc217495279323e0d0a224f0c7579ae3ce7 Mon Sep 17 00:00:00 2001 From: Shobi P P Date: Sun, 19 Apr 2020 20:39:26 +0300 Subject: [PATCH 5/7] autoload the utils.php file in order to avoid including the file every now and then --- composer.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index ba2b52b1..d6f0a07e 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,10 @@ "autoload-dev": { "psr-4": { "Tests\\": "tests/" - } + }, + "files": [ + "tests/utils.php" + ] }, "require-dev": { "phpunit/phpunit": "^8.5", From ae9a9f89ed2e54d5d72f28bfd62be1e3bb3af8a0 Mon Sep 17 00:00:00 2001 From: Shobi P P Date: Sun, 19 Apr 2020 20:40:49 +0300 Subject: [PATCH 6/7] remove all file inclusions since the file is auto-loaded already --- tests/ClientTest.php | 6 ++---- tests/DocumentsTest.php | 2 -- tests/IndexTest.php | 2 -- tests/KeysAndPermissionsTest.php | 2 -- tests/SearchTest.php | 2 -- tests/Settings/AcceptNewFieldsTest.php | 3 --- tests/Settings/DisplayedAttributesTest.php | 3 --- tests/Settings/DistinctAttributeTest.php | 4 ---- tests/Settings/RankingRulesTest.php | 4 ---- tests/Settings/SearchableAttributesTest.php | 4 ---- tests/Settings/SettingsTest.php | 4 ---- tests/Settings/StopWordsTest.php | 4 ---- tests/Settings/SynonymsTest.php | 4 ---- tests/UpdatesTest.php | 2 -- tests/utils.php | 2 +- 15 files changed, 3 insertions(+), 45 deletions(-) diff --git a/tests/ClientTest.php b/tests/ClientTest.php index fc8ac15c..168cb46d 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -1,11 +1,9 @@ deleteIndex($index['uid']); } -} +} \ No newline at end of file From 244d082015f659f9c62e22c6cc6cd7ce24145f60 Mon Sep 17 00:00:00 2001 From: Shobi P P Date: Sun, 19 Apr 2020 20:47:54 +0300 Subject: [PATCH 7/7] lint files --- tests/ClientTest.php | 4 ++-- tests/Settings/DistinctAttributeTest.php | 1 + tests/Settings/RankingRulesTest.php | 1 + tests/Settings/SearchableAttributesTest.php | 1 + tests/Settings/SettingsTest.php | 1 + tests/Settings/StopWordsTest.php | 1 + tests/Settings/SynonymsTest.php | 1 + tests/utils.php | 2 +- 8 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/ClientTest.php b/tests/ClientTest.php index 168cb46d..be69a8c1 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -1,9 +1,9 @@ deleteIndex($index['uid']); } -} \ No newline at end of file +}