diff --git a/.appveyor.yml b/.appveyor.yml new file mode 100644 index 0000000000000000000000000000000000000000..f85c7496d0bc4a569d8c0d6ae166001cd5d21ddb --- /dev/null +++ b/.appveyor.yml @@ -0,0 +1,29 @@ +build: false +shallow_clone: false +version: '1.17.1.{build}' +platform: 'x64' +clone_folder: C:\projects\simplesamlphp + +environment: + matrix: + - PHP_VERSION: "5.6" + - PHP_VERSION: "7.0" + - PHP_VERSION: "7.1" + - PHP_VERSION: "7.2" + - PHP_VERSION: "7.3" + +install: + - ps: Invoke-WebRequest "https://raw.githubusercontent.com/ChadSikorra/ps-install-php/master/Install-PHP.ps1" -OutFile "Install-PHP.ps1" + - ps: .\Install-PHP.ps1 -Version $Env:PHP_VERSION -Highest -Arch x64 -Extensions mbstring,intl,openssl,curl,pdo_mysql,pdo_sqlite + - refreshenv + - cd C:\projects\simplesamlphp + - php -r "readfile('https://getcomposer.org/installer');" | php + +before_test: + - cd C:\projects\simplesamlphp + - php composer.phar install --no-interaction --no-progress --optimize-autoloader --prefer-source --no-ansi + +test_script: + - cd C:\projects\simplesamlphp + - vendor\bin\phpunit.bat + diff --git a/tests/BuiltInServer.php b/tests/BuiltInServer.php index 0695e8c7eed2d5a37ffbe53596881130a6f92ad0..c12fc6dc2323e1c3b91b290ce65ea3aae01f4cf2 100644 --- a/tests/BuiltInServer.php +++ b/tests/BuiltInServer.php @@ -9,6 +9,8 @@ namespace SimpleSAML\Test; +use SimpleSAML\Utils\System; + class BuiltInServer { @@ -60,6 +62,10 @@ class BuiltInServer } else { $this->docroot = dirname(dirname(__FILE__)).'/www/'; } + + // Rationalize docroot + $this->docroot = str_replace('\\', '/', $this->docroot); + $this->docroot = rtrim($this->docroot, '/'); } @@ -80,17 +86,26 @@ class BuiltInServer $port = mt_rand(1025, 65535); $this->address = 'localhost:'.$port; - $command = sprintf( - 'php -S %s -t %s %s >> /dev/null 2>&1 & echo $!', - $this->address, - $this->docroot, - $this->router - ); + if (System::getOS() === System::WINDOWS) { + $command = sprintf( + 'powershell $proc = start-process php -ArgumentList (\'-S %s\', \'-t %s\', \'%s\') -Passthru; Write-output $proc.Id;', + $this->address, + $this->docroot, + $this->router + ); + } else { + $command = sprintf( + 'php -S %s -t %s %s >> /dev/null 2>&1 & echo $!', + $this->address, + $this->docroot, + $this->router + ); + } // execute the command and store the process ID $output = []; exec($command, $output); - $this->pid = (int) $output[0]; + $this->pid = intval($output[0]); // wait until it's listening for connections to avoid race conditions $start = microtime(true); @@ -117,8 +132,11 @@ class BuiltInServer { if ($this->pid === 0) { return; + } else if (System::getOS() === System::WINDOWS) { + exec('taskkill /PID '.$this->pid); + } else { + exec('kill '.$this->pid); } - exec('kill '.$this->pid); $this->pid = 0; } diff --git a/tests/lib/SimpleSAML/ConfigurationTest.php b/tests/lib/SimpleSAML/ConfigurationTest.php index 474495e84443c5485883c89bfee1183d7d9269da..18a21fe057e6c0101034122a8238d74e8fbbe0ea 100644 --- a/tests/lib/SimpleSAML/ConfigurationTest.php +++ b/tests/lib/SimpleSAML/ConfigurationTest.php @@ -210,17 +210,17 @@ class ConfigurationTest extends \SimpleSAML\Test\Utils\ClearStateTestCase public function testGetBaseDir() { $c = Configuration::loadFromArray([]); - $this->assertEquals($c->getBaseDir(), dirname(dirname(dirname(dirname(__FILE__)))).'/'); + $this->assertEquals($c->getBaseDir(), dirname(dirname(dirname(dirname(__FILE__)))).DIRECTORY_SEPARATOR); $c = Configuration::loadFromArray([ - 'basedir' => '/basedir', + 'basedir' => DIRECTORY_SEPARATOR.'basedir', ]); - $this->assertEquals($c->getBaseDir(), '/basedir/'); + $this->assertEquals($c->getBaseDir(), DIRECTORY_SEPARATOR.'basedir'.DIRECTORY_SEPARATOR); $c = Configuration::loadFromArray([ - 'basedir' => '/basedir/', + 'basedir' => DIRECTORY_SEPARATOR.'basedir'.DIRECTORY_SEPARATOR, ]); - $this->assertEquals($c->getBaseDir(), '/basedir/'); + $this->assertEquals($c->getBaseDir(), DIRECTORY_SEPARATOR.'basedir'.DIRECTORY_SEPARATOR); } /**