Skip to content

Commit 1d832f4

Browse files
committed
Fix running oci extensions tests
1 parent c0b1e99 commit 1d832f4

File tree

4 files changed

+80
-10
lines changed

4 files changed

+80
-10
lines changed

extension/BuildPhpExtension/private/Add-BuildTools.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ Function Add-BuildTools {
3636
git {
3737
choco install git.install --params "'/GitAndUnixToolsOnPath /WindowsTerminal /NoAutoCrlf'" -y --force
3838
}
39+
oci_db {
40+
$tool = "Oracle Database XE"
41+
Add-OciDB
42+
}
3943
Default {
4044
$program = $_
4145
$resultLines = (choco search $_ --limit-output) -split "\`r?\`n"

extension/BuildPhpExtension/private/Add-OciDB.ps1

Lines changed: 64 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,73 @@ Function Add-OciDB {
77
param(
88
)
99
begin {
10+
$installDir = 'C:\oracle\product\21c'
11+
$setupDir = 'C:\tools\oracle-setup'
12+
$workingDir = 'C:\tools\oracle'
13+
14+
$dbPassword = 'oracle'
15+
$dbPort = '1521'
16+
$dbEmExpressPort = '5550'
17+
$dbCharset = 'AL32UTF8'
18+
$dbDomain = 'localdomain'
19+
20+
$dbZipFile = 'OracleXE213_Win64.zip'
21+
$dbUrl = 'https://download.oracle.com/otn-pub/otn_software/db-express/OracleXE213_Win64.zip'
1022
}
1123
process {
12-
$dbUrl = 'https://download.oracle.com/otn-pub/otn_software/db-express/OracleXE213_Win64.zip'
13-
$dbZipFile = 'OracleXE213_Win64.zip'
24+
Add-Type -Assembly "System.IO.Compression.Filesystem"
25+
@(
26+
$workingDir,
27+
$setupDir,
28+
"$setupDir\temp",
29+
$installDir
30+
) | ForEach-Object {
31+
New-Item -ItemType Directory -Path $_ -Force | Out-Null
32+
}
33+
1434
Get-File -Url $dbUrl -OutFile $dbZipFile
15-
New-Item -ItemType Directory -Path C:\tools\oracle-setup -Force | Out-Null
16-
New-Item -ItemType Directory -Path C:\tools\oracle -Force | Out-Null
17-
Expand-Archive -Path $dbZipFile -DestinationPath C:\tools\oracle-setup -Force
18-
$rspContent = Get-Content -Path C:\tools\oracle-setup\XEInstall.rsp
19-
$rspContent = $rspContent -replace 'PASSWORD=.*', "PASSWORD=pass"
20-
$rspContent = $rspContent -replace 'INSTALLDIR=.*', "INSTALLDIR=C:\tools\oracle\"
21-
Set-Content -Path C:\tools\oracle-setup\XEInstall-new.rsp -Value $rspContent
22-
cmd.exe /c 'C:\tools\oracle-setup\setup.exe /s /v"RSP_FILE=C:\tools\oracle-setup\XEInstall-new.rsp" /v"/L*v C:\tools\oracle-setup\setup.log" /v"/qn"'
35+
$rspContent = @(
36+
"INSTALLDIR=$installDir\"
37+
"PASSWORD=$dbPassword"
38+
"LISTENER_PORT=$dbPort"
39+
"EMEXPRESS_PORT=$dbEmExpressPort"
40+
"CHAR_SET=$dbCharset"
41+
"DB_DOMAIN=$dbDomain"
42+
)
43+
$argumentList = @(
44+
'/s'
45+
"/v`"RSP_FILE=$setupDir\OracleServerInstall.rsp`""
46+
"/v`"/L*v $setupDir\OracleServerSetup.log`""
47+
'/v"/qn"'
48+
)
49+
if (Get-Command 7z -ErrorAction SilentlyContinue) {
50+
7z x $dbZipFile "-o$setupDir" -y | Out-Null
51+
} else {
52+
[System.IO.Compression.ZipFile]::ExtractToDirectory($dbZipFile, $setupDir)
53+
}
54+
$rspContent | Set-Content -Path $setupDir\OracleServerInstall.rsp
55+
56+
$oldEnv = @{
57+
TMPDIR = $env:TMPDIR
58+
TMP = $env:TMP
59+
TEMP = $env:TEMP
60+
}
61+
62+
try {
63+
$env:TMPDIR = "$setupDir\temp"
64+
$env:TMP = "$setupDir\temp"
65+
$env:TEMP = "$setupDir\temp"
66+
67+
Start-Process -FilePath $setupDir\setup.exe -ArgumentList $argumentList -WorkingDirectory $workingDir -NoNewWindow -Wait
68+
}
69+
finally {
70+
$env:TMPDIR = $oldEnv.TMPDIR
71+
$env:TMP = $oldEnv.TMP
72+
$env:TEMP = $oldEnv.TEMP
73+
}
74+
75+
Add-Path -PathItem "$oracleHome\bin"
76+
$env:ORACLE_HOME="$installDir\dbhomeXE"
2377
}
2478
end {
2579
}

extension/BuildPhpExtension/private/Get-ExtensionConfig.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,10 @@ Function Get-ExtensionConfig {
218218
}
219219
}
220220

221+
if($config.extension_libraries -contains 'instantclient' -and $env:RUN_TESTS -eq 'true') {
222+
$config.build_tools += "oci_db"
223+
}
224+
221225
# TODO: This should be implemented using composer.json once implemented
222226
$packageXml = Get-ChildItem (Get-Location).Path -Recurse -Filter "package.xml" -ErrorAction SilentlyContinue | Select-Object -First 1
223227
if($null -ne $packageXml) {

extension/BuildPhpExtension/private/Invoke-Tests.ps1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ Function Invoke-Tests {
2727
Get-PhpSrc -PhpVersion $Config.php_version
2828
$env:PDO_TEST_DIR = "$currentDirectory\php-$($Config.php_version)-src\ext\pdo\tests"
2929
$env:PDO_OCI_TEST_DIR = "$currentDirectory\tests"
30+
$env:PDO_OCI_TEST_USER = "system"
31+
$env:PDO_OCI_TEST_PASS = "oracle"
32+
$env:PDO_OCI_TEST_DSN = "oci:dbname=localhost:1521/XEPDB1.localdomain;charset=AL32UTF8"
33+
}
34+
if($Config.name -eq 'oci8_19'){
35+
$env:PHP_OCI8_TEST_USER = "system"
36+
$env:PHP_OCI8_TEST_PASS = "oracle"
37+
$env:PHP_OCI8_TEST_DB = "localhost:1521/XEPDB1.localdomain"
3038
}
3139
$tempOriginal = $env:TEMP
3240
Get-TempFiles

0 commit comments

Comments
 (0)