Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions fixtures/with_sessions/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php
// The sessions extension rewrites these directives in the dependency php.ini
// during the supply phase. No session is started here, so no Redis server is
// required for this app to serve.
echo "handler=" . ini_get("session.save_handler") . "|name=" . ini_get("session.name");
1 change: 1 addition & 0 deletions src/php/integration/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ func TestIntegration(t *testing.T) {
suite("Placeholders", testPlaceholders(platform, fixtures))
suite("PreprocessCmds", testPreprocessCmds(platform, fixtures))
suite("StandaloneApp", testStandaloneApp(platform, fixtures))
suite("Sessions", testSessions(platform, fixtures))
// suite("BuildpackPythonExtension", testPythonExtension(platform, fixtures)) // Skipped for now
// suite("APMs", testAPMs(platform, fixtures, dynatraceDeployment.InternalURL)) // Needs dynatrace mock
if settings.Cached {
Expand Down
62 changes: 62 additions & 0 deletions src/php/integration/sessions_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package integration_test

import (
"path/filepath"
"testing"

"github.com/cloudfoundry/switchblade"
. "github.com/cloudfoundry/switchblade/matchers"
. "github.com/onsi/gomega"
"github.com/sclevine/spec"
)

func testSessions(platform switchblade.Platform, fixtures string) func(*testing.T, spec.G, spec.S) {
return func(t *testing.T, context spec.G, it spec.S) {
var (
Expect = NewWithT(t).Expect
Eventually = NewWithT(t).Eventually

name string
)

it.Before(func() {
var err error
name, err = switchblade.RandomName()
Expect(err).NotTo(HaveOccurred())
})

it.After(func() {
if t.Failed() && name != "" {
t.Logf("❌ FAILED TEST - App/Container: %s", name)
t.Logf(" Platform: %s", settings.Platform)
}
if name != "" && (!settings.KeepFailedContainers || !t.Failed()) {
Expect(platform.Delete.Execute(name)).To(Succeed())
}
})

context("app bound to a redis session store", func() {
it("writes the session configuration into the dependency php.ini", func() {
deployment, logs, err := platform.Deploy.
WithServices(map[string]switchblade.Service{
"redis-sessions": {
"hostname": "redis.example.com",
"port": 6379,
"password": "secret",
},
}).
Execute(name, filepath.Join(fixtures, "with_sessions"))
Expect(err).NotTo(HaveOccurred(), logs.String)

Eventually(logs.String()).Should(SatisfyAll(
ContainSubstring("Running extension Compile phase"),
Not(ContainSubstring("Extension compilation failed")),
))

Eventually(deployment).Should(Serve(
ContainSubstring("handler=redis|name=PHPSESSIONID"),
))
})
})
}
}
Loading