From 812336bc37b686dc0968b4ddd9d2783744834b44 Mon Sep 17 00:00:00 2001 From: lifesign Date: Mon, 10 Jul 2017 15:07:27 +0800 Subject: [PATCH] fix windows environment check not work on mac --- src/ConfigPath.php | 4 ++-- tests/ConfigPathTest.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ConfigPath.php b/src/ConfigPath.php index 26e3cc0..142bc2a 100644 --- a/src/ConfigPath.php +++ b/src/ConfigPath.php @@ -43,7 +43,7 @@ public static function getHomeConfigDir() */ public static function isWindows() { - return stripos(PHP_OS, 'win') !== false; + return DIRECTORY_SEPARATOR == '\\'; } /** @@ -63,4 +63,4 @@ public static function getUserConfigFile() { return static::getHomeConfigDir() . '/crm.json'; } -} \ No newline at end of file +} diff --git a/tests/ConfigPathTest.php b/tests/ConfigPathTest.php index 6be9f43..caa19cd 100644 --- a/tests/ConfigPathTest.php +++ b/tests/ConfigPathTest.php @@ -8,11 +8,11 @@ class ConfigPathTest extends TestCase { public function testHomeConfigDir() { - $this->assertTrue((boolean)preg_match('/win/i', PHP_OS) === ConfigPath::isWindows()); + $this->assertTrue((boolean)(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') === ConfigPath::isWindows()); } public function testDefaultConfigFile() { $this->assertFileExists(ConfigPath::getDefaultConfigFile()); } -} \ No newline at end of file +}