Skip to content

Commit 9db7008

Browse files
committed
[ticket/16661] Add test for phpBB on Windows
PHPBB3-16661
1 parent 8992277 commit 9db7008

2 files changed

Lines changed: 124 additions & 0 deletions

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit backupGlobals="true"
3+
backupStaticAttributes="false"
4+
colors="true"
5+
convertErrorsToExceptions="true"
6+
convertNoticesToExceptions="true"
7+
convertWarningsToExceptions="true"
8+
processIsolation="false"
9+
stopOnFailure="false"
10+
verbose="true"
11+
bootstrap="../tests/bootstrap.php">
12+
<testsuites>
13+
<testsuite name="phpBB Test Suite">
14+
<directory suffix="_test.php">../tests</directory>
15+
<exclude>../tests/functional</exclude>
16+
<exclude>../tests/lint_test.php</exclude>
17+
</testsuite>
18+
<testsuite name="phpBB Functional Tests">
19+
<directory suffix="_test.php">../tests/functional</directory>
20+
</testsuite>
21+
</testsuites>
22+
23+
<groups>
24+
<exclude>
25+
<group>slow</group>
26+
</exclude>
27+
</groups>
28+
29+
<php>
30+
<server name="PHPBB_TEST_DBMS" value="phpbb\db\driver\postgres"/>
31+
<server name="PHPBB_TEST_DBHOST" value="localhost" />
32+
<server name="PHPBB_TEST_DBPORT" value="5432" />
33+
<server name="PHPBB_TEST_DBNAME" value="phpbb_tests" />
34+
<server name="PHPBB_TEST_DBUSER" value="postgres" />
35+
<server name="PHPBB_TEST_DBPASSWD" value="root" />
36+
<server name="PHPBB_TEST_REDIS_HOST" value="localhost" />
37+
<server name="PHPBB_TEST_MEMCACHED_HOST" value="localhost" />
38+
<server name="PHPBB_TEST_TABLE_PREFIX" value="phpbb_"/>
39+
<server name="PHPBB_FUNCTIONAL_URL" value="http://phpbb.test/" />
40+
</php>
41+
</phpunit>

.github/workflows/tests.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,3 +363,86 @@ jobs:
363363
DB: ${{steps.database-type.outputs.db}}
364364
run: |
365365
phpBB/vendor/bin/phpunit --configuration .github/phpunit-$DB-github.xml --verbose --stop-on-error
366+
367+
# Test with IIS & PostgreSQL on Windows
368+
windows-tests:
369+
runs-on: windows-2016
370+
strategy:
371+
matrix:
372+
include:
373+
- php: '7.4'
374+
db: "postgres"
375+
376+
name: Windows - PHP ${{ matrix.php }} - ${{ matrix.db }}
377+
378+
steps:
379+
- name: Prepare git for Windows
380+
run: |
381+
git config --system core.autocrlf false
382+
git config --system core.eol lf
383+
- name: Checkout repository
384+
uses: actions/checkout@v2
385+
386+
- name: Setup PHP
387+
uses: shivammathur/setup-php@v2
388+
with:
389+
php-version: ${{ matrix.php }}
390+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, intl, gd, exif, iconv, pgsql, pdo_pgsql
391+
ini-values: upload_tmp_dir=${{ runner.temp }}, sys_temp_dir=${{ runner.temp }}
392+
coverage: none
393+
394+
- name: Setup environment for phpBB
395+
env:
396+
GITHUB_WORKSPACE: ${{ github.workspace }}
397+
TEMP_DIR: ${{ runner.temp }}
398+
run: |
399+
Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebServerRole, IIS-WebServer, IIS-CommonHttpFeatures, IIS-ManagementConsole, IIS-HttpErrors, IIS-HttpRedirect, IIS-WindowsAuthentication, IIS-StaticContent, IIS-DefaultDocument, IIS-HttpCompressionStatic, IIS-DirectoryBrowsing, IIS-WebServerManagementTools, IIS-CGI -All
400+
Set-Service wuauserv -StartupType Manual
401+
(Get-Content ${env:GITHUB_WORKSPACE}\phpBB\web.config).replace("<configuration>", "<configuration>`n`t<system.web>`n`t`t<customErrors mode=`"Off`"/>`n`t</system.web>") | Set-Content ${env:GITHUB_WORKSPACE}\phpBB\web.config
402+
(Get-Content ${env:GITHUB_WORKSPACE}\phpBB\web.config).replace("`t</system.webServer>", "`t`t<httpErrors errorMode=`"Detailed`" />`n`t</system.webServer>") | Set-Content ${env:GITHUB_WORKSPACE}\phpBB\web.config
403+
choco install urlrewrite -y
404+
Import-Module WebAdministration
405+
New-WebSite -Name 'phpBBTest' -PhysicalPath "${env:GITHUB_WORKSPACE}\phpBB" -Force
406+
$session = Get-PSSession -Name WinPSCompatSession
407+
$sb = {Set-ItemProperty 'IIS:\Sites\phpBBTest' -name Bindings -value @{protocol='http';bindingInformation='*:80:phpbb.test'}}
408+
Invoke-Command -Scriptblock $sb -Session $session
409+
$sb = {Set-WebConfigurationProperty -filter /system.WebServer/security/authentication/AnonymousAuthentication -name enabled -value true -location "IIS:\Sites\phpBBTest"}
410+
Invoke-Command -Scriptblock $sb -Session $session
411+
Add-Content -Path $env:windir\System32\drivers\etc\hosts -Value "`r`n127.0.0.1`tphpbb.test" -Force
412+
[System.Environment]::SetEnvironmentVariable('PATH',$Env:PATH+";%windir%\system32\inetsrv")
413+
echo Setup FAST-CGI configuration
414+
Add-WebConfiguration -Filter /system.webServer/fastCgi -PSPath IIS:\ -Value @{fullpath="C:\tools\php\php-cgi.exe"}
415+
echo Setup FACT-CGI handler
416+
New-WebHandler -Name "PHP-FastCGI" -Path "*.php" -Modules FastCgiModule -ScriptProcessor "C:\tools\php\php-cgi.exe" -Verb '*' -ResourceType Either
417+
iisreset
418+
NET START W3SVC
419+
mkdir "${env:GITHUB_WORKSPACE}\phpBB\cache\test"
420+
mkdir "${env:GITHUB_WORKSPACE}\phpBB\cache\installer"
421+
icacls "${env:GITHUB_WORKSPACE}\phpBB\cache" /grant Users:F /T
422+
icacls "${env:GITHUB_WORKSPACE}\phpBB\files" /grant Users:F /T
423+
icacls "${env:GITHUB_WORKSPACE}\phpBB\store" /grant Users:F /T
424+
icacls "${env:GITHUB_WORKSPACE}\phpBB\images\avatars\upload" /grant Users:F /T
425+
$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule("IIS_IUSRS", "FullControl", "ContainerInherit,ObjectInherit", "None", "Allow")
426+
$acl = Get-ACL "${env:TEMP_DIR}"
427+
$acl.AddAccessRule($accessRule)
428+
Set-ACL -Path "${env:TEMP_DIR}" -ACLObject $acl
429+
cd ${env:GITHUB_WORKSPACE}\phpBB
430+
php ..\composer.phar install
431+
cd ..
432+
- name: Setup database
433+
run: |
434+
$postgreSqlSvc = Get-Service "postgresql*"
435+
Set-Service $postgreSqlSvc.Name -StartupType manual
436+
$postgreSqlSvc.Start()
437+
try {
438+
(Get-Service "postgresql*").Start()
439+
} catch {
440+
$_ | select *
441+
}
442+
[System.Environment]::SetEnvironmentVariable('PATH',$Env:PATH+";${env:PGBIN}")
443+
$env:PGPASSWORD = 'root'
444+
psql -c 'DROP DATABASE IF EXISTS phpbb_tests;' -U postgres
445+
psql -c 'create database phpbb_tests;' -U postgres
446+
- name: Run unit tests
447+
run: |
448+
phpBB/vendor/bin/phpunit --configuration .github/phpunit-psql-windows-github.xml --verbose --stop-on-error

0 commit comments

Comments
 (0)