[Bps-public-commit] r11472 - SVN-PropDB/t

clkao at bestpractical.com clkao at bestpractical.com
Thu Apr 3 23:30:51 EDT 2008


Author: clkao
Date: Thu Apr  3 23:30:51 2008
New Revision: 11472

Added:
   SVN-PropDB/t/validation.t

Log:
more validation test.

Added: SVN-PropDB/t/validation.t
==============================================================================
--- (empty file)
+++ SVN-PropDB/t/validation.t	Thu Apr  3 23:30:51 2008
@@ -0,0 +1,31 @@
+package App::Record;
+use base 'Prophet::Record';
+
+sub validate_prop_point {
+    my ($self, %args) = @_;
+    
+    return 1 if $args{props}{point} =~ m/^\d+$/;
+    $args{errors}{point} = 'must be numbers';
+    return 0;
+    
+}
+
+package main;
+use warnings;
+use strict;
+
+use Prophet::Test tests => 2;
+use Test::Exception;
+
+
+as_alice {
+    my $cli  = Prophet::CLI->new();
+    my $rec = App::Record->new( handle => $cli->handle, type => 'foo' );
+
+    ok($rec->create( props => { foo => 'bar', point => '123' } ));
+
+    throws_ok {
+        $rec->create( props => { foo => 'bar', point => 'orz' } );
+    } qr/must be numbers/;
+};
+



More information about the Bps-public-commit mailing list