diff --git a/.appveyor.yml b/.appveyor.yml new file mode 100644 index 000000000..5892aabc1 --- /dev/null +++ b/.appveyor.yml @@ -0,0 +1,44 @@ +build: false +platform: + - x64 +clone_folder: c:\projects\box +version: '{build}.{branch}' + +environment: + matrix: + - PHP_VERSION: 7.1 + - PHP_VERSION: 7.2 + +cache: + - '%LOCALAPPDATA%\Composer\files' + - composer.phar + - C:\ProgramData\chocolatey\bin -> .appveyor.yml + - C:\ProgramData\chocolatey\lib -> .appveyor.yml + - c:\tools\php -> .appveyor.yml + +init: + - SET PATH=C:\Program Files\OpenSSL;c:\tools\php\%PHP_VERSION%;%PATH% + - SET COMPOSER_NO_INTERACTION=1 + - REG ADD "HKEY_CURRENT_USER\Software\Microsoft\Command Processor" /v DelayedExpansion /t REG_DWORD /d 1 /f + +install: + - IF NOT EXIST c:\php mkdir c:\php + - IF NOT EXIST c:\php\%PHP_VERSION% mkdir c:\php\%PHP_VERSION% + - ps: appveyor-retry cinst --params '""/InstallDir:C:\tools\php\%PHP_VERSION%""' --ignore-checksums -y php --version ((choco search php --exact --all-versions -r | select-string -pattern $env:PHP_VERSION | sort { [version]($_ -split '\|' | select -last 1) } -Descending | Select-Object -first 1) -replace '[php|]','') + - cd c:\tools\php\%PHP_VERSION% + - copy php.ini-production php.ini /Y + - echo date.timezone="UTC" >> php.ini + - echo extension_dir=ext >> php.ini + - echo extension=php_openssl.dll >> php.ini + - echo extension=php_mbstring.dll >> php.ini + - echo extension=php_fileinfo.dll >> php.ini + - echo extension=php_bz2.dll >> php.ini + - cd c:\projects\box + - IF NOT EXIST composer.phar (appveyor-retry appveyor DownloadFile https://github.com/composer/composer/releases/download/1.7.1/composer.phar) + - php composer.phar self-update + - IF %APPVEYOR_REPO_BRANCH%==master (SET COMPOSER_ROOT_VERSION=dev-master) ELSE (SET COMPOSER_ROOT_VERSION=%APPVEYOR_REPO_BRANCH%.x-dev) + - appveyor-retry php composer.phar install --no-interaction --no-progress --no-suggest --prefer-dist + +test_script: + - cd c:\projects\box + - bin\phpunit diff --git a/src/Test/FileSystemTestCase.php b/src/Test/FileSystemTestCase.php index 773f503d9..537bc402f 100644 --- a/src/Test/FileSystemTestCase.php +++ b/src/Test/FileSystemTestCase.php @@ -34,6 +34,11 @@ abstract class FileSystemTestCase extends TestCase */ protected $tmp; + /** + * @var string + */ + protected $ds = DIRECTORY_SEPARATOR; + /** * {@inheritdoc} */ @@ -75,7 +80,7 @@ final protected function normalizePaths(array $files): array $files = array_values( array_map( function (string $file) use ($root): string { - return str_replace($root.DIRECTORY_SEPARATOR, '', $file); + return str_replace([$root.DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR], ['', '/'], $file); }, $files ) diff --git a/tests/Composer/ComposerConfigurationTest.php b/tests/Composer/ComposerConfigurationTest.php index 3b9e445db..d86ccc8e4 100644 --- a/tests/Composer/ComposerConfigurationTest.php +++ b/tests/Composer/ComposerConfigurationTest.php @@ -228,12 +228,12 @@ public function test_it_can_retrieve_the_dev_packages_found_in_the_lock_file(): $decodedComposerJson = []; $decodedComposerLock = json_decode(self::COMPOSER_LOCK_SAMPLE, true); - mkdir('vendor/bamarni/composer-bin-plugin'); - mkdir('vendor/doctrine/instantiator'); + mkdir("vendor{$this->ds}bamarni{$this->ds}composer-bin-plugin"); + mkdir("vendor{$this->ds}doctrine{$this->ds}instantiator"); $expected = [ - $this->tmp.'/vendor/bamarni/composer-bin-plugin', - $this->tmp.'/vendor/doctrine/instantiator', + $this->tmp."{$this->ds}vendor{$this->ds}bamarni{$this->ds}composer-bin-plugin", + $this->tmp."{$this->ds}vendor{$this->ds}doctrine{$this->ds}instantiator", ]; $actual = ComposerConfiguration::retrieveDevPackages($this->tmp, $decodedComposerJson, $decodedComposerLock); @@ -246,12 +246,12 @@ public function test_it_can_retrieve_the_dev_packages_found_in_the_lock_file_2() $decodedComposerJson = ['config' => []]; $decodedComposerLock = json_decode(self::COMPOSER_LOCK_SAMPLE, true); - mkdir('vendor/bamarni/composer-bin-plugin'); - mkdir('vendor/doctrine/instantiator'); + mkdir("vendor{$this->ds}bamarni{$this->ds}composer-bin-plugin"); + mkdir("vendor{$this->ds}doctrine{$this->ds}instantiator"); $expected = [ - $this->tmp.'/vendor/bamarni/composer-bin-plugin', - $this->tmp.'/vendor/doctrine/instantiator', + $this->tmp."{$this->ds}vendor{$this->ds}bamarni{$this->ds}composer-bin-plugin", + $this->tmp."{$this->ds}vendor{$this->ds}doctrine{$this->ds}instantiator", ]; $actual = ComposerConfiguration::retrieveDevPackages($this->tmp, $decodedComposerJson, $decodedComposerLock); @@ -264,11 +264,11 @@ public function test_it_ignores_non_existent_dev_packages_found_in_the_lock_file $decodedComposerJson = []; $decodedComposerLock = json_decode(self::COMPOSER_LOCK_SAMPLE, true); - mkdir('vendor/bamarni/composer-bin-plugin'); + mkdir("vendor{$this->ds}bamarni{$this->ds}composer-bin-plugin"); // Doctrine Instantiator vendor does not exists $expected = [ - $this->tmp.'/vendor/bamarni/composer-bin-plugin', + $this->tmp."{$this->ds}vendor{$this->ds}bamarni{$this->ds}composer-bin-plugin", ]; $actual = ComposerConfiguration::retrieveDevPackages($this->tmp, $decodedComposerJson, $decodedComposerLock); @@ -285,11 +285,11 @@ public function test_it_can_retrieve_the_dev_packages_found_in_the_lock_file_in_ ]; $decodedComposerLock = json_decode(self::COMPOSER_LOCK_SAMPLE, true); - mkdir('custom-vendor/bamarni/composer-bin-plugin'); - mkdir('vendor/doctrine/instantiator'); // Wrong directory + mkdir("custom-vendor{$this->ds}bamarni{$this->ds}composer-bin-plugin"); + mkdir("vendor{$this->ds}doctrine{$this->ds}instantiator"); // Wrong directory $expected = [ - $this->tmp.'/custom-vendor/bamarni/composer-bin-plugin', + $this->tmp."{$this->ds}custom-vendor{$this->ds}bamarni{$this->ds}composer-bin-plugin", ]; $actual = ComposerConfiguration::retrieveDevPackages($this->tmp, $decodedComposerJson, $decodedComposerLock); @@ -404,8 +404,8 @@ public function test_it_can_retrieve_the_dev_packages_found_in_the_lock_file_eve true ); - mkdir('custom-vendor/bamarni/composer-bin-plugin'); - mkdir('vendor/doctrine/instantiator'); // Wrong directory + mkdir("custom-vendor{$this->ds}bamarni{$this->ds}composer-bin-plugin"); + mkdir("vendor{$this->ds}doctrine{$this->ds}instantiator"); // Wrong directory $expected = []; diff --git a/tests/ConfigurationFileTest.php b/tests/ConfigurationFileTest.php index f93cd899c..09e7d9b38 100644 --- a/tests/ConfigurationFileTest.php +++ b/tests/ConfigurationFileTest.php @@ -1126,7 +1126,7 @@ public function test_the_blacklist_input_may_refer_to_non_existent_paths(): void { $this->setConfig([ 'blacklist' => [ - '/nowhere', + ($this->isWindows() ? 'C:' : '') . '/nowhere', ], ]); diff --git a/tests/RequirementChecker/RequirementsDumperTest.php b/tests/RequirementChecker/RequirementsDumperTest.php index 0abfeba09..0c7c9e644 100644 --- a/tests/RequirementChecker/RequirementsDumperTest.php +++ b/tests/RequirementChecker/RequirementsDumperTest.php @@ -14,14 +14,14 @@ namespace KevinGH\Box\RequirementChecker; +use KevinGH\Box\Test\FileSystemTestCase; use Phar; -use PHPUnit\Framework\TestCase; use function array_column; /** * @covers \KevinGH\Box\RequirementChecker\RequirementsDumper */ -class RequirementsDumperTest extends TestCase +class RequirementsDumperTest extends FileSystemTestCase { /** * @dataProvider provideJsonAndLockContents @@ -75,7 +75,7 @@ public function test_it_dumps_the_requirement_checker_files( $this->assertSame( $expectedFiles, - array_column($checkFiles, 0) + $this->normalizePaths(array_column($checkFiles, 0)) ); $this->assertSame($expectedRequirement, $checkFiles[0][1]);