Final Moose Case

ts final Case postette day here in the Moose-pen

For the final clean up of Case I am going to add in a few tests in Database::Accessor that should have been there in the first place.

First I will add this;


whens => [
{
left => { name => 'Price', },
right => { value => '10' },
operator => '<',
statement => { name => 'price' }
},
++ [{
++ left => { name => 'Price', },
++ right => { value => '10' },
++ operator => '<',
++ statement => { name => 'price' }
++ },
++ {
++ condition => 'and',
++ left => { name => 'Price', },
++ right => [{ value => '10' },
++ { value => '10' }],
++ operator => 'in',
++ statement => { name => 'price' }
++ }
++ ],
{ statement => { name => 'prices' } }
]

which will allow me to do these new tests;

ok( ref( $dad->elements->[3]->whens->[1] ) eq 'ARRAY',
'Element 3 whens->[1] Is an Array' );
ok( ref($dad->elements->[3]->whens->[1]->[0]->left ) eq 'Database::Accessor::Element',
'Element 3 whens->[1]->[0]->left Is an Database::Accessor::Element' );
ok( $dad->elements->[3]->whens->[1]->[0]->left->view eq 'People',
'Element 3 whens->[1]->[0]->left->view is People' );
ok( $dad->elements->[3]->whens->[1]->[1]->condition eq 'AND',
'Element 3 whens->[1]->[1]->condition Is an UC AND' );
ok( $dad->elements->[3]->whens->[1]->[1]->operator eq 'IN',
'Element 3 whens->[1]->[1]->operator Is an UC IN' );

Which make sure I have an array, the values on that array are coerced correctly, the 'view' attribute is set on elements, and the 'condition' and 'operator' attributes have been upper cased.

Finally I can add in one more test


ok( $dad->elements->[3]->whens->[2]->statement->view eq 'People',
'Element 3 whens->[2]->statement->view is People' );

that checks that final 'statement' to make sure the 'view' is set which means it is being processed by the '_check_element' sub;

Now when I run that test I get;



ok 38 - Element 3 whens->[1] Is an Array
ok 39 - Element 3 whens->[1]->[0]->left Is an Database::Accessor::Element
ok 40 - Element 3 whens->[1]->[0]->left->view is People
ok 41 - Element 3 whens->[1]->[1]->condition Is an UC AND
ok 42 - Element 3 whens->[1]->[1]->operator Is an UC IN
ok 43 - Element 3 whens->[2]->statement is an element
ok 44 - Element 3 whens->[2]->statement->name is prices
ok 45 - Element 3 whens->[2]->statement->view is People

I think that covers off all of the little problems I had when working though the DBI::Driver side of things. Just think how much time I would of saved had I added in these tests to start. Oh well hind-sight is always 20/20

milch017s1.jpg

Leave a comment

About byterock

user-pic Long time Perl guy, a few CPAN mods allot of work on DBD::Oracle and a few YAPC presentations