2 #===============================================================================
6 # DESCRIPTION: test sql manipulation funtions
11 # AUTHOR: Gordon Irving (), <goraxe@cpan.org>
13 # CREATED: 12/12/09 12:44:57 GMT
15 #===============================================================================
28 use File::Spec::Functions qw(catdir);
29 use lib catdir($Bin,'..', '..','lib');
30 use lib catdir($Bin,'..', 'lib');
31 eval "use DBIx::Class::Admin";
32 plan skip_all => "Deps not installed: $@" if $@;
37 use ok 'DBIx::Class::Admin';
41 { # test data maniplulation functions
43 # create a DBICTest so we can steal its connect info
44 my $schema = DBICTest->init_schema(
51 my $admin = DBIx::Class::Admin->new(
52 schema_class=> "DBICTest::Schema",
53 connect_info => $schema->storage->connect_info(),
57 isa_ok ($admin, 'DBIx::Class::Admin', 'create the admin object');
59 $admin->insert('Employee', { name => 'Matt' });
60 my $employees = $schema->resultset('Employee');
61 is ($employees->count(), 1, "insert okay" );
63 my $employee = $employees->find(1);
64 is($employee->name(), 'Matt', "insert valid" );
66 $admin->update('Employee', {name => 'Trout'}, {name => 'Matt'});
68 $employee = $employees->find(1);
69 is($employee->name(), 'Trout', "update Matt to Trout" );
71 $admin->insert('Employee', {name =>'Aran'});
74 [$employee->result_source->columns() ],
75 [1,1,undef,undef,undef,'Trout'],
76 [2,2,undef,undef,undef,'Aran']
79 lives_ok { $data = $admin->select('Employee')} 'can retrive data from database';
80 cmp_deeply($data, $expected_data, 'DB matches whats expected');
82 $admin->delete('Employee', {name=>'Trout'});
83 my $del_rs = $employees->search({name => 'Trout'});
84 is($del_rs->count(), 0, "delete Trout" );
85 is ($employees->count(), 1, "left Aran" );