Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Update Windows compatibility #276

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -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
7 changes: 6 additions & 1 deletion src/Test/FileSystemTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ abstract class FileSystemTestCase extends TestCase
*/
protected $tmp;

/**
* @var string
*/
protected $ds = DIRECTORY_SEPARATOR;

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -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
)
Expand Down
30 changes: 15 additions & 15 deletions tests/Composer/ComposerConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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 = [];

Expand Down
2 changes: 1 addition & 1 deletion tests/ConfigurationFileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the path be C:\nowhere?

],
]);

Expand Down
6 changes: 3 additions & 3 deletions tests/RequirementChecker/RequirementsDumperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]);
Expand Down