2 #===============================================================================
6 # DESCRIPTION: test sql manipulation funtions
11 # AUTHOR: Gordon Irving (), <Gordon.irving@sophos.com>
13 # CREATED: 12/12/09 12:44:57 GMT
15 #===============================================================================
28 use lib dir($Bin,'..', '..','lib')->stringify;
29 use lib dir($Bin,'..', 'lib')->stringify;
31 use ok 'DBIx::Class::Admin';
35 { # test data maniplulation functions
37 # create a DBICTest so we can steal its connect info
38 my $schema = DBICTest->init_schema(
45 my $admin = DBIx::Class::Admin->new(
46 schema_class=> "DBICTest::Schema",
47 connect_info => $schema->storage->connect_info(),
51 isa_ok ($admin, 'DBIx::Class::Admin', 'create the admin object');
53 $admin->insert_data('Employee', { name => 'Matt' });
54 my $employees = $schema->resultset('Employee');
55 is ($employees->count(), 1, "insert okay" );
57 my $employee = $employees->find(1);
58 is($employee->name(), 'Matt', "insert valid" );
60 $admin->update_data('Employee', {name => 'Trout'}, {name => 'Matt'});
62 $employee = $employees->find(1);
63 is($employee->name(), 'Trout', "update Matt to Trout" );
65 $admin->insert_data('Employee', {name =>'Aran'});
68 [$employee->result_source->columns() ],
69 [1,1,undef,undef,undef,'Trout'],
70 [2,2,undef,undef,undef,'Aran']
73 lives_ok { $data = $admin->select_data('Employee')} 'can retrive data from database';
74 cmp_deeply($data, $expected_data, 'DB matches whats expected');
76 $admin->delete_data('Employee', {name=>'Trout'});
77 my $del_rs = $employees->search({name => 'Trout'});
78 is($del_rs->count(), 0, "delete Trout" );
79 is ($employees->count(), 1, "left Aran" );