Skip to content

Commit

Permalink
Merge pull request #1 from alexiusp/windows-support
Browse files Browse the repository at this point in the history
#1: Add Windows support
  • Loading branch information
BR0kEN- authored Nov 17, 2017
2 parents 2df3a1b + 8234e1a commit 420b282
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 4 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ php:
- 5.5
- 5.6
- 7
- hhvm

env:
- COMPOSER_OPTS=""
Expand Down
47 changes: 47 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
build: false
version: '{build}'
platform: x86
clone_folder: c:\projects\environment-loader
shallow_clone: false

environment:
matrix:
- PHP_DOWNLOAD_FILE: php-7.1.11-Win32-VC14-x86.zip

branches:
only:
- master

skip_commits:
message: /\[ci skip\]/

cache:
- c:\php -> appveyor.yml

init:
- SET PATH=c:\php;%PATH%
- SET COMPOSER_NO_INTERACTION=1
- SET PHP=1
- SET ANSICON=121x90 (121x90)
- git config --global core.autocrlf input

install:
- IF EXIST c:\php (SET PHP=0) ELSE (mkdir c:\php)
- cd c:\php
- IF %PHP%==1 appveyor DownloadFile http://windows.php.net/downloads/releases/%PHP_DOWNLOAD_FILE%
- IF %PHP%==1 7z x %PHP_DOWNLOAD_FILE% -y > 7z.log
- IF %PHP%==1 echo @php %%~dp0composer.phar %%* > composer.bat
- appveyor DownloadFile https://getcomposer.org/composer.phar
- 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_curl.dll >> php.ini
- echo extension=php_mbstring.dll >> php.ini
- echo extension=php_fileinfo.dll >> php.ini
- cd c:\projects\environment-loader
- composer install --no-progress --ansi

test_script:
- cd c:\projects\environment-loader
- php vendor\phpunit\phpunit\phpunit
2 changes: 1 addition & 1 deletion src/EnvironmentLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function __construct(Extension $extension, ContainerBuilder $container, a
// Remove the "ServiceContainer" from the namespace of the extension object.
$this->namespace = rtrim(str_replace('ServiceContainer', '', $reflection->getNamespaceName()), '\\');
// Remove the name of file and "ServiceContainer" from the path to extension.
$this->path = implode('/', array_slice(explode('/', $reflection->getFileName()), 0, -2));
$this->path = implode(DIRECTORY_SEPARATOR, array_slice(explode(DIRECTORY_SEPARATOR, $reflection->getFileName()), 0, -2));
$this->container = $container;
// To not care about string format.
$this->configKey = strtolower($extension->getConfigKey());
Expand Down
14 changes: 12 additions & 2 deletions tests/EnvironmentLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function loaderConstructor()
$this->readLoaderProperties();

foreach ([
'path' => sprintf('%s/behat/extensions/ExampleExtension', __DIR__),
'path' => self::resolvePath(sprintf('%s/behat/extensions/ExampleExtension', __DIR__)),
'namespace' => sprintf('%s\ExampleExtension', __NAMESPACE__),
'container' => $this->container,
'configKey' => $this->extension->getConfigKey(),
Expand Down Expand Up @@ -149,7 +149,7 @@ public function runBehatTests()
$code = 0;

static::assertTrue(chdir('tests/behat'));
system('../../vendor/bin/behat --no-colors', $code);
system(self::resolvePath('../../vendor/bin/behat --no-colors'), $code);
static::assertTrue(0 === $code);
}

Expand Down Expand Up @@ -185,4 +185,14 @@ private function isEnvironmentHasDefinition($definition)

return isset($definitions[$definition]);
}

/**
* @param string $path
*
* @return string
*/
private static function resolvePath($path)
{
return '/' === DIRECTORY_SEPARATOR ? $path : str_replace('/', '\\', $path);
}
}

0 comments on commit 420b282

Please sign in to comment.