annotate _test/Test/ORM/Schema.pm @ 31:d59526f6310e

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
author Sergey
date Mon, 09 Nov 2009 01:39:16 +0300
parents dd4d72600c69
children d660fb38b7cc
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
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
10 test ExtractClassSchema => sub {
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
11 my ($this) = @_;
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
12
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
13 my $schema = Test::ORM::Schema::Data::User->ormGetSchema('Test::ORM::Schema::Data');
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
14 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
15
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
16 return 1;
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
17 };
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
18
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
19 test StaticSchema => sub {
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
20 my ($this) = @_;
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
21
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
22 my $schema = Test::ORM::Schema::Data->instance;
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
23
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
24 return 1;
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
25 };
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
26
28
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
27
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
28 package Test::ORM::Schema::Data::User;
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
29 use base qw(IMPL::ORM::Object);
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
30 use IMPL::Class::Property;
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
31
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
32 BEGIN {
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
33 public property Name => prop_all, { type => 'String' }; # Field
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
34 public property Id => prop_all, { type => 'String' }; # Field
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
35 public property Roles => prop_all | prop_list, { type=> 'Test::ORM::Schema::Data::Role'}; # HasMany
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
36 }
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
37
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
38 package Test::ORM::Schema::Data::Role;
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
39 use base qw(IMPL::ORM::Object);
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
40 use IMPL::Class::Property;
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
41
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
42 BEGIN {
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
43 public property Name => prop_all, { type => 'String' }; # Field
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::Session;
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 use IMPL::ORM::Helpers qw(Map);
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
50
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
51 BEGIN {
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
52 public property Id => prop_get, { type => 'String' }; # Field
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
53 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
54 #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
55 public property AccessTime => prop_get, { type => 'DateTime' }; # Field
28
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
56 }
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
57
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
58 package Test::ORM::Schema::Data;
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
59 use base qw(IMPL::ORM::Schema);
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
60
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
61 __PACKAGE__->ValueTypes (
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
62 'String' => 'IMPL::ORM::Value::String',
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
63 'DateTime' => 'IMPL::ORM::Value::DateTime',
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
64 'Integer' => 'IMPL::ORM::Value::Inetger',
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
65 'Float' => 'IMPL::ORM::Value::Float',
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
66 'Decimal' => 'IMPL::ORM::Value::Decimal'
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
67 );
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
68
30
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
69 __PACKAGE__->usePrefix(__PACKAGE__);
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
70 __PACKAGE__->Classes qw(
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
71 User
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
72 Role
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
73 Session
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
74 );
dd4d72600c69 ORM in works
Sergey
parents: 28
diff changeset
75
31
d59526f6310e Small fixes to Test framework (correct handlinf of the compilation errors in the test units)
Sergey
parents: 30
diff changeset
76 __PACKAGE__->CompleteSchema;
d59526f6310e Small fixes to Test framework (correct handlinf of the compilation errors in the test units)
Sergey
parents: 30
diff changeset
77
28
6d33f75c6e1f ORM in works
Sergey
parents:
diff changeset
78 1;