annotate _test/Test/ORM/Schema.pm @ 43:009aa9ca2e48

merge
author Sergey
date Thu, 07 Jan 2010 15:41:49 +0300
parents d660fb38b7cc
children 32d2350fccf9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
28
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
1 package Test::ORM::Schema;
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
2 use strict;
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
3 use warnings;
30
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
4 use base qw(IMPL::Test::Unit);
28
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
5
30
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
6 __PACKAGE__->PassThroughArgs;
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
7
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
8 use IMPL::Test qw(test failed);
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
9
38
d660fb38b7cc small fixes
Sergey
parents: 31
diff changeset
10 require IMPL::ORM::Schema::TransformToSQL;
d660fb38b7cc small fixes
Sergey
parents: 31
diff changeset
11
30
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
12 test ExtractClassSchema => sub {
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
13 my ($this) = @_;
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
14
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
15 my $schema = Test::ORM::Schema::Data::User->ormGetSchema('Test::ORM::Schema::Data');
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
16 failed "Wrong number of the elements","expected: 4","got: ".$schema->childNodes->Count unless $schema->childNodes->Count == 4;
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
17
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
18 return 1;
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
19 };
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
20
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
21 test StaticSchema => sub {
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
22 my ($this) = @_;
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
23
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
24 my $schema = Test::ORM::Schema::Data->instance;
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
25
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
26 return 1;
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
27 };
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
28
38
d660fb38b7cc small fixes
Sergey
parents: 31
diff changeset
29 test TransformDataSchema => sub {
d660fb38b7cc small fixes
Sergey
parents: 31
diff changeset
30 my $sqlSchema = IMPL::ORM::Schema::TransformToSQL->Std->Transform(Test::ORM::Schema::Data->instance)
d660fb38b7cc small fixes
Sergey
parents: 31
diff changeset
31 or failed("Failed to transform a schema");
d660fb38b7cc small fixes
Sergey
parents: 31
diff changeset
32 $sqlSchema->Dispose;
d660fb38b7cc small fixes
Sergey
parents: 31
diff changeset
33 };
d660fb38b7cc small fixes
Sergey
parents: 31
diff changeset
34
28
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
35
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
36 package Test::ORM::Schema::Data::User;
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
37 use base qw(IMPL::ORM::Object);
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
38 use IMPL::Class::Property;
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
39
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
40 BEGIN {
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
41 public property Name => prop_all, { type => 'String' }; # Field
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
42 public property Id => prop_all, { type => 'String' }; # Field
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
43 public property Roles => prop_all | prop_list, { type=> 'Test::ORM::Schema::Data::Role'}; # HasMany
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
44 }
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
45
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
46 package Test::ORM::Schema::Data::Role;
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
47 use base qw(IMPL::ORM::Object);
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
48 use IMPL::Class::Property;
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
49
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
50 BEGIN {
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
51 public property Name => prop_all, { type => 'String' }; # Field
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
52 }
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
53
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
54 package Test::ORM::Schema::Data::Session;
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
55 use base qw(IMPL::ORM::Object);
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
56 use IMPL::Class::Property;
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
57 use IMPL::ORM::Helpers qw(Map);
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
58
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
59 BEGIN {
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
60 public property Id => prop_get, { type => 'String' }; # Field
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
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
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
64 }
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
65
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
66 package Test::ORM::Schema::Data;
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
67 use base qw(IMPL::ORM::Schema);
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
68
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
69 __PACKAGE__->ValueTypes (
38
d660fb38b7cc small fixes
Sergey
parents: 31
diff changeset
70 String => 'IMPL::ORM::Value::String',
d660fb38b7cc small fixes
Sergey
parents: 31
diff changeset
71 DateTime => 'IMPL::ORM::Value::DateTime',
d660fb38b7cc small fixes
Sergey
parents: 31
diff changeset
72 Integer => 'IMPL::ORM::Value::Inetger',
d660fb38b7cc small fixes
Sergey
parents: 31
diff changeset
73 Float => 'IMPL::ORM::Value::Float',
d660fb38b7cc small fixes
Sergey
parents: 31
diff changeset
74 Decimal => 'IMPL::ORM::Value::Decimal'
28
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
75 );
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
76
30
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
77 __PACKAGE__->usePrefix(__PACKAGE__);
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
78 __PACKAGE__->Classes qw(
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
79 User
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
80 Role
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
81 Session
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
82 );
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
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
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
86 1;