Skip to content

Commit b7222ba

Browse files
committed
Adding appveyor CI support
1 parent 14fa7ef commit b7222ba

File tree

3 files changed

+65
-1
lines changed

3 files changed

+65
-1
lines changed

appveyor.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
build: false
2+
clone_folder: c:\projects\maker-bundle
3+
4+
cache:
5+
- composer.phar
6+
- .phpunit -> phpunit
7+
8+
install:
9+
- mkdir c:\php && cd c:\php
10+
- appveyor DownloadFile https://github.com/symfony/binary-utils/releases/download/v0.1/php-7.1.3-Win32-VC14-x86.zip
11+
- 7z x php-7.1.3-Win32-VC14-x86.zip -y >nul
12+
- cd ext
13+
- appveyor DownloadFile https://github.com/symfony/binary-utils/releases/download/v0.1/php_apcu-5.1.8-7.1-ts-vc14-x86.zip
14+
- 7z x php_apcu-5.1.8-7.1-ts-vc14-x86.zip -y >nul
15+
- cd ..
16+
- copy /Y php.ini-development php.ini-min
17+
- echo memory_limit=-1 >> php.ini-min
18+
- echo serialize_precision=14 >> php.ini-min
19+
- echo max_execution_time=1200 >> php.ini-min
20+
- echo date.timezone="America/Los_Angeles" >> php.ini-min
21+
- echo extension_dir=ext >> php.ini-min
22+
- copy /Y php.ini-min php.ini-max
23+
- echo zend_extension=php_opcache.dll >> php.ini-max
24+
- echo opcache.enable_cli=1 >> php.ini-max
25+
- echo extension=php_openssl.dll >> php.ini-max
26+
- echo extension=php_apcu.dll >> php.ini-max
27+
- echo apc.enable_cli=1 >> php.ini-max
28+
- echo extension=php_intl.dll >> php.ini-max
29+
- echo extension=php_mbstring.dll >> php.ini-max
30+
- echo extension=php_fileinfo.dll >> php.ini-max
31+
- echo extension=php_pdo_sqlite.dll >> php.ini-max
32+
- echo extension=php_curl.dll >> php.ini-max
33+
- copy /Y php.ini-max php.ini
34+
35+
- cd c:\php
36+
- IF NOT EXIST composer.phar (appveyor DownloadFile https://getcomposer.org/download/1.6.3/composer.phar)
37+
- php composer.phar self-update
38+
- echo @php "c:\php\composer.phar" %*>composer.bat
39+
40+
- cd c:\projects\maker-bundle
41+
- php -dmemory_limit=-1 c:\php\composer.phar install --no-progress --no-suggest --ansi
42+
- ./vendor/bin/simple-phpunit install
43+
44+
test_script:
45+
- ./vendor/bin/simple-phpunit

src/FileManager.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class FileManager
3333
public function __construct(Filesystem $fs, string $rootDirectory)
3434
{
3535
$this->fs = $fs;
36-
$this->rootDirectory = rtrim($this->realpath($rootDirectory).'/');
36+
$this->rootDirectory = rtrim($this->realpath($this->normalizeSlashes($rootDirectory)).'/');
3737
}
3838

3939
public function setIO(SymfonyStyle $io)
@@ -63,6 +63,8 @@ public function fileExists($path): bool
6363

6464
public function relativizePath($absolutePath): string
6565
{
66+
$absolutePath = $this->normalizeSlashes($absolutePath);
67+
6668
// see if the path is even in the root
6769
if (false === strpos($absolutePath, $this->rootDirectory)) {
6870
return $absolutePath;
@@ -144,6 +146,11 @@ private function absolutizePath($path): string
144146
return $path;
145147
}
146148

149+
// support windows drive paths: C:\
150+
if (1 === strpos($path, ':\\')) {
151+
return $path;
152+
}
153+
147154
return sprintf('%s/%s', $this->rootDirectory, $path);
148155
}
149156

@@ -159,6 +166,7 @@ private function realPath($absolutePath): string
159166
$finalParts = [];
160167
$currentIndex = -1;
161168

169+
$absolutePath = $this->normalizeSlashes($absolutePath);
162170
foreach (explode('/', $absolutePath) as $pathPart) {
163171
if ('..' === $pathPart) {
164172
// we need to remove the previous entry
@@ -184,4 +192,9 @@ private function realPath($absolutePath): string
184192

185193
return $finalPath;
186194
}
195+
196+
private function normalizeSlashes(string $path)
197+
{
198+
return str_replace('\\', '/', $path);
199+
}
187200
}

tests/FileManagerTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ public function getRelativizePathTests()
4545
'/home/project/foo/bar/../../src/Baz.php',
4646
'src/Baz.php',
4747
];
48+
49+
yield 'windows_path' => [
50+
'D:\path\to\project',
51+
'D:\path\to\project\vendor\composer/../../src/Controller/TestController.php',
52+
'src/Controller/TestController.php',
53+
];
4854
}
4955

5056
public function testGetPathForFutureClass()

0 commit comments

Comments
 (0)