added Next version
|
1 |
use Test::More; |
2 |
use strict; |
|
3 |
use warnings; |
|
4 |
use utf8; |
|
5 | ||
6 |
use FindBin; |
|
removed DBIx::Custom::Next f...
|
7 |
use DBIx::Custom; |
added Next version
|
8 | |
9 |
my $dbi; |
|
10 |
my $dsn; |
|
11 |
my $args; |
|
12 |
my $user = 'dbix_custom'; |
|
13 |
my $password = 'dbix_custom'; |
|
14 |
my $database = 'dbix_custom'; |
|
15 | ||
16 |
$dsn = "dbi:mysql:database=$database"; |
|
17 |
$args = {dsn => $dsn, user => $user, password => $password,}; |
|
18 | ||
19 |
plan skip_all => 'mysql private test' unless -f "$FindBin::Bin/run/mysql2.run" |
|
removed DBIx::Custom::Next f...
|
20 |
&& eval { $dbi = DBIx::Custom->connect($args); 1 }; |
added Next version
|
21 |
plan 'no_plan'; |
22 | ||
23 |
$SIG{__WARN__} = sub { warn $_[0] unless $_[0] =~ /DEPRECATED/}; |
|
24 | ||
25 | ||
26 |
require DBIx::Connector; |
|
27 | ||
28 |
# Function for test name |
|
29 |
sub test { print "# $_[0]\n" } |
|
30 | ||
31 |
# Varialbes for tests |
|
32 |
my $dbname; |
|
33 |
my $rows; |
|
34 |
my $result; |
|
35 | ||
removed DBIx::Custom::Next f...
|
36 |
$dbi = DBIx::Custom->connect( |
added Next version
|
37 |
dsn => "dbi:mysql:database=$database", |
38 |
user => $user, |
|
39 |
password => $password |
|
40 |
); |
|
41 |
eval { $dbi->execute('drop table table1') }; |
|
42 |
$dbi->execute('create table table1 (key1 varchar(255), key2 varchar(255))'); |
|
43 | ||
44 |
test 'connector => 1'; |
|
45 |
{ |
|
removed DBIx::Custom::Next f...
|
46 |
my $dbi = DBIx::Custom->connect(dsn => $dsn, user => $user, password => $password, |
added Next version
|
47 |
option => {PrintError => 1}, connector => 1); |
48 |
is(ref $dbi->connector, 'DBIx::Connector'); |
|
49 |
ok($dbi->dbh->{PrintError}); |
|
50 |
$dbi->delete_all(table => 'table1'); |
|
51 |
$dbi->insert({key1 => 1, key2 => 2}, table => 'table1'); |
|
52 |
die "Can't fork" unless defined (my $pid = fork); |
|
53 | ||
54 |
if ($pid) { |
|
55 |
# Parent |
|
56 |
my $result = $dbi->select(table => 'table1'); |
|
57 |
is_deeply($result->fetch_hash_first, {key1 => 1, key2 => 2}); |
|
58 |
} |
|
59 |
else { |
|
60 |
# Child |
|
61 |
my $result = $dbi->select(table => 'table1'); |
|
62 |
die "Not OK" unless $result->fetch_hash_first->{key1} == 1; |
|
63 |
} |
|
64 |
} |
|
65 |