Skip to content

Commit 9b66786

Browse files
committed
Add integration test for .ini file extension loading
Add test case that verifies PHP extensions specified in .bp-config/php/php.ini.d/*.ini files are loaded during both composer install (build-time) and application runtime. Test fixture includes: - .bp-config/php/php.ini.d/custom.ini with extension=apcu.so - composer.json requiring ext-apcu with verification scripts - index.php displaying loaded extensions at runtime The test validates that: - APCu extension loads during composer install - Extension is available at application runtime - Build logs show successful extension configuration
1 parent 64c1975 commit 9b66786

File tree

5 files changed

+86
-0
lines changed

5 files changed

+86
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[PHP]
2+
extension=apcu.so
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "cloudfoundry/composer_with_extensions",
3+
"description": "Test app requiring PHP extensions during composer install",
4+
"require": {
5+
"php": ">=8.1",
6+
"ext-apcu": "*"
7+
},
8+
"scripts": {
9+
"post-install-cmd": [
10+
"php -r \"if (!extension_loaded('apcu')) { echo 'FATAL: apcu extension not loaded during composer!'; exit(1); }\"",
11+
"php -r \"echo 'SUCCESS: All required extensions are loaded during composer install\\n';\""
12+
]
13+
}
14+
}

fixtures/composer_with_extensions/composer.lock

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
echo "<h1>PHP Extensions Test</h1>";
3+
echo "<h2>PHP Version: " . phpversion() . "</h2>";
4+
5+
$required_extensions = ['apcu'];
6+
7+
echo "<h3>Required Extensions Status:</h3>";
8+
echo "<ul>";
9+
foreach ($required_extensions as $ext) {
10+
$loaded = extension_loaded($ext);
11+
$status = $loaded ? '✓ LOADED' : '✗ NOT LOADED';
12+
echo "<li><strong>$ext:</strong> $status</li>";
13+
}
14+
echo "</ul>";
15+
16+
echo "<h3>All Loaded Extensions:</h3>";
17+
echo "<ul>";
18+
foreach (get_loaded_extensions() as $ext) {
19+
echo "<li>$ext</li>";
20+
}
21+
echo "</ul>";
22+
?>

src/php/integration/composer_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,5 +110,29 @@ func testComposer(platform switchblade.Platform, fixtures string) func(*testing.
110110
})
111111
})
112112
}
113+
114+
context("composer app with extensions in .bp-config/php/php.ini.d", func() {
115+
it("loads extensions during composer install and at runtime", func() {
116+
deployment, logs, err := platform.Deploy.
117+
WithEnv(map[string]string{
118+
"COMPOSER_GITHUB_OAUTH_TOKEN": os.Getenv("COMPOSER_GITHUB_OAUTH_TOKEN"),
119+
}).
120+
Execute(name, filepath.Join(fixtures, "composer_with_extensions"))
121+
Expect(err).NotTo(HaveOccurred())
122+
123+
// Check build logs first (composer phase)
124+
Expect(logs.String()).To(SatisfyAll(
125+
ContainSubstring("Loading user-requested extensions from .bp-config/php/php.ini.d"),
126+
ContainSubstring("Found 1 extension(s)"),
127+
ContainSubstring("Installing Composer dependencies"),
128+
ContainSubstring("SUCCESS: All required extensions are loaded during composer install"),
129+
Not(ContainSubstring("composer install failed")),
130+
Not(ContainSubstring("ERROR")),
131+
))
132+
133+
// Then wait for deployment and check runtime
134+
Eventually(deployment).Should(Serve(ContainSubstring("apcu:</strong> ✓ LOADED")))
135+
})
136+
})
113137
}
114138
}

0 commit comments

Comments
 (0)