Skip to content

Commit 3204dcc

Browse files
authored
Merge pull request #59 from mlocati/fix-installing-couchbase-extension
Fix installing couchbase extension
2 parents fb77d09 + 6aa8b95 commit 3204dcc

File tree

4 files changed

+27
-6
lines changed

4 files changed

+27
-6
lines changed

PhpManager/public/Install-Composer.ps1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@
7171
$installer = Get-FileFromUrlOrCache -Url $installerUrl -CachedFileName 'composer-installer.php'
7272
}
7373
$tempPhar = [System.IO.Path]::GetTempFileName();
74-
$args = @()
75-
$args += $installer
76-
$args += '--install-dir=' + (Split-Path -Path $tempPhar -Parent)
77-
$args += '--filename=' + (Split-Path -Path $tempPhar -Leaf)
78-
$args += '2>&1'
74+
$arguments = @()
75+
$arguments += $installer
76+
$arguments += '--install-dir=' + (Split-Path -Path $tempPhar -Parent)
77+
$arguments += '--filename=' + (Split-Path -Path $tempPhar -Leaf)
78+
$arguments += '2>&1'
7979
Write-Verbose "Launching Composer installer"
80-
$installerResult = & $phpVersion.ExecutablePath $args
80+
$installerResult = & $phpVersion.ExecutablePath $arguments
8181
if ($LASTEXITCODE -ne 0) {
8282
throw $installerResult
8383
}

PhpManager/public/Install-Php.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
Use this switch to enable installing PHP even if the destination directory already exists and it's not empty.
4848
#>
4949
[OutputType()]
50+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', 'ThreadSafe', Justification = 'False positive as rule does not know that Where-Object operates within the same scope')] # See https://github.com/PowerShell/PSScriptAnalyzer/issues/1472
5051
param (
5152
[Parameter(Mandatory = $true, Position = 0, HelpMessage = 'The PHP version to be installed')]
5253
[ValidatePattern('^(master|(\d+\.\d+snapshot)|(\d+(\.\d+)?(\.\d+)?((alpha|beta|RC)\d*)?))$')]

PhpManager/public/Install-PhpExtension.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@
144144
}
145145
$dllPath = $phpDlls[0].FullName
146146
switch ($peclPackageHandle) {
147+
'couchbase' {
148+
$libcouchbaseDll = Join-Path -Path $tempFolder -ChildPath 'libcouchbase.dll'
149+
if (Test-Path -LiteralPath $libcouchbaseDll -PathType Leaf) {
150+
$additionalFiles += $libcouchbaseDll
151+
}
152+
}
147153
'yaml' {
148154
$yamlDll = Join-Path -Path $tempFolder -ChildPath 'yaml.dll'
149155
if (Test-Path -LiteralPath $yamlDll -PathType Leaf) {

test/tests/Install-Enable-Extensions.Tests.ps1

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,20 @@
6767
$yaml.Type | Should -BeExactly 'Php'
6868
$yaml.State | Should -BeExactly 'Enabled'
6969
}
70+
It -Name 'should download and install couchbase on PHP <version>' -TestCases $testCases {
71+
param ($path, $version)
72+
if (-not(Join-Path -Path $Env:windir -ChildPath System32\msvcp140.dll | Test-Path -PathType Leaf)) {
73+
if (-not(Join-Path -Path $Env:windir -ChildPath System32\msvcp160.dll | Test-Path -PathType Leaf)) {
74+
Set-ItResult -Skipped -Because 'Missing some required system DLLs'
75+
}
76+
}
77+
Get-PhpExtension -Path $path | Where-Object { $_.Handle -eq 'couchbase' } | Should -HaveCount 0
78+
Install-PhpExtension -Extension couchbase -Path $path
79+
$couchbase = Get-PhpExtension -Path $path | Where-Object { $_.Handle -eq 'couchbase' }
80+
$couchbase | Should -HaveCount 1
81+
$couchbase.Type | Should -BeExactly 'Php'
82+
$couchbase.State | Should -BeExactly 'Enabled'
83+
}
7084
It -Name 'should handle multiple extension versions' {
7185
$phpPath = Join-Path -Path $Global:PHPMANAGER_TESTINSTALLS -ChildPath (New-Guid).Guid
7286
Install-Php -Version 7.1 -Architecture x64 -ThreadSafe $true -Path $phpPath

0 commit comments

Comments
 (0)