Update Crud::SubClass test.
This commit is contained in:
parent
4c5c9fc840
commit
753cc9b75c
2 changed files with 17 additions and 17 deletions
|
|
@ -29,12 +29,12 @@ plan tests => 4; # Increment this number for each test you create
|
|||
# Create
|
||||
WebGUI::Crud::Subclass->crud_createTable($session);
|
||||
WebGUI::Test->addToCleanup(sub { WebGUI::Crud::Subclass->crud_dropTable($session); });
|
||||
my $record1 = WebGUI::Crud::Subclass->create($session, { field1 => 10 });
|
||||
my $record1 = WebGUI::Crud::Subclass->new($session, { field1 => 10 });
|
||||
isa_ok($record1, "WebGUI::Crud", "isa WebGUI::Crud");
|
||||
is($record1->get('field1'), 10, "got back correct field1 value");
|
||||
|
||||
# bug #10660 (zero should not trigger defaultValue)
|
||||
is(WebGUI::Crud::Subclass->create($session, { field1 => 0 })->get('field1'), 0, 'zero does not trigger default');
|
||||
is(WebGUI::Crud::Subclass->create($session, { field1 => '' })->get('field1'), 5, '..but empty string intentionally triggers default');
|
||||
is(WebGUI::Crud::Subclass->new($session, { field1 => 0 })->get('field1'), 0, 'zero does not trigger default');
|
||||
is(WebGUI::Crud::Subclass->new($session, { field1 => '' })->get('field1'), '', '..but empty string does not trigger default either');
|
||||
|
||||
#vim:ft=perl
|
||||
|
|
|
|||
|
|
@ -2,20 +2,20 @@ package WebGUI::Crud::Subclass;
|
|||
|
||||
use strict;
|
||||
|
||||
use base 'WebGUI::Crud';
|
||||
use Moose;
|
||||
use WebGUI::Definition::Crud;
|
||||
extends 'WebGUI::Crud';
|
||||
define tableName => 'crudSubclass';
|
||||
define tableKey => 'crudSubclassId';
|
||||
has crudSubclassId => (
|
||||
required => 1,
|
||||
is => 'ro',
|
||||
);
|
||||
|
||||
sub crud_definition {
|
||||
my ($class, $session) = @_;
|
||||
my $definition = $class->SUPER::crud_definition($session);
|
||||
$definition->{tableName} = 'crudSubclass';
|
||||
$definition->{tableKey} = 'crudSubclassId';
|
||||
$definition->{sequenceKey} = '';
|
||||
my $properties = $definition->{properties};
|
||||
$properties->{field1} = {
|
||||
fieldType => 'integer',
|
||||
defaultValue => 5,
|
||||
};
|
||||
return $definition;
|
||||
}
|
||||
property field1 => (
|
||||
label => 'field1',
|
||||
fieldType => 'integer',
|
||||
defaultValue => 5,
|
||||
);
|
||||
|
||||
1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue