Changeset 13108
- Timestamp:
- 11/18/11 05:26:10 (6 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Release01x01/UnitTestContrib/test/unit/UploadScriptTests.pm
r12508 r13108 28 28 $this->SUPER::set_up(); 29 29 $UI_FN ||= $this->getUIFn('upload'); 30 my $topicObject=31 Foswiki:: Meta->new( $this->{session}, $this->{test_web},32 $this->{test_topic}, " * Set ATTACHFILESIZELIMIT = 511\n", undef);33 $topicObject->put ( 'FORM',$FORM );30 my ($topicObject) = 31 Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 32 $topicObject->text(" * Set ATTACHFILESIZELIMIT = 511\n"); 33 $topicObject->putAll( 'FORM', $FORM ); 34 34 $topicObject->putAll( 'FIELD', @FIELDS ); 35 35 $topicObject->save( forcenewrevision => 1 ); 36 $this->_assert_meta_stillgood( );36 $this->_assert_meta_stillgood(0); 37 37 38 38 return; … … 406 406 # Assert that we've still got good meta 407 407 sub _assert_meta_stillgood { 408 my ( $this) = @_;408 my ( $this, $assert ) = @_; 409 409 my ($topicObj) = 410 410 Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); … … 413 413 my %tFIELDShash = map { $_->{name} => $_ } @tFIELDS; 414 414 415 $this->assert($tFORM); 416 $this->assert( exists $tFORM->{name} ); 417 $this->assert( $tFORM->{name} eq $FORM->{name} ); 418 $this->assert( scalar(@tFIELDS) ); 419 $this->assert( scalar(@tFIELDS) == scalar(@FIELDS) ); 415 return unless $this->_assert_( $assert, $tFORM ); 416 return unless $this->_assert_( $assert, exists $tFORM->{name} ); 417 return unless $this->_assert_( $assert, $tFORM->{name} eq $FORM->{name} ); 418 return unless $this->_assert_( $assert, scalar(@tFIELDS) ); 419 return 420 unless $this->_assert_( $assert, scalar(@tFIELDS) == scalar(@FIELDS) ); 420 421 foreach my $name ( keys %FIELDShash ) { 421 $this->assert( 422 return 423 unless $this->_assert_( 424 $assert, 422 425 exists $tFIELDShash{$name}, 423 426 "$this->{test_web}.$this->{test_topic} did not contain META:FIELD[name='$name']" 424 ); 425 $this->assert( 427 ); 428 return 429 unless $this->_assert_( 430 $assert, 426 431 exists $tFIELDShash{$name}->{value}, 427 432 "$this->{test_web}.$this->{test_topic} did not contain a value key in META:FIELD[name='$name']" 428 ); 429 $this->assert( 433 ); 434 return 435 unless $this->_assert_( 436 $assert, 430 437 $tFIELDShash{$name}->{value} eq $FIELDShash{$name}->{value}, 431 438 "'$this->{test_web}.$this->{test_topic}'/META:FIELD[name='$name'].value = '$tFIELDShash{$name}->{value}' but expected '$FIELDShash{$name}->{value}'" 432 ); 433 } 434 435 return; 439 ); 440 } 441 442 return; 443 } 444 445 # ->assert() from set_up crashes TestRunner if LocalLib has ASSERTS=1, so die 446 # differently inside set_up 447 sub _assert_ { 448 my ( $this, $assert, $condition, $message ) = @_; 449 450 if ( !defined $assert || $assert ) { 451 $this->assert( $condition, $message ); 452 } 453 elsif ( !$condition ) { 454 print STDERR 'ASSERT FAILED during set_up: ' . ( $message || '' ); 455 } 456 457 return $condition; 436 458 } 437 459
Note: See TracChangeset
for help on using the changeset viewer.
