Alzabo

 view release on metacpan or  search on metacpan

t/07-methodmaker.t  view on Meta::CPAN

#!/usr/bin/perl -w

use strict;

use File::Spec;

use lib '.', File::Spec->catdir( File::Spec->curdir, 't', 'lib' );

use Alzabo::Test::Utils;

use Test::More;


my @rdbms_names = Alzabo::Test::Utils->rdbms_names;

unless (@rdbms_names)
{
    plan skip_all => 'no test config provided';
    exit;
}

plan tests => 106;


Alzabo::Test::Utils->remove_all_schemas;


use Alzabo::Create::Schema;
use Alzabo::Runtime::Schema;
require Alzabo::MethodMaker;


# doesn't matter which RDBMS is used
my $rdbms = $rdbms_names[0];

my $config = Alzabo::Test::Utils->test_config_for($rdbms);


# these tests use a different schema than the other live DB tests
make_methodmaker_schema(%$config);


Alzabo::MethodMaker->import( schema => $config->{schema_name},
			     all => 1,
			     class_root => 'Alzabo::MM::Test',
			     name_maker => \&namer,
			   );

my $s = Alzabo::Runtime::Schema->load_from_file( name => $config->{schema_name} );


eval { $s->docs_as_pod };
ok( ! $@, 'docs_as_pod should not cause an exception' );


foreach my $t ($s->tables)
{
    my $t_meth = $t->name . '_t';
    ok( $s->can($t_meth),
	"Schema object should have $t_meth method" );

    is( $s->$t_meth(), $t,
	"Results of \$s->$t_meth() should be same as existing table object" );

    foreach my $c ($t->columns)
    {
	my $c_meth = $c->name . '_c';



( run in 0.683 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )