File: source_bind_compat.t

package info (click to toggle)
libdbix-class-perl 0.08196-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 4,424 kB
  • sloc: perl: 22,328; sql: 362; makefile: 10
file content (49 lines) | stat: -rw-r--r-- 1,136 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use strict;
use warnings;

use Test::More;
use Test::Warn;
use Test::Exception;
use lib qw(t/lib);
use DBICTest;

{
  package DBICTest::Legacy::Storage;
  use base 'DBIx::Class::Storage::DBI::SQLite';

  use Data::Dumper::Concise;

  sub source_bind_attributes { return {} }
}


my $schema = DBICTest::Schema->clone;
$schema->storage_type('DBICTest::Legacy::Storage');
$schema->connection('dbi:SQLite::memory:');

$schema->storage->dbh_do( sub { $_[1]->do(<<'EOS') } );
CREATE TABLE artist (
  artistid INTEGER PRIMARY KEY NOT NULL,
  name varchar(100),
  rank integer NOT NULL DEFAULT 13,
  charfield char(10)
)
EOS

my $legacy = sub { $schema->resultset('Artist')->search({ name => 'foo'})->next };
if (DBIx::Class->VERSION >= 0.09) {
  &throws_ok(
    $legacy,
    qr/XXXXXXXXX not sure what error to put here yet XXXXXXXXXXXXXXX/,
    'deprecated use of source_bind_attributes throws',
  );
}
else {
  &warnings_exist (
    $legacy,
    qr/\QThe source_bind_attributes() override in DBICTest::Legacy::Storage relies on a deprecated codepath/,
    'Warning issued during invocation of legacy storage codepath',
  );
}

done_testing;