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 lib dir($Bin,'..', '..','lib')->stringify;
34 use lib dir($Bin,'..', 'lib')->stringify;
36 use ok 'DBIx::Class::Admin';
40 { # test data maniplulation functions
42 # create a DBICTest so we can steal its connect info
43 my $schema = DBICTest->init_schema(
50 my $admin = DBIx::Class::Admin->new(
51 schema_class=> "DBICTest::Schema",
52 connect_info => $schema->storage->connect_info(),
56 isa_ok ($admin, 'DBIx::Class::Admin', 'create the admin object');
58 $admin->insert('Employee', { name => 'Matt' });
59 my $employees = $schema->resultset('Employee');
60 is ($employees->count(), 1, "insert okay" );
62 my $employee = $employees->find(1);
63 is($employee->name(), 'Matt', "insert valid" );
65 $admin->update('Employee', {name => 'Trout'}, {name => 'Matt'});
67 $employee = $employees->find(1);
68 is($employee->name(), 'Trout', "update Matt to Trout" );
70 $admin->insert('Employee', {name =>'Aran'});
73 [$employee->result_source->columns() ],
74 [1,1,undef,undef,undef,'Trout'],
75 [2,2,undef,undef,undef,'Aran']
78 lives_ok { $data = $admin->select('Employee')} 'can retrive data from database';
79 cmp_deeply($data, $expected_data, 'DB matches whats expected');
81 $admin->delete('Employee', {name=>'Trout'});
82 my $del_rs = $employees->search({name => 'Trout'});
83 is($del_rs->count(), 0, "delete Trout" );
84 is ($employees->count(), 1, "left Aran" );