From: <chr...@us...> - 2006-05-03 19:51:20
|
Revision: 851 Author: chromatic Date: 2006-05-03 12:51:05 -0700 (Wed, 03 May 2006) ViewCVS: http://svn.sourceforge.net/everydevel/?rev=851&view=rev Log Message: ----------- r16501@windwheel: chromatic | 2006-05-03 12:50:46 -0700 Ported tests for htmlcode nodes to Test::Class. Made restrictTitle() test a little less strict in node tests. Modified Paths: -------------- trunk/ebase/MANIFEST trunk/ebase/lib/Everything/Node/Test/node.pm trunk/ebase/t/Node/htmlcode.t Added Paths: ----------- trunk/ebase/lib/Everything/Node/Test/htmlcode.pm Property Changed: ---------------- trunk/ebase/ Property changes on: trunk/ebase ___________________________________________________________________ Name: svk:merge - a6810612-c0f9-0310-9d3e-a9e4af8c5745:/ebase/offline:16499 + a6810612-c0f9-0310-9d3e-a9e4af8c5745:/ebase/offline:16501 Modified: trunk/ebase/MANIFEST =================================================================== --- trunk/ebase/MANIFEST 2006-05-03 19:49:41 UTC (rev 850) +++ trunk/ebase/MANIFEST 2006-05-03 19:51:05 UTC (rev 851) @@ -88,6 +88,7 @@ lib/Everything/Node/usergroup.pm lib/Everything/Node/workspace.pm lib/Everything/Node/Test/dbtable.pm +lib/Everything/Node/Test/htmlcode.pm lib/Everything/Node/Test/node.pm lib/Everything/Node/Test/nodetype.pm lib/Everything/Node/Test/setting.pm Added: trunk/ebase/lib/Everything/Node/Test/htmlcode.pm =================================================================== --- trunk/ebase/lib/Everything/Node/Test/htmlcode.pm (rev 0) +++ trunk/ebase/lib/Everything/Node/Test/htmlcode.pm 2006-05-03 19:51:05 UTC (rev 851) @@ -0,0 +1,45 @@ +package Everything::Node::Test::htmlcode; + +use strict; +use warnings; + +use base 'Everything::Node::Test::node'; + +use Test::More; +use SUPER; + +*Everything::Node::htmlcode::SUPER = \&UNIVERSAL::SUPER; + +sub node_class { 'Everything::Node::htmlcode' } + +sub test_dbtables :Test( 2 ) +{ + my $self = shift; + my $class = $self->node_class(); + can_ok( $class, 'dbtables' ); + my @tables = $class->dbtables(); + is_deeply( \@tables, [qw( htmlcode node )], + 'dbtables() should return node tables' ); +} + +1; + +sub test_restrict_title :Test( 4 ) +{ + my $self = shift; + my $node = $self->{node}; + + ok( ! $node->restrictTitle(), + 'restrictTitle() should return false with no title' ); + + $node->{title} = 'bad title'; + ok( ! $node->restrictTitle(), + '... should return false if title contains a space' ); + + like( $self->{errors}[0][0], qr/htmlcode.+invalid characters/, + '... logging an error' ); + + $node->{title} = join( '', ( 'a' .. 'z', 'A' .. 'Z', 0 .. 9 ) ); + ok( $node->restrictTitle(), + '... returning true if title contains only alphanumeric characters' ); +} Property changes on: trunk/ebase/lib/Everything/Node/Test/htmlcode.pm ___________________________________________________________________ Name: svn:mime-type + text/plain; charset=UTF-8 Name: svn:eol-style + native Modified: trunk/ebase/lib/Everything/Node/Test/node.pm =================================================================== --- trunk/ebase/lib/Everything/Node/Test/node.pm 2006-05-03 19:49:41 UTC (rev 850) +++ trunk/ebase/lib/Everything/Node/Test/node.pm 2006-05-03 19:51:05 UTC (rev 851) @@ -344,7 +344,7 @@ $node->{title} = 'o|o'; ok( ! $node->restrictTitle(), '... or a pipe' ); - like( $self->{errors}[0][0], qr/node.+invalid characters/, + like( $self->{errors}[0][0], qr/name.+invalid characters/, '... and should log error' ); $node->{title} = 'a good name zz9'; Modified: trunk/ebase/t/Node/htmlcode.t =================================================================== --- trunk/ebase/t/Node/htmlcode.t 2006-05-03 19:49:41 UTC (rev 850) +++ trunk/ebase/t/Node/htmlcode.t 2006-05-03 19:51:05 UTC (rev 851) @@ -1,62 +1,7 @@ -#!/usr/bin/perl +#! perl use strict; use warnings; -use vars qw( $AUTOLOAD $errors ); - -BEGIN -{ - chdir 't' if -d 't'; - use lib 'lib'; -} - -use Test::More tests => 8; - -my $module = 'Everything::Node::htmlcode'; -use_ok( $module ) or exit; -ok( $module->isa( 'Everything::Node::node' ), 'htmlcode should extend node' ); - -can_ok( $module, 'dbtables' ); -my @tables = $module->dbtables(); -is_deeply( \@tables, [qw( htmlcode node )], - 'dbtables() should return node tables' ); - -local *Everything::logErrors; -*Everything::logErrors = sub -{ - $main::errors = join( ' ', @_ ); -}; - -# restrictTitle() -ok( !restrictTitle( {} ), 'restrictTitle() should return false with no title' ); -{ - ok( - !restrictTitle( { title => 'bad title' } ), - '... should return false if title contains a space' - ); - like( $errors, qr/htmlcode.+invalid characters/, '... logging an error' ); - -} -ok( - restrictTitle( - { title => join( '', ( 'a' .. 'z', 'A' .. 'Z', 0 .. 9 ) ) } - ), - '... should return true if title contains only alphanumeric characters' -); - -sub AUTOLOAD -{ - return if $AUTOLOAD =~ /DESTROY$/; - - no strict 'refs'; - $AUTOLOAD =~ s/^main:://; - - my $sub = "Everything::Node::htmlcode::$AUTOLOAD"; - - if ( defined &{$sub} ) - { - *{$AUTOLOAD} = \&{$sub}; - goto &{$sub}; - } -} +use Everything::Node::Test::htmlcode; +Everything::Node::Test::htmlcode->runtests(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |