Subject: | [PATCH] Don't use %ENV for passing data structures to tests |
Perl 5.18 stringifies values in %ENV on insert, rather than
keeping references within the same process, so use packge
variables instead of %ENV for structured data.
Subject: | Catalyst-Plugin-Session-Store-DBIC-0.12-ENV.patch |
From f01949281b79bad97e4497307888d676a6fcbef7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?"D.=20Ilmari=20Manns=C3=A5ker"?=
<ilmari.mannsaker@net-a-porter.com>
Date: Fri, 14 Jun 2013 16:47:50 +0100
Subject: [PATCH] Don't use %ENV for passing data structures to tests
Perl 5.18 stringifies values in %ENV on insert, rather than
keeping references within the same process, so use packge
variables instead of %ENV for structured data.
---
Changes | 3 +++
t/05dbic-schema.t | 8 ++++----
t/lib/SetupDB.pm | 2 +-
t/lib/TestApp.pm | 4 ++--
t/lib/TestApp/Model/DBICSchema.pm | 2 +-
5 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/Changes b/Changes
index 2e56165..c302911 100644
--- a/Changes
+++ b/Changes
@@ -1,4 +1,7 @@
Revision history for Catalyst-Plugin-Session-Store-DBIC
+ - Don't use %ENV for passing data structures to tests.
+ This fixes the tests on Perl 5.18, which stringifies %ENV values
+ immediately.
0.12 Thu Aug 4 23:56:00 BST 2011
- Changed a test case to be less picky about the actual text captured
diff --git a/t/05dbic-schema.t b/t/05dbic-schema.t
index 08cb919..87e1282 100644
--- a/t/05dbic-schema.t
+++ b/t/05dbic-schema.t
@@ -23,9 +23,9 @@ BEGIN {
plan tests => 14;
- $ENV{TESTAPP_DB_FILE} = "$FindBin::Bin/session.db";
+ $TestApp::DB_FILE = "$FindBin::Bin/session.db";
- $ENV{TESTAPP_CONFIG} = {
+ $TestApp::CONFIG = {
name => 'TestApp',
session => {
dbic_class => 'DBICSchema::Session',
@@ -33,7 +33,7 @@ BEGIN {
},
};
- $ENV{TESTAPP_PLUGINS} = [qw/
+ $TestApp::PLUGINS = [qw/
Session
Session::State::Cookie
Session::Store::DBIC
@@ -79,4 +79,4 @@ $mech->get_ok('http://localhost/session/delete_expired', 'request to delete expi
$mech->content_is('ok', 'deleted expired sessions');
# Clean up
-unlink $ENV{TESTAPP_DB_FILE};
+unlink $TestApp::DB_FILE;
diff --git a/t/lib/SetupDB.pm b/t/lib/SetupDB.pm
index 86a0341..7588e8f 100644
--- a/t/lib/SetupDB.pm
+++ b/t/lib/SetupDB.pm
@@ -4,7 +4,7 @@ use strict;
use warnings;
# Create the database
-my $db_file = $ENV{TESTAPP_DB_FILE};
+my $db_file = $TestApp::DB_FILE;
unlink $db_file if -e $db_file;
my $dbh = DBI->connect("dbi:SQLite:$db_file") or die $DBI::errstr;
diff --git a/t/lib/TestApp.pm b/t/lib/TestApp.pm
index f12229e..000f81f 100644
--- a/t/lib/TestApp.pm
+++ b/t/lib/TestApp.pm
@@ -4,7 +4,7 @@ use strict;
use warnings;
use Catalyst;
-__PACKAGE__->config($ENV{TESTAPP_CONFIG});
-__PACKAGE__->setup(@{ $ENV{TESTAPP_PLUGINS} });
+__PACKAGE__->config($TestApp::CONFIG);
+__PACKAGE__->setup(@{ $TestApp::PLUGINS });
1;
diff --git a/t/lib/TestApp/Model/DBICSchema.pm b/t/lib/TestApp/Model/DBICSchema.pm
index dbab4d4..705d133 100644
--- a/t/lib/TestApp/Model/DBICSchema.pm
+++ b/t/lib/TestApp/Model/DBICSchema.pm
@@ -6,7 +6,7 @@ eval { require Catalyst::Model::DBIC::Schema }; return 1 if $@;
use strict;
use warnings;
-our $db_file = $ENV{TESTAPP_DB_FILE};
+our $db_file = $TestApp::DB_FILE;
__PACKAGE__->config(
schema_class => 'TestApp::Schema',
--
1.7.9.5