2 #===============================================================================
6 # DESCRIPTION: test sql manipulation funtions
11 # AUTHOR: Gordon Irving (), <goraxe@cpan.org>
13 # CREATED: 12/12/09 12:44:57 GMT
15 #===============================================================================
26 eval "use DBIx::Class::Admin";
27 plan skip_all => "Deps not installed: $@" if $@;
33 use ok 'DBIx::Class::Admin';
36 { # test data maniplulation functions
38 # create a DBICTest so we can steal its connect info
39 my $schema = DBICTest->init_schema(
43 my $admin = DBIx::Class::Admin->new(
44 schema_class=> "DBICTest::Schema",
45 connect_info => $schema->storage->connect_info(),
49 isa_ok ($admin, 'DBIx::Class::Admin', 'create the admin object');
51 $admin->insert('Employee', { name => 'Matt' });
52 my $employees = $schema->resultset('Employee');
53 is ($employees->count(), 1, "insert okay" );
55 my $employee = $employees->find(1);
56 is($employee->name(), 'Matt', "insert valid" );
58 $admin->update('Employee', {name => 'Trout'}, {name => 'Matt'});
60 $employee = $employees->find(1);
61 is($employee->name(), 'Trout', "update Matt to Trout" );
63 $admin->insert('Employee', {name =>'Aran'});
66 [$employee->result_source->columns() ],
67 [1,1,undef,undef,undef,'Trout'],
68 [2,2,undef,undef,undef,'Aran']
71 lives_ok { $data = $admin->select('Employee')} 'can retrive data from database';
72 cmp_deeply($data, $expected_data, 'DB matches whats expected');
74 $admin->delete('Employee', {name=>'Trout'});
75 my $del_rs = $employees->search({name => 'Trout'});
76 is($del_rs->count(), 0, "delete Trout" );
77 is ($employees->count(), 1, "left Aran" );