diff options
author | n-peugnet <n.peugnet@free.fr> | 2020-05-11 14:25:39 +0200 |
---|---|---|
committer | n-peugnet <n.peugnet@free.fr> | 2020-05-11 16:10:08 +0200 |
commit | e8b0993f7054299e61af1ab501aaca46285b0caa (patch) | |
tree | fbe8798f1dce5952eb5a3d542534603989ca35fe | |
parent | 28fb122f56df0cb034013740dd30aaaf5ce9059e (diff) | |
download | wcms-e8b0993f7054299e61af1ab501aaca46285b0caa.tar.gz wcms-e8b0993f7054299e61af1ab501aaca46285b0caa.zip |
fix: tests for Windows
-rw-r--r-- | Makefile | 5 | ||||
-rw-r--r-- | tests/FilesTest.php | 1 | ||||
-rw-r--r-- | tests/LoggerTest.php | 28 |
3 files changed, 20 insertions, 14 deletions
@@ -7,7 +7,10 @@ js_src_dir := src # Misc variables. PATH := vendor/bin:node_modules/.bin:$(PATH) -SHELL := PATH=$(PATH) /bin/bash + +ifneq ($(OS),Windows_NT) # Not for Windows + SHELL := PATH=$(PATH) /bin/bash +endif override GIT_VERSION := $(shell git --no-pager describe --always --tags) override CUR_VERSION := $(strip $(shell cat VERSION 2>/dev/null)) override WEBPACK_FLAGS += $(if $(filter $(ENV),dist),-p) diff --git a/tests/FilesTest.php b/tests/FilesTest.php index 7ab66fe..83a32d6 100644 --- a/tests/FilesTest.php +++ b/tests/FilesTest.php @@ -12,6 +12,7 @@ use PHPUnit\Framework\TestCase; */ abstract class FilesTest extends TestCase { + protected $ds = DIRECTORY_SEPARATOR; protected $testdir = 'build/test'; protected $notwritabledir = 'build/test/notwritabledir'; protected $notwritablefile = 'build/test/notwritablefile'; diff --git a/tests/LoggerTest.php b/tests/LoggerTest.php index 5536864..c383003 100644 --- a/tests/LoggerTest.php +++ b/tests/LoggerTest.php @@ -48,6 +48,7 @@ class LoggerTest extends FilesTest /** * @test + * @requires OSFAMILY Linux */ public function initDirNotWritableTest(): void { @@ -100,7 +101,7 @@ class LoggerTest extends FilesTest { Logger::init($this->logfile, $verbosity); Logger::error($msg, ...$args); - $expected = " [ ERROR ] tests/LoggerTest.php(102) $expected\n"; + $expected = " [ ERROR ] tests{$this->ds}LoggerTest.php(103) $expected\n"; $this->assertEquals($expected, substr(file_get_contents($this->logfile), 25)); } @@ -138,7 +139,7 @@ class LoggerTest extends FilesTest { Logger::init($this->logfile, $verbosity); Logger::warning($msg, ...$args); - $expected = " [ WARN ] tests/LoggerTest.php(140) $expected\n"; + $expected = " [ WARN ] tests{$this->ds}LoggerTest.php(141) $expected\n"; $this->assertEquals($expected, substr(file_get_contents($this->logfile), 25)); } @@ -175,7 +176,7 @@ class LoggerTest extends FilesTest { Logger::init($this->logfile, $verbosity); Logger::info($msg, ...$args); - $expected = " [ INFO ] tests/LoggerTest.php(177) $expected\n"; + $expected = " [ INFO ] tests{$this->ds}LoggerTest.php(178) $expected\n"; $this->assertEquals($expected, substr(file_get_contents($this->logfile), 25)); } @@ -211,7 +212,7 @@ class LoggerTest extends FilesTest { Logger::init($this->logfile, $verbosity); Logger::debug($msg, ...$args); - $expected = " [ DEBUG ] tests/LoggerTest.php(213) $expected\n"; + $expected = " [ DEBUG ] tests{$this->ds}LoggerTest.php(214) $expected\n"; $this->assertEquals($expected, substr(file_get_contents($this->logfile), 25)); } @@ -247,8 +248,8 @@ class LoggerTest extends FilesTest Logger::init($this->logfile, $verbosity); Logger::errorex($e); $file = __FILE__; - $line += 258; - $expected = " [ ERROR ] tests/LoggerTest.php(248) $expected in $file($line)\n"; + $line += 259; + $expected = " [ ERROR ] tests{$this->ds}LoggerTest.php(249) $expected in $file($line)\n"; $this->assertEquals($expected, substr(file_get_contents($this->logfile), 25)); } @@ -264,13 +265,14 @@ class LoggerTest extends FilesTest /** * @test + * @requires OSFAMILY Linux */ public function errorexBacktraceTest(): void { Logger::init($this->logfile, 1); Logger::errorex(new Exception('Error'), true); $content = file_get_contents($this->logfile); - $expected = " [ ERROR ] tests/LoggerTest.php(271) Error "; + $expected = " [ ERROR ] tests{$this->ds}LoggerTest.php(273) Error "; $this->assertEquals($expected, substr($content, 25, 43)); $this->assertRegExp('/(#\d+ [\w\/\.]*\(\d+\): .*\)\n)+#\d+ \{main\}\n/U', $content); } @@ -300,8 +302,8 @@ class LoggerTest extends FilesTest Logger::init($this->logfile, $verbosity); Logger::warningex($e); $file = __FILE__; - $line += 311; - $expected = " [ WARN ] tests/LoggerTest.php(301) $expected in $file($line)\n"; + $line += 313; + $expected = " [ WARN ] tests{$this->ds}LoggerTest.php(303) $expected in $file($line)\n"; $this->assertEquals($expected, substr(file_get_contents($this->logfile), 25)); } @@ -339,8 +341,8 @@ class LoggerTest extends FilesTest Logger::init($this->logfile, $verbosity); Logger::infoex($e); $file = __FILE__; - $line += 350; - $expected = " [ INFO ] tests/LoggerTest.php(340) $expected in $file($line)\n"; + $line += 352; + $expected = " [ INFO ] tests{$this->ds}LoggerTest.php(342) $expected in $file($line)\n"; $this->assertEquals($expected, substr(file_get_contents($this->logfile), 25)); } @@ -377,8 +379,8 @@ class LoggerTest extends FilesTest Logger::init($this->logfile, $verbosity); Logger::debugex($e); $file = __FILE__; - $line += 388; - $expected = " [ DEBUG ] tests/LoggerTest.php(378) $expected in $file($line)\n"; + $line += 390; + $expected = " [ DEBUG ] tests{$this->ds}LoggerTest.php(380) $expected in $file($line)\n"; $this->assertEquals($expected, substr(file_get_contents($this->logfile), 25)); } |