# HG changeset patch # User Sergey # Date 1257719956 -10800 # Node ID d59526f6310edbfdc2aa3eae33a67646028a248a # Parent dd4d72600c69c4c3e9284388e41075356c6c56ae Small fixes to Test framework (correct handlinf of the compilation errors in the test units) Imported and refactored SQL DB schema from the old project diff -r dd4d72600c69 -r d59526f6310e Lib/IMPL/ORM/Object.pm --- a/Lib/IMPL/ORM/Object.pm Tue Nov 03 16:31:47 2009 +0300 +++ b/Lib/IMPL/ORM/Object.pm Mon Nov 09 01:39:16 2009 +0300 @@ -78,7 +78,7 @@ $schema->appendChild( new IMPL::ORM::Schema::Relation::HasOne($ormProp->Name,$entity->entityName)); } else { # хз что. Скорее всего не удалось квалифицировать тип свойства не как ссылочный и как поле. - die new IMPL::Exception('Uexpected error due building schema for a class', $ormProp->Class, $ormProp->Name); + die new IMPL::Exception('Uexpected error due building schema for a class', $ormProp->Class, $ormProp->Name,$ormProp->Type); } } diff -r dd4d72600c69 -r d59526f6310e Lib/IMPL/ORM/Schema.pm --- a/Lib/IMPL/ORM/Schema.pm Tue Nov 03 16:31:47 2009 +0300 +++ b/Lib/IMPL/ORM/Schema.pm Mon Nov 09 01:39:16 2009 +0300 @@ -14,7 +14,7 @@ public property mapValueTypes => prop_get | owner_set; public property mapReferenceTypes => prop_get | owner_set; public property mapPending => prop_get | owner_set; - public property prefix => prop_all; + public property prefix => prop_get | owner_set; } sub CTOR { @@ -91,9 +91,20 @@ sub usePrefix { my ($this,$prefix) = @_; + $prefix .= '::' if $prefix and $prefix !~ /::$/; + (ref $this ? $this : $this->instance)->prefix($prefix); } +sub CompleteSchema { + my ($this) = @_; + + $this = ref $this ? $this : $this->instance; + + $this->mapReferenceTypes->{$_} = $_->ormGetSchema($this,delete $this->mapPending->{$_}) + foreach (keys %{$this->mapPending}); +} + 1; __END__ diff -r dd4d72600c69 -r d59526f6310e Lib/IMPL/Test/BadUnit.pm --- a/Lib/IMPL/Test/BadUnit.pm Tue Nov 03 16:31:47 2009 +0300 +++ b/Lib/IMPL/Test/BadUnit.pm Mon Nov 09 01:39:16 2009 +0300 @@ -13,12 +13,18 @@ our %CTOR = ( 'IMPL::Test::Unit' => sub { - my ($unit,$message,$error) = @_; - return new IMPL::Test::Unit::TestInfo( - BadUnitTest => sub { - die new IMPL::Test::FailException($message,$unit,eval {$error->isa('IMPL::Exception')} ? $error->toString(1) : $error) - } - ); + if (@_>1) { + # Unit construction + my ($unit,$message,$error) = @_; + return new IMPL::Test::Unit::TestInfo( + BadUnitTest => sub { + die new IMPL::Test::FailException($message,$unit,eval {$error->isa('IMPL::Exception')} ? $error->toString(1) : $error) + } + ); + } else { + # test construction + return @_; + } } ); @@ -45,5 +51,15 @@ $inst->callCTOR(@args{qw(UnitName Message)}); } +sub List { + my ($this) = @_; + my $error = $this->Error; + return new IMPL::Test::Unit::TestInfo( + BadUnitTest => sub { + die new IMPL::Test::FailException($this->Message,$this->UnitName,eval {$error->isa('IMPL::Exception')} ? $error->toString(1) : $error) + } + ); +} + 1; diff -r dd4d72600c69 -r d59526f6310e Lib/IMPL/Test/Plan.pm --- a/Lib/IMPL/Test/Plan.pm Tue Nov 03 16:31:47 2009 +0300 +++ b/Lib/IMPL/Test/Plan.pm Mon Nov 09 01:39:16 2009 +0300 @@ -64,8 +64,13 @@ my %info; # preload module + undef $@; + eval "require $Unit" unless (ref $Unit); + # handle loading errors + $Unit = new IMPL::Test::BadUnit($Unit,"Failed to load unit",$@) if $@; + $info{Unit} = $Unit; try { $info{Tests} = [map $Unit->new($_), $Unit->List]; diff -r dd4d72600c69 -r d59526f6310e _test/Test/ORM/Schema.pm --- a/_test/Test/ORM/Schema.pm Tue Nov 03 16:31:47 2009 +0300 +++ b/_test/Test/ORM/Schema.pm Mon Nov 09 01:39:16 2009 +0300 @@ -51,8 +51,8 @@ BEGIN { public property Id => prop_get, { type => 'String' }; # Field public property User => prop_get, { type => 'Test::ORM::Schema::Data::User' }; # HasOne - public property Data => prop_all, { type => Map( 'String','String' ) }; # HasOne - public property AccessTime => prop_get { type => 'DateTime' }; # Field + #public property Data => prop_all, { type => Map( 'String','String' ) }; # HasOne + public property AccessTime => prop_get, { type => 'DateTime' }; # Field } package Test::ORM::Schema::Data; @@ -73,4 +73,6 @@ Session ); +__PACKAGE__->CompleteSchema; + 1;