5 #----------------------------------------------------------------------
7 #----------------------------------------------------------------------
10 eval "use DBIx::Class::CDBICompat;";
12 plan (skip_all => 'Class::Trigger and DBIx::ContextualFetch required');
15 eval "use DBD::SQLite";
16 plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 25);
24 is_deeply [ Lazy->columns('Primary') ], [qw/this/], "Pri";
25 is_deeply [ sort Lazy->columns('Essential') ], [qw/opop this/], "Essential";
26 is_deeply [ sort Lazy->columns('things') ], [qw/that this/], "things";
27 is_deeply [ sort Lazy->columns('horizon') ], [qw/eep orp/], "horizon";
28 is_deeply [ sort Lazy->columns('vertical') ], [qw/oop opop/], "vertical";
29 is_deeply [ sort Lazy->columns('All') ], [qw/eep oop opop orp that this/], "All";
32 my @groups = Lazy->__grouper->groups_for(Lazy->find_column('this'));
33 is_deeply [ sort @groups ], [sort qw/things Essential Primary/], "this (@groups)";
37 my @groups = Lazy->__grouper->groups_for(Lazy->find_column('that'));
38 is_deeply \@groups, [qw/things/], "that (@groups)";
41 Lazy->create({ this => 1, that => 2, oop => 3, opop => 4, eep => 5 });
43 ok(my $obj = Lazy->retrieve(1), 'Retrieve by Primary');
44 ok($obj->_attribute_exists('this'), "Gets primary");
45 ok($obj->_attribute_exists('opop'), "Gets other essential");
46 ok(!$obj->_attribute_exists('that'), "But other things");
47 ok(!$obj->_attribute_exists('eep'), " nor eep");
48 ok(!$obj->_attribute_exists('orp'), " nor orp");
49 ok(!$obj->_attribute_exists('oop'), " nor oop");
51 ok(my $val = $obj->eep, 'Fetch eep');
52 ok($obj->_attribute_exists('orp'), 'Gets orp too');
53 ok(!$obj->_attribute_exists('oop'), 'But still not oop');
54 ok(!$obj->_attribute_exists('that'), 'nor that');
57 Lazy->columns(All => qw/this that eep orp oop opop/);
58 ok(my $obj = Lazy->retrieve(1), 'Retrieve by Primary');
59 ok !$obj->_attribute_exists('oop'), " Don't have oop";
61 ok !$obj->_attribute_exists('oop'),
62 " Don't have oop - even after getting eep";
65 # Test contructor breaking.
67 eval { # Need a hashref
68 Lazy->create(this => 10, that => 20, oop => 30, opop => 40, eep => 50);
73 Lazy->create({ this => 10, that => 20, theother => 30 });
77 eval { # Multiple false columns
78 Lazy->create({ this => 10, that => 20, theother => 30, andanother => 40 });