From e35141f86529b85b3c6ebee20d7479880d58ff7d Mon Sep 17 00:00:00 2001 From: Simon Gabriel Date: Tue, 13 Feb 2018 15:51:16 +0100 Subject: [PATCH 01/11] [feature] (PHPLIB-27) Autoload: Added autoloader and test. --- Autoloader.php | 40 +++++++++++++++++ tests/unit/AutoloaderTest.php | 85 +++++++++++++++++++++++++++++++++++ 2 files changed, 125 insertions(+) create mode 100755 Autoloader.php create mode 100755 tests/unit/AutoloaderTest.php diff --git a/Autoloader.php b/Autoloader.php new file mode 100755 index 0000000..ce9d9bb --- /dev/null +++ b/Autoloader.php @@ -0,0 +1,40 @@ + + * + * @package Heidelpay + * @subpackage PhpStorm + * @category ${CATEGORY} + */ + +class Autoloader +{ + const BASE_PATH = __DIR__.DIRECTORY_SEPARATOR. 'lib'; + + /** + * Loads all php files in lib directory. + * + * @param string $dir + */ + public static function requireAllPhpOnce($dir = self::BASE_PATH) + { + /** @var array $files */ + $files = glob("$dir/*"); + foreach ($files as $file) { + if (preg_match('/\.php$/', $file)) { + require_once $file; + } elseif (is_dir($file)) { + self::requireAllPhpOnce($file); + } + } + } +} \ No newline at end of file diff --git a/tests/unit/AutoloaderTest.php b/tests/unit/AutoloaderTest.php new file mode 100755 index 0000000..8b659c0 --- /dev/null +++ b/tests/unit/AutoloaderTest.php @@ -0,0 +1,85 @@ + + * + * @package Heidelpay + * @subpackage PhpStorm + * @category ${CATEGORY} + */ +namespace Tests\Unit; + +use Autoloader as MessageMapperAutoloader; + +require __DIR__ . '\..\..\Autoloader.php'; + +class AutoloaderTest extends \PHPUnit_Framework_TestCase +{ + /** + * Test that autoloader includes all required classes. + * + * @test + */ + public function autoloaderShouldProduceAnErrorWhenTheFilesAreNotLoaded() + { + $path = realpath(__DIR__. '\\..\\..\\lib\\'); + $regex = '/^' . str_replace('\\', '\\\\', $path) . '\\\\.*\.php$/'; + $filesIncludedBefore = preg_grep($regex, get_included_files()); + + $autoloader = new MessageMapperAutoloader(); + $autoloader::requireAllPhpOnce(); + $filesIncludedAfter = preg_grep($regex, get_included_files()); + + $phpFilesInLib = $this->getPhpFilesInLib($path); + + foreach ($phpFilesInLib as $item) { + $this->assertArrayNotHasKey($item, array_flip($filesIncludedBefore)); + $this->assertArrayHasKey($item, array_flip($filesIncludedAfter)); + } + } + + private function getPhpFilesInLib($path) + { + $files = []; + + + if (!is_dir($path)) { + return $files; + } + + $items = scandir($path, SCANDIR_SORT_NONE); + + $fileArrays = []; + + foreach ($items as $item) { + if ($item === '.' || $item === '..') { + continue; + } + + $itemPath = $path . '\\' . $item; + $files = []; + if (is_dir($itemPath)) { + $files = $this->getPhpFilesInLib($itemPath); + } else { + if (pathinfo($itemPath)['extension'] === 'php') { + $files = [$itemPath]; + } + } + $fileArrays[] = $files; + } + + return array_merge(...$fileArrays); + } + + + + +} From 933057e6cc453744790ce2d5ec9346745731706f Mon Sep 17 00:00:00 2001 From: Simon Gabriel Date: Tue, 13 Feb 2018 16:23:42 +0100 Subject: [PATCH 02/11] [refactor] (PHPLIB-27) Autoload: Refactored autoloader and test. --- Autoloader.php | 4 ++-- tests/unit/AutoloaderTest.php | 27 ++++++++++++--------------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/Autoloader.php b/Autoloader.php index ce9d9bb..a2036ee 100755 --- a/Autoloader.php +++ b/Autoloader.php @@ -25,7 +25,7 @@ class Autoloader * * @param string $dir */ - public static function requireAllPhpOnce($dir = self::BASE_PATH) + public static function requireAllLibs($dir = self::BASE_PATH) { /** @var array $files */ $files = glob("$dir/*"); @@ -33,7 +33,7 @@ public static function requireAllPhpOnce($dir = self::BASE_PATH) if (preg_match('/\.php$/', $file)) { require_once $file; } elseif (is_dir($file)) { - self::requireAllPhpOnce($file); + self::requireAllLibs($file); } } } diff --git a/tests/unit/AutoloaderTest.php b/tests/unit/AutoloaderTest.php index 8b659c0..823b25f 100755 --- a/tests/unit/AutoloaderTest.php +++ b/tests/unit/AutoloaderTest.php @@ -35,7 +35,7 @@ public function autoloaderShouldProduceAnErrorWhenTheFilesAreNotLoaded() $filesIncludedBefore = preg_grep($regex, get_included_files()); $autoloader = new MessageMapperAutoloader(); - $autoloader::requireAllPhpOnce(); + $autoloader::requireAllLibs(); $filesIncludedAfter = preg_grep($regex, get_included_files()); $phpFilesInLib = $this->getPhpFilesInLib($path); @@ -48,38 +48,35 @@ public function autoloaderShouldProduceAnErrorWhenTheFilesAreNotLoaded() private function getPhpFilesInLib($path) { - $files = []; - - if (!is_dir($path)) { - return $files; + return []; } - $items = scandir($path, SCANDIR_SORT_NONE); - $fileArrays = []; + // iterate through all items in the given path + $items = scandir($path, SCANDIR_SORT_DESCENDING); + $files = []; + $fileArrays = []; foreach ($items as $item) { + // leave current and previous path out if ($item === '.' || $item === '..') { continue; } + // prepare complete path of the current item $itemPath = $path . '\\' . $item; - $files = []; if (is_dir($itemPath)) { - $files = $this->getPhpFilesInLib($itemPath); + // scan subdirectories as well + $fileArrays[] = $this->getPhpFilesInLib($itemPath); } else { if (pathinfo($itemPath)['extension'] === 'php') { - $files = [$itemPath]; + $files[] = $itemPath; } } - $fileArrays[] = $files; } + $fileArrays[] = $files; return array_merge(...$fileArrays); } - - - - } From 15b35e3f7412233ef927233e32298058425ef057 Mon Sep 17 00:00:00 2001 From: Simon Gabriel Date: Wed, 14 Feb 2018 10:28:30 +0100 Subject: [PATCH 03/11] [refactor] (PHPLIB-27) Renamed Autoloader to FileLoader since it is now loading ALL php-files. --- Autoloader.php => FileLoader.php | 2 +- .../unit/{AutoloaderTest.php => FileLoaderTest.php} | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) rename Autoloader.php => FileLoader.php (98%) rename tests/unit/{AutoloaderTest.php => FileLoaderTest.php} (86%) diff --git a/Autoloader.php b/FileLoader.php similarity index 98% rename from Autoloader.php rename to FileLoader.php index a2036ee..4a7332d 100755 --- a/Autoloader.php +++ b/FileLoader.php @@ -16,7 +16,7 @@ * @category ${CATEGORY} */ -class Autoloader +class FileLoader { const BASE_PATH = __DIR__.DIRECTORY_SEPARATOR. 'lib'; diff --git a/tests/unit/AutoloaderTest.php b/tests/unit/FileLoaderTest.php similarity index 86% rename from tests/unit/AutoloaderTest.php rename to tests/unit/FileLoaderTest.php index 823b25f..16e311b 100755 --- a/tests/unit/AutoloaderTest.php +++ b/tests/unit/FileLoaderTest.php @@ -17,24 +17,24 @@ */ namespace Tests\Unit; -use Autoloader as MessageMapperAutoloader; +use FileLoader as MessageMapperFileLoader; -require __DIR__ . '\..\..\Autoloader.php'; +require __DIR__ . '\..\..\FileLoader.php'; -class AutoloaderTest extends \PHPUnit_Framework_TestCase +class FileLoaderTest extends \PHPUnit_Framework_TestCase { /** - * Test that autoloader includes all required classes. + * Test that file loader includes all php files. * * @test */ - public function autoloaderShouldProduceAnErrorWhenTheFilesAreNotLoaded() + public function autoloaderShouldLoadAllPhpFilesInLibDirectory() { $path = realpath(__DIR__. '\\..\\..\\lib\\'); $regex = '/^' . str_replace('\\', '\\\\', $path) . '\\\\.*\.php$/'; $filesIncludedBefore = preg_grep($regex, get_included_files()); - $autoloader = new MessageMapperAutoloader(); + $autoloader = new MessageMapperFileLoader(); $autoloader::requireAllLibs(); $filesIncludedAfter = preg_grep($regex, get_included_files()); @@ -52,7 +52,6 @@ private function getPhpFilesInLib($path) return []; } - // iterate through all items in the given path $items = scandir($path, SCANDIR_SORT_DESCENDING); From 50b2108684f5e4833a62a091bd016c7387009cf6 Mon Sep 17 00:00:00 2001 From: Simon Gabriel Date: Wed, 14 Feb 2018 10:44:09 +0100 Subject: [PATCH 04/11] [bugfix] (PHPLIB-27) Fixed path to FileLoader class in test. --- tests/unit/FileLoaderTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/unit/FileLoaderTest.php b/tests/unit/FileLoaderTest.php index 16e311b..fa58abe 100755 --- a/tests/unit/FileLoaderTest.php +++ b/tests/unit/FileLoaderTest.php @@ -19,7 +19,8 @@ use FileLoader as MessageMapperFileLoader; -require __DIR__ . '\..\..\FileLoader.php'; +/** @noinspection PhpIncludeInspection */ +require realpath(__DIR__ . '/../../FileLoader.php'); class FileLoaderTest extends \PHPUnit_Framework_TestCase { From 204edfb32c3d2d3a156f4f4914d4e8dd512a1ac8 Mon Sep 17 00:00:00 2001 From: Simon Gabriel Date: Fri, 23 Feb 2018 10:53:29 +0100 Subject: [PATCH 05/11] [change] (PHPLIB-28) Add FileLoader to PhpUnit whitelist and make sure files are loaded at all. --- phpunit.xml.dist | 1 + tests/unit/FileLoaderTest.php | 5 +++++ 2 files changed, 6 insertions(+) mode change 100644 => 100755 phpunit.xml.dist diff --git a/phpunit.xml.dist b/phpunit.xml.dist old mode 100644 new mode 100755 index 5d54a39..6a864fc --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -19,6 +19,7 @@ ./lib/ + ./FileLoader.php \ No newline at end of file diff --git a/tests/unit/FileLoaderTest.php b/tests/unit/FileLoaderTest.php index fa58abe..bcc67fb 100755 --- a/tests/unit/FileLoaderTest.php +++ b/tests/unit/FileLoaderTest.php @@ -41,6 +41,11 @@ public function autoloaderShouldLoadAllPhpFilesInLibDirectory() $phpFilesInLib = $this->getPhpFilesInLib($path); + fwrite(STDOUT, 'Loaded Files before: ' . print_r($filesIncludedBefore, 1)); + fwrite(STDOUT, 'Loaded Files after: ' . print_r($filesIncludedAfter, 1)); + + $this->assertGreaterThan(0, 1, 'Error: There are no files loaded at all!'); + foreach ($phpFilesInLib as $item) { $this->assertArrayNotHasKey($item, array_flip($filesIncludedBefore)); $this->assertArrayHasKey($item, array_flip($filesIncludedAfter)); From 250aadfc8ca7580a98c841b590cb11ef4f5f6056 Mon Sep 17 00:00:00 2001 From: Simon Gabriel Date: Fri, 23 Feb 2018 10:54:08 +0100 Subject: [PATCH 06/11] [cleanup] (PHPLIB-29) Fixed several issues. --- composer.json | 4 ++++ lib/Helpers/FileSystem.php | 4 ++-- tests/unit/MessageCodeMapperTest.php | 6 ++++++ 3 files changed, 12 insertions(+), 2 deletions(-) mode change 100644 => 100755 composer.json mode change 100644 => 100755 lib/Helpers/FileSystem.php mode change 100644 => 100755 tests/unit/MessageCodeMapperTest.php diff --git a/composer.json b/composer.json old mode 100644 new mode 100755 index efad51d..b8c64cc --- a/composer.json +++ b/composer.json @@ -8,6 +8,10 @@ { "name": "Stephano Vogel", "email": "development@heidelpay.de" + }, + { + "name": "Simon Gabriel", + "email": "development@heidelpay.de" } ], "support" : { diff --git a/lib/Helpers/FileSystem.php b/lib/Helpers/FileSystem.php old mode 100644 new mode 100755 index 94a9801..2b962ef --- a/lib/Helpers/FileSystem.php +++ b/lib/Helpers/FileSystem.php @@ -29,7 +29,7 @@ class FileSystem public function __construct($path) { // we just want to read files, so mode 'r' will be fine at all. - $this->handle = fopen($path, 'r'); + $this->handle = fopen($path, 'rb'); } /** @@ -56,7 +56,7 @@ public function getCsvContent() // an array with the error-code as key and the message as value. while ($content = fgetcsv($this->handle)) { // 0 = HPError-Code, 1 = Message - if (isset($content[0]) && isset($content[1])) { + if (isset($content[0], $content[1])) { $ret[$content[0]] = $content[1]; } } diff --git a/tests/unit/MessageCodeMapperTest.php b/tests/unit/MessageCodeMapperTest.php old mode 100644 new mode 100755 index d93e619..bcbece4 --- a/tests/unit/MessageCodeMapperTest.php +++ b/tests/unit/MessageCodeMapperTest.php @@ -26,6 +26,7 @@ class MessageCodeMapperTest extends TestCase * Unit test for the correct locale after object initialization. * * @test + * @throws MissingLocaleFileException */ public function displayCorrectLocale() { @@ -39,6 +40,7 @@ public function displayCorrectLocale() * string or not. * * @test + * @throws MissingLocaleFileException */ public function displayCorrectMessageOutputEn() { @@ -59,6 +61,7 @@ public function displayCorrectMessageOutputEn() * string or not. * * @test + * @throws MissingLocaleFileException */ public function displayCorrectMessageOutputDe() { @@ -79,6 +82,7 @@ public function displayCorrectMessageOutputDe() * is defined in the en_US locale file. * * @test + * @throws MissingLocaleFileException */ public function displayDefaultMessageOutputEn() { @@ -99,6 +103,7 @@ public function displayDefaultMessageOutputEn() * is defined in the de_DE locale file. * * @test + * @throws MissingLocaleFileException */ public function displayDefaultMessageOutputDe() { @@ -118,6 +123,7 @@ public function displayDefaultMessageOutputDe() * not present (e.g. because the selected language does not exist). * * @test + * @throws MissingLocaleFileException */ public function throwMissingLocaleFileException() { From 2a46519fdc1f0530df5c265f32065bf7fd504e8c Mon Sep 17 00:00:00 2001 From: Simon Gabriel Date: Fri, 23 Feb 2018 10:55:55 +0100 Subject: [PATCH 07/11] [cleanup] (PHPLIB-29) Fixed several issues. --- composer.json | 4 ++++ lib/Helpers/FileSystem.php | 4 ++-- tests/unit/FileLoaderTest.php | 2 +- tests/unit/MessageCodeMapperTest.php | 6 ++++++ 4 files changed, 13 insertions(+), 3 deletions(-) mode change 100644 => 100755 composer.json mode change 100644 => 100755 lib/Helpers/FileSystem.php mode change 100644 => 100755 tests/unit/MessageCodeMapperTest.php diff --git a/composer.json b/composer.json old mode 100644 new mode 100755 index efad51d..b8c64cc --- a/composer.json +++ b/composer.json @@ -8,6 +8,10 @@ { "name": "Stephano Vogel", "email": "development@heidelpay.de" + }, + { + "name": "Simon Gabriel", + "email": "development@heidelpay.de" } ], "support" : { diff --git a/lib/Helpers/FileSystem.php b/lib/Helpers/FileSystem.php old mode 100644 new mode 100755 index 94a9801..2b962ef --- a/lib/Helpers/FileSystem.php +++ b/lib/Helpers/FileSystem.php @@ -29,7 +29,7 @@ class FileSystem public function __construct($path) { // we just want to read files, so mode 'r' will be fine at all. - $this->handle = fopen($path, 'r'); + $this->handle = fopen($path, 'rb'); } /** @@ -56,7 +56,7 @@ public function getCsvContent() // an array with the error-code as key and the message as value. while ($content = fgetcsv($this->handle)) { // 0 = HPError-Code, 1 = Message - if (isset($content[0]) && isset($content[1])) { + if (isset($content[0], $content[1])) { $ret[$content[0]] = $content[1]; } } diff --git a/tests/unit/FileLoaderTest.php b/tests/unit/FileLoaderTest.php index bcc67fb..d4916ca 100755 --- a/tests/unit/FileLoaderTest.php +++ b/tests/unit/FileLoaderTest.php @@ -44,7 +44,7 @@ public function autoloaderShouldLoadAllPhpFilesInLibDirectory() fwrite(STDOUT, 'Loaded Files before: ' . print_r($filesIncludedBefore, 1)); fwrite(STDOUT, 'Loaded Files after: ' . print_r($filesIncludedAfter, 1)); - $this->assertGreaterThan(0, 1, 'Error: There are no files loaded at all!'); + $this->assertGreaterThan(0, 0, 'Error: There are no files loaded at all!'); foreach ($phpFilesInLib as $item) { $this->assertArrayNotHasKey($item, array_flip($filesIncludedBefore)); diff --git a/tests/unit/MessageCodeMapperTest.php b/tests/unit/MessageCodeMapperTest.php old mode 100644 new mode 100755 index d93e619..bcbece4 --- a/tests/unit/MessageCodeMapperTest.php +++ b/tests/unit/MessageCodeMapperTest.php @@ -26,6 +26,7 @@ class MessageCodeMapperTest extends TestCase * Unit test for the correct locale after object initialization. * * @test + * @throws MissingLocaleFileException */ public function displayCorrectLocale() { @@ -39,6 +40,7 @@ public function displayCorrectLocale() * string or not. * * @test + * @throws MissingLocaleFileException */ public function displayCorrectMessageOutputEn() { @@ -59,6 +61,7 @@ public function displayCorrectMessageOutputEn() * string or not. * * @test + * @throws MissingLocaleFileException */ public function displayCorrectMessageOutputDe() { @@ -79,6 +82,7 @@ public function displayCorrectMessageOutputDe() * is defined in the en_US locale file. * * @test + * @throws MissingLocaleFileException */ public function displayDefaultMessageOutputEn() { @@ -99,6 +103,7 @@ public function displayDefaultMessageOutputEn() * is defined in the de_DE locale file. * * @test + * @throws MissingLocaleFileException */ public function displayDefaultMessageOutputDe() { @@ -118,6 +123,7 @@ public function displayDefaultMessageOutputDe() * not present (e.g. because the selected language does not exist). * * @test + * @throws MissingLocaleFileException */ public function throwMissingLocaleFileException() { From 8a6eb500c7ae752b7441f4ba20fab454acedbbeb Mon Sep 17 00:00:00 2001 From: Simon Gabriel Date: Fri, 23 Feb 2018 10:57:27 +0100 Subject: [PATCH 08/11] [bugfix] (PHPLIB-28) Fix loaded file count assertion. --- tests/unit/FileLoaderTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/FileLoaderTest.php b/tests/unit/FileLoaderTest.php index d4916ca..bf889e7 100755 --- a/tests/unit/FileLoaderTest.php +++ b/tests/unit/FileLoaderTest.php @@ -44,7 +44,7 @@ public function autoloaderShouldLoadAllPhpFilesInLibDirectory() fwrite(STDOUT, 'Loaded Files before: ' . print_r($filesIncludedBefore, 1)); fwrite(STDOUT, 'Loaded Files after: ' . print_r($filesIncludedAfter, 1)); - $this->assertGreaterThan(0, 0, 'Error: There are no files loaded at all!'); + $this->assertGreaterThan(0, count($filesIncludedAfter), 'Error: There are no files loaded at all!'); foreach ($phpFilesInLib as $item) { $this->assertArrayNotHasKey($item, array_flip($filesIncludedBefore)); From 9ab76c1973d01dc0eb8dfb58664992f869048dc4 Mon Sep 17 00:00:00 2001 From: Simon Gabriel Date: Fri, 23 Feb 2018 10:59:17 +0100 Subject: [PATCH 09/11] [cleanup] (PHPLIB-29) Fixed code style issues. --- tests/unit/MessageCodeMapperTest.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/unit/MessageCodeMapperTest.php b/tests/unit/MessageCodeMapperTest.php index bcbece4..0feedd7 100755 --- a/tests/unit/MessageCodeMapperTest.php +++ b/tests/unit/MessageCodeMapperTest.php @@ -2,8 +2,8 @@ namespace Tests\Unit; -use Heidelpay\MessageCodeMapper\MessageCodeMapper; use Heidelpay\MessageCodeMapper\Exceptions\MissingLocaleFileException; +use Heidelpay\MessageCodeMapper\MessageCodeMapper; use PHPUnit\Framework\TestCase; /** @@ -26,6 +26,7 @@ class MessageCodeMapperTest extends TestCase * Unit test for the correct locale after object initialization. * * @test + * * @throws MissingLocaleFileException */ public function displayCorrectLocale() @@ -40,6 +41,7 @@ public function displayCorrectLocale() * string or not. * * @test + * * @throws MissingLocaleFileException */ public function displayCorrectMessageOutputEn() @@ -61,6 +63,7 @@ public function displayCorrectMessageOutputEn() * string or not. * * @test + * * @throws MissingLocaleFileException */ public function displayCorrectMessageOutputDe() @@ -82,6 +85,7 @@ public function displayCorrectMessageOutputDe() * is defined in the en_US locale file. * * @test + * * @throws MissingLocaleFileException */ public function displayDefaultMessageOutputEn() @@ -103,6 +107,7 @@ public function displayDefaultMessageOutputEn() * is defined in the de_DE locale file. * * @test + * * @throws MissingLocaleFileException */ public function displayDefaultMessageOutputDe() @@ -123,6 +128,7 @@ public function displayDefaultMessageOutputDe() * not present (e.g. because the selected language does not exist). * * @test + * * @throws MissingLocaleFileException */ public function throwMissingLocaleFileException() From 9755e013266773dface9561c742dd9cbcd135f89 Mon Sep 17 00:00:00 2001 From: Simon Gabriel Date: Fri, 23 Feb 2018 12:36:05 +0100 Subject: [PATCH 10/11] [bugfix] (PHPLIB-30) Fix FileLoaderTest to work on Windows and Linux OS. --- tests/unit/FileLoaderTest.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/unit/FileLoaderTest.php b/tests/unit/FileLoaderTest.php index bf889e7..e87a7ac 100755 --- a/tests/unit/FileLoaderTest.php +++ b/tests/unit/FileLoaderTest.php @@ -31,18 +31,19 @@ class FileLoaderTest extends \PHPUnit_Framework_TestCase */ public function autoloaderShouldLoadAllPhpFilesInLibDirectory() { - $path = realpath(__DIR__. '\\..\\..\\lib\\'); - $regex = '/^' . str_replace('\\', '\\\\', $path) . '\\\\.*\.php$/'; - $filesIncludedBefore = preg_grep($regex, get_included_files()); + $path = realpath(__DIR__. '/../../lib/'); + $regex = '/^' . str_replace(DIRECTORY_SEPARATOR, '\\' . DIRECTORY_SEPARATOR, $path) . '.*\.php$/'; - $autoloader = new MessageMapperFileLoader(); - $autoloader::requireAllLibs(); + $filesIncludedBefore = preg_grep($regex, get_included_files()); + MessageMapperFileLoader::requireAllLibs(); $filesIncludedAfter = preg_grep($regex, get_included_files()); + // files that should be loaded $phpFilesInLib = $this->getPhpFilesInLib($path); fwrite(STDOUT, 'Loaded Files before: ' . print_r($filesIncludedBefore, 1)); fwrite(STDOUT, 'Loaded Files after: ' . print_r($filesIncludedAfter, 1)); + fwrite(STDOUT, 'Files that should have been loaded: ' . print_r($phpFilesInLib, 1)); $this->assertGreaterThan(0, count($filesIncludedAfter), 'Error: There are no files loaded at all!'); @@ -70,12 +71,12 @@ private function getPhpFilesInLib($path) } // prepare complete path of the current item - $itemPath = $path . '\\' . $item; + $itemPath = $path . DIRECTORY_SEPARATOR . $item; if (is_dir($itemPath)) { // scan subdirectories as well $fileArrays[] = $this->getPhpFilesInLib($itemPath); } else { - if (pathinfo($itemPath)['extension'] === 'php') { + if (pathinfo($itemPath, PATHINFO_EXTENSION) === 'php') { $files[] = $itemPath; } } From 28ccacd30aae411463774b1ffa32a6617907b205 Mon Sep 17 00:00:00 2001 From: Simon Gabriel Date: Fri, 23 Feb 2018 12:46:58 +0100 Subject: [PATCH 11/11] [cleanup] (PHPLIB-29) Fixed a code style issue. --- tests/unit/FileLoaderTest.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/unit/FileLoaderTest.php b/tests/unit/FileLoaderTest.php index e87a7ac..5dc53ff 100755 --- a/tests/unit/FileLoaderTest.php +++ b/tests/unit/FileLoaderTest.php @@ -75,10 +75,11 @@ private function getPhpFilesInLib($path) if (is_dir($itemPath)) { // scan subdirectories as well $fileArrays[] = $this->getPhpFilesInLib($itemPath); - } else { - if (pathinfo($itemPath, PATHINFO_EXTENSION) === 'php') { - $files[] = $itemPath; - } + continue; + } + + if (pathinfo($itemPath, PATHINFO_EXTENSION) === 'php') { + $files[] = $itemPath; } } $fileArrays[] = $files;