Mercurial > pub > Impl
annotate _test/Test/ORM/Schema.pm @ 40:ac21a032e7a9
bnf parser in progress
author | Sergey |
---|---|
date | Thu, 10 Dec 2009 17:43:39 +0300 |
parents | d660fb38b7cc |
children | 32d2350fccf9 |
rev | line source |
---|---|
28 | 1 package Test::ORM::Schema; |
2 use strict; | |
3 use warnings; | |
30 | 4 use base qw(IMPL::Test::Unit); |
28 | 5 |
30 | 6 __PACKAGE__->PassThroughArgs; |
7 | |
8 use IMPL::Test qw(test failed); | |
9 | |
38 | 10 require IMPL::ORM::Schema::TransformToSQL; |
11 | |
30 | 12 test ExtractClassSchema => sub { |
13 my ($this) = @_; | |
14 | |
15 my $schema = Test::ORM::Schema::Data::User->ormGetSchema('Test::ORM::Schema::Data'); | |
16 failed "Wrong number of the elements","expected: 4","got: ".$schema->childNodes->Count unless $schema->childNodes->Count == 4; | |
17 | |
18 return 1; | |
19 }; | |
20 | |
21 test StaticSchema => sub { | |
22 my ($this) = @_; | |
23 | |
24 my $schema = Test::ORM::Schema::Data->instance; | |
25 | |
26 return 1; | |
27 }; | |
28 | |
38 | 29 test TransformDataSchema => sub { |
30 my $sqlSchema = IMPL::ORM::Schema::TransformToSQL->Std->Transform(Test::ORM::Schema::Data->instance) | |
31 or failed("Failed to transform a schema"); | |
32 $sqlSchema->Dispose; | |
33 }; | |
34 | |
28 | 35 |
36 package Test::ORM::Schema::Data::User; | |
37 use base qw(IMPL::ORM::Object); | |
38 use IMPL::Class::Property; | |
39 | |
40 BEGIN { | |
41 public property Name => prop_all, { type => 'String' }; # Field | |
42 public property Id => prop_all, { type => 'String' }; # Field | |
43 public property Roles => prop_all | prop_list, { type=> 'Test::ORM::Schema::Data::Role'}; # HasMany | |
44 } | |
45 | |
46 package Test::ORM::Schema::Data::Role; | |
47 use base qw(IMPL::ORM::Object); | |
48 use IMPL::Class::Property; | |
49 | |
50 BEGIN { | |
51 public property Name => prop_all, { type => 'String' }; # Field | |
52 } | |
53 | |
54 package Test::ORM::Schema::Data::Session; | |
55 use base qw(IMPL::ORM::Object); | |
56 use IMPL::Class::Property; | |
57 use IMPL::ORM::Helpers qw(Map); | |
58 | |
59 BEGIN { | |
60 public property Id => prop_get, { type => 'String' }; # Field | |
61 public property User => prop_get, { type => 'Test::ORM::Schema::Data::User' }; # HasOne | |
31
d59526f6310e
Small fixes to Test framework (correct handlinf of the compilation errors in the test units)
Sergey
parents:
30
diff
changeset
|
62 #public property Data => prop_all, { type => Map( 'String','String' ) }; # HasOne |
d59526f6310e
Small fixes to Test framework (correct handlinf of the compilation errors in the test units)
Sergey
parents:
30
diff
changeset
|
63 public property AccessTime => prop_get, { type => 'DateTime' }; # Field |
28 | 64 } |
65 | |
66 package Test::ORM::Schema::Data; | |
67 use base qw(IMPL::ORM::Schema); | |
68 | |
69 __PACKAGE__->ValueTypes ( | |
38 | 70 String => 'IMPL::ORM::Value::String', |
71 DateTime => 'IMPL::ORM::Value::DateTime', | |
72 Integer => 'IMPL::ORM::Value::Inetger', | |
73 Float => 'IMPL::ORM::Value::Float', | |
74 Decimal => 'IMPL::ORM::Value::Decimal' | |
28 | 75 ); |
76 | |
30 | 77 __PACKAGE__->usePrefix(__PACKAGE__); |
78 __PACKAGE__->Classes qw( | |
79 User | |
80 Role | |
81 Session | |
82 ); | |
83 | |
31
d59526f6310e
Small fixes to Test framework (correct handlinf of the compilation errors in the test units)
Sergey
parents:
30
diff
changeset
|
84 __PACKAGE__->CompleteSchema; |
d59526f6310e
Small fixes to Test framework (correct handlinf of the compilation errors in the test units)
Sergey
parents:
30
diff
changeset
|
85 |
28 | 86 1; |